Skip to content

Use internal sparse solver to replace EIGEN and MKL #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 114 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
763f211
simplfy readme
TonyXiang8787 Apr 22, 2022
beb51c2
some wording
TonyXiang8787 Apr 22, 2022
4267967
some notes on arm
TonyXiang8787 Apr 22, 2022
cc9ef06
fix a bug for source flat start
TonyXiang8787 Apr 23, 2022
fe3495d
reproduce bug by adding test
TonyXiang8787 Apr 23, 2022
e055801
add comment
TonyXiang8787 Apr 23, 2022
8f7c092
pytest support multiple methods
TonyXiang8787 Apr 24, 2022
73dbb70
modify cpp test
TonyXiang8787 Apr 24, 2022
cedf978
add const
TonyXiang8787 Apr 24, 2022
07a2249
handle exception
TonyXiang8787 Apr 24, 2022
1826ae6
update examples
TonyXiang8787 Apr 24, 2022
0320f8e
Merge branch 'main' into feature/simplfy-readme
TonyXiang8787 Apr 25, 2022
57085c9
Merge branch 'main' into feature/simplfy-readme
TonyXiang8787 Apr 26, 2022
0b24226
begin to record fill-in
TonyXiang8787 May 11, 2022
6a267d8
build graph
TonyXiang8787 May 11, 2022
8568793
add fill-ins
TonyXiang8787 May 11, 2022
2fc52e0
update bug, not passed yet
TonyXiang8787 May 12, 2022
c88069d
fix bug on 12
TonyXiang8787 May 12, 2022
c3b99b0
fix test
TonyXiang8787 May 13, 2022
70d1d33
down merge
TonyXiang8787 May 14, 2022
d3ec29e
shared y bus struct
TonyXiang8787 May 14, 2022
09fc81a
use existing y bus struct when constructing solver
TonyXiang8787 May 14, 2022
5a075b8
use shared y bus struct in main model
TonyXiang8787 May 14, 2022
08b4c30
begin to add fill-in
TonyXiang8787 May 14, 2022
303ce4a
finish ybus fill-in, to be tested
TonyXiang8787 May 14, 2022
fdc19c5
begin to test y bus
TonyXiang8787 May 16, 2022
71c5742
test y bug
TonyXiang8787 May 16, 2022
9c657ab
build coverage only when needed
TonyXiang8787 May 16, 2022
d5e79a8
check tensor and vector
TonyXiang8787 May 16, 2022
899e214
begin to sparse lu
TonyXiang8787 May 17, 2022
ec447c0
start eigen
TonyXiang8787 May 17, 2022
49d5e8e
start pivot
TonyXiang8787 May 17, 2022
e5a83d0
finish prefactorization
TonyXiang8787 May 17, 2022
95d6c79
add solve
TonyXiang8787 May 17, 2022
08ee7fb
need to resolve accuracy issue
TonyXiang8787 May 17, 2022
4ce2c3e
use lu pivot still not solve the problem
TonyXiang8787 May 17, 2022
d06af67
try linear method
TonyXiang8787 May 17, 2022
89d97a1
use inplace
May 19, 2022
8f21a91
factorize inside pivot, not good yet
TonyXiang8787 May 20, 2022
ffcc442
fix a bug, still not pass
TonyXiang8787 May 20, 2022
6be3272
enforce eval, still not passing
TonyXiang8787 May 20, 2022
59ed610
add test for single scalar
TonyXiang8787 May 20, 2022
de331c2
new dataset
TonyXiang8787 May 20, 2022
e637179
add block test, fails
TonyXiang8787 May 20, 2022
e8b17ec
remove eval
TonyXiang8787 May 20, 2022
b4dc235
permute L and U, not passed yet
TonyXiang8787 May 20, 2022
fd56067
fix iterate column bug,
TonyXiang8787 May 20, 2022
2732be4
bug in test
TonyXiang8787 May 20, 2022
45e7b21
fix bug
TonyXiang8787 May 20, 2022
bf978e1
fix test
TonyXiang8787 May 20, 2022
8457542
reset test data
TonyXiang8787 May 20, 2022
0ce879b
try line
TonyXiang8787 May 21, 2022
15c64b0
Merge branch 'main' into feature/internal-sparse-solver
TonyXiang8787 May 24, 2022
f86c15e
use lower bound to search index
TonyXiang8787 May 24, 2022
6f0da12
improve naming
TonyXiang8787 May 25, 2022
0b81605
add test
TonyXiang8787 May 25, 2022
0e2a745
solve benchmark
TonyXiang8787 May 25, 2022
6ba35ce
test se
TonyXiang8787 May 25, 2022
f3bb93b
remove some mkl
TonyXiang8787 May 25, 2022
fa31e56
remove mkl import
TonyXiang8787 May 25, 2022
2cfe09b
use triangular solve
TonyXiang8787 May 25, 2022
b99317f
use col major
TonyXiang8787 May 27, 2022
465c8b8
begin for block matrix
TonyXiang8787 May 28, 2022
456a3ec
semi finish block
TonyXiang8787 May 28, 2022
b8bd78c
add eigen template
TonyXiang8787 May 28, 2022
3a55cd5
working inheritance
TonyXiang8787 May 28, 2022
f5e11c4
Merge branch 'main' into feature/internal-sparse-solver
TonyXiang8787 May 31, 2022
79a01ea
add jacobian tensor
TonyXiang8787 May 31, 2022
afd6f61
block for newton power flow
TonyXiang8787 May 31, 2022
2968a39
add block for linear power flow
TonyXiang8787 May 31, 2022
c33dfa1
finish all blocks
TonyXiang8787 May 31, 2022
4e9ec36
remove mkl build in ci
TonyXiang8787 May 31, 2022
67df7e4
remove env
TonyXiang8787 May 31, 2022
ad595e7
Merge remote-tracking branch 'origin/feature/simplfy-readme' into fea…
TonyXiang8787 May 31, 2022
290a7e5
documentation, fix compare error
TonyXiang8787 May 31, 2022
90500da
fix macos build
TonyXiang8787 May 31, 2022
a6fa1ea
remove maybe
TonyXiang8787 May 31, 2022
2eb7c3e
disable maybe uninitialize only for gcc
TonyXiang8787 May 31, 2022
74c5049
build mac python
TonyXiang8787 May 31, 2022
46bb97a
begin to clean build guid
TonyXiang8787 Jun 1, 2022
1e219e6
add documentation
TonyXiang8787 Jun 1, 2022
9c74eef
some typo
TonyXiang8787 Jun 1, 2022
0280488
test meshed network, no good
TonyXiang8787 Jun 2, 2022
e2800df
remove transformer clock
TonyXiang8787 Jun 2, 2022
ac2747e
format
TonyXiang8787 Jun 2, 2022
20b5bd6
reoder slow
TonyXiang8787 Jun 2, 2022
c001477
reduce meshed benchmarkt
TonyXiang8787 Jun 3, 2022
f75466b
use private type alias
TonyXiang8787 Jun 3, 2022
6fd9e8d
record output calculation time
TonyXiang8787 Jun 3, 2022
6f82a30
optimize initialization
TonyXiang8787 Jun 8, 2022
83fc13d
solve triangular manually
TonyXiang8787 Jun 8, 2022
e41e44c
Merge branch 'main' into feature/internal-sparse-solver
TonyXiang8787 Jun 14, 2022
fe7d772
[skip ci] start to use solve in place
TonyXiang8787 Jun 14, 2022
a442979
[skip ci] modify y bus
TonyXiang8787 Jun 14, 2022
70cc98c
[skip ci] change power flow
TonyXiang8787 Jun 14, 2022
eb24c03
refactor all calculations
TonyXiang8787 Jun 14, 2022
3036938
Merge remote-tracking branch 'origin/feature/validation-networks' int…
TonyXiang8787 Jun 14, 2022
ccfbca4
fix bug
TonyXiang8787 Jun 14, 2022
1ff601f
use single thread to build windows
TonyXiang8787 Jun 14, 2022
c30b9c5
Merge branch 'main' into feature/internal-sparse-solver
TonyXiang8787 Jun 14, 2022
35758b1
Merge branch 'release/1.4' into feature/internal-sparse-solver
TonyXiang8787 Jun 17, 2022
eba8676
Merge branch 'release/1.4' into feature/internal-sparse-solver
TonyXiang8787 Jun 17, 2022
1ea3a32
use empty array for result
TonyXiang8787 Jun 18, 2022
0a234f8
Merge branch 'release/1.4' into feature/internal-sparse-solver
TonyXiang8787 Jun 20, 2022
5c65f7d
downmerge with iterative current
TonyXiang8787 Jun 24, 2022
3c8a7a8
add some new test cases
TonyXiang8787 Jun 24, 2022
c7bdb3b
ci test
TonyXiang8787 Jun 24, 2022
a8838e2
Merge branch 'release/1.4' into feature/internal-sparse-solver
TonyXiang8787 Jun 24, 2022
d5edf9b
Merge branch 'release/1.4' into feature/internal-sparse-solver
TonyXiang8787 Jun 24, 2022
1aa4a99
Merge branch 'release/1.4' into feature/internal-sparse-solver
TonyXiang8787 Jun 27, 2022
9ff2d3d
typo in comments
petersalemink95 Jul 4, 2022
f1b7cdb
increase readability
petersalemink95 Jul 12, 2022
d6acd4d
revise based on comments
TonyXiang8787 Jul 14, 2022
cf0c276
fix last comments
TonyXiang8787 Jul 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 9 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,19 @@ jobs:
strategy:
matrix:
build-option: [ Debug, Release ]
sparse-solver: [ EIGEN, MKL, MKL_RUNTIME ]

steps:
- uses: actions/checkout@v3

- name: Run build script
run: ./build.sh ${{ matrix.build-option }} ${{ matrix.sparse-solver }}
run: ./build.sh ${{ matrix.build-option }}

build-cpp-test-windows:
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
runs-on: windows-latest
strategy:
matrix:
build-option: [ Debug, Release ]
sparse-solver: [ EIGEN, MKL, MKL_RUNTIME ]
env:
MKL_INCLUDE: C:\conda_envs\cpp_pkgs\Library\include
MKL_LIB: C:\conda_envs\cpp_pkgs\Library\lib

steps:
- uses: actions/checkout@v3
Expand All @@ -57,25 +52,24 @@ jobs:
- name: Install conda environment
# TODO removed pinned v2 of catch2, see https://github.com/alliander-opensource/power-grid-model/issues/73
run: |
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen nlohmann_json mkl mkl-devel mkl-include catch2==2.13.9
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen nlohmann_json catch2==2.13.9

- name: Build and test
run: |
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
$env:Path += ";C:\conda_envs\cpp_pkgs\Library\bin"
mkdir cpp_build_${{ matrix.build-option }}_${{ matrix.sparse-solver }}
cd cpp_build_${{ matrix.build-option }}_${{ matrix.sparse-solver }}
mkdir cpp_build_${{ matrix.build-option }}
cd cpp_build_${{ matrix.build-option }}
# generate cmake cache
cmake .. `
-G "Ninja" `
-DCMAKE_BUILD_TYPE=${{ matrix.build-option }} `
-DPOWER_GRID_MODEL_SPARSE_SOLVER=${{ matrix.sparse-solver }} `
-DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library `
-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1
# build
cmake --build . --verbose
cmake --build . --verbose -j 1
# test
.\tests\cpp_unit_tests\power_grid_model_unit_tests.exe

Expand All @@ -85,12 +79,9 @@ jobs:
strategy:
matrix:
build-option: [ Debug, Release ]
sparse-solver: [ EIGEN, MKL, MKL_RUNTIME ]
env:
CC: clang
CXX: clang++
MKL_INCLUDE: /usr/local/include
MKL_LIB: /usr/local/lib
CMAKE_PREFIX_PATH: /usr/local

steps:
Expand All @@ -101,14 +92,10 @@ jobs:
run: |
brew install ninja boost eigen nlohmann-json
curl https://github.com/raw/Homebrew/homebrew-core/5e5abb11bf49787d01164c4066119365262c21ed/Formula/catch2.rb > $(find $(brew --repository) -name catch2.rb) && brew reinstall catch2
sudo pip3 install mkl mkl-devel mkl-include

- name: Build and test
run: |
# environment
export LD_LIBRARY_PATH=${MKL_LIB}:${LD_LIBRARY_PATH}
# bash
./build.sh ${{ matrix.build-option }} ${{ matrix.sparse-solver }}
./build.sh ${{ matrix.build-option }}

build-and-test-python:
strategy:
Expand All @@ -122,9 +109,6 @@ jobs:
boost:
eigen:
cibw_build: "cp*-manylinux_x86_64 cp*-manylinux_aarch64"
test_cmd: >
pytest {package}/tests &&
LD_LIBRARY_PATH= pytest {package}/tests
archs: "x86_64 aarch64"
- platform: macos
os: macos-latest
Expand All @@ -134,9 +118,6 @@ jobs:
eigen: /usr/local/include/eigen3
cibw_build: cp*-macosx_*
archs: "x86_64 arm64"
test_cmd: >
pytest {package}/tests &&
LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} pytest {package}/tests
- platform: windows
os: windows-latest
cc:
Expand All @@ -145,7 +126,6 @@ jobs:
eigen: C:\conda_envs\cpp_pkgs\Library\include\eigen3
cibw_build: cp*-win_amd64
archs: AMD64
test_cmd: pytest {package}/tests

runs-on: ${{ matrix.os }}
needs: [build-cpp-test-linux, build-cpp-test-windows, build-cpp-test-macos]
Expand All @@ -160,7 +140,7 @@ jobs:
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_TEST_REQUIRES: pytest pytest-cov
CIBW_TEST_COMMAND: ${{ matrix.test_cmd }}
CIBW_TEST_COMMAND: pytest {package}/tests
# Skip trying to test arm64 builds on Intel Macs
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/alliander-opensource/power-grid-model-build-env
Expand All @@ -169,11 +149,10 @@ jobs:
CIBW_BEFORE_ALL_MACOS: >
which clang++ &&
clang++ --version &&
brew install boost eigen &&
sudo pip3 install mkl mkl-devel mkl-include
brew install boost eigen
MACOSX_DEPLOYMENT_TARGET: 10.15
CIBW_BEFORE_ALL_WINDOWS : >
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen mkl
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Run build-wrapper for C++
run: |
mkdir cpp_build
cmake -S . -B cpp_build -GNinja -DCMAKE_BUILD_TYPE=Debug -DPOWER_GRID_MODEL_SPARSE_SOLVER=EIGEN -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
cmake -S . -B cpp_build -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
VERBOSE=1 build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build cpp_build/

- name: C++ test and coverage
Expand Down
40 changes: 6 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,52 +31,23 @@ else()
add_compile_options(-Wall -Wextra -pedantic -Werror)
add_compile_options(-Wno-deprecated-copy) # bug in boost
if(UNIX AND NOT APPLE)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.1)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.2)
# test coverage for debug build in linux
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# test coverage for debug build in linux, if specified
if ((CMAKE_BUILD_TYPE STREQUAL "Debug") AND (DEFINED POWER_GRID_MODEL_COVERAGE) AND (POWER_GRID_MODEL_COVERAGE EQUAL 1))
add_compile_options(-fprofile-arcs -ftest-coverage)
add_link_options(-fprofile-arcs)
endif()
else()
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .1.dylib)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .2.dylib)
endif()
# thread
find_package(Threads REQUIRED)
target_link_libraries(power_grid_model INTERFACE Threads::Threads)
endif()


# sparse solver, default eigen
if (NOT DEFINED POWER_GRID_MODEL_SPARSE_SOLVER)
set(POWER_GRID_MODEL_SPARSE_SOLVER "EIGEN")
endif()

# use mkl solver
if((POWER_GRID_MODEL_SPARSE_SOLVER STREQUAL "MKL") OR (POWER_GRID_MODEL_SPARSE_SOLVER STREQUAL "MKL_RUNTIME"))
# check load mkl at runtime or link-time
if(POWER_GRID_MODEL_SPARSE_SOLVER STREQUAL "MKL_RUNTIME")
target_compile_definitions(power_grid_model INTERFACE POWER_GRID_MODEL_USE_MKL_AT_RUNTIME=1)
target_link_libraries(power_grid_model INTERFACE ${CMAKE_DL_LIBS})
else()
if(NOT DEFINED ENV{MKL_INCLUDE})
message(FATAL_ERROR "MKL include dir not found!")
endif()
if(NOT DEFINED ENV{MKL_LIB})
message(FATAL_ERROR "MKL lib dir not found!")
endif()
# mkl
target_include_directories(power_grid_model INTERFACE $ENV{MKL_INCLUDE})
list(APPEND CMAKE_PREFIX_PATH "$ENV{MKL_LIB}")
find_library(MKL_RT mkl_rt)
message("${MKL_RT}")
target_compile_definitions(power_grid_model INTERFACE POWER_GRID_MODEL_USE_MKL=1)
target_link_libraries(power_grid_model INTERFACE "${MKL_RT}")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
add_compile_options(-Wno-maybe-uninitialized) # bug in boost
endif()


# get tests
add_subdirectory(tests/cpp_unit_tests)

Expand All @@ -85,3 +56,4 @@ if(DEFINED POWER_GRID_MODEL_BUILD_BENCHMARK AND POWER_GRID_MODEL_BUILD_BENCHMARK
add_subdirectory(tests/benchmark_cpp)
endif()


48 changes: 0 additions & 48 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,6 @@
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{
"name": "x64-Debug-MKL",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\cpp_build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1 -DPOWER_GRID_MODEL_SPARSE_SOLVER=MKL",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{
"name": "x64-Release-MKL",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\cpp_build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1 -DPOWER_GRID_MODEL_SPARSE_SOLVER=MKL",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
},
{
"name": "x64-Debug-MKL-at-runtime",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\cpp_build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1 -DPOWER_GRID_MODEL_SPARSE_SOLVER=MKL_RUNTIME",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake",
"inheritEnvironments": [ "msvc_x64_x64" ]
},
{
"name": "x64-Release-MKL-at-runtime",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\cpp_build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1 -DPOWER_GRID_MODEL_SPARSE_SOLVER=MKL_RUNTIME",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake",
"inheritEnvironments": [ "msvc_x64_x64" ]
}
]
}
40 changes: 1 addition & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,8 @@ Currently, it supports the following calculations:

# Installation

## Runtime Dependencies
## Install from PyPI

The only Python runtime dependency is
[numpy](https://numpy.org/). It will be automatically installed as the requirements.
Moreover, the library optionally depends on
[Intel Math Kernel Library (mkl)](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl.html),
for its [PARDISO](https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/sparse-solver-routines/onemkl-pardiso-parallel-direct-sparse-solver-iface.html) sparse solver.
It is recommended to install `mkl` because it gives huge performance boosts.

The easiest way to install `mkl` is using `pip` or `conda`:

```
pip install mkl
```

or

```
conda install -c conda-forge mkl
```

You need to add the path to the `mkl` runtime file `libmkl_rt.so` or `mkl_rt.dll` the environment variable
`LD_LIBRARY_PATH` in Linux or `Path` in Windows (`conda` does this automatically in the environment).
If the library can find `mkl` runtime, it uses it as the sparse solver.
It is recommended to set the environment variable `MKL_THREADING_LAYER` to `SEQUENTIAL`,
as multi-threading is handled in a higher level.
If the library cannot find `mkl` runtime, it will fall back to an internally built-in (and much slower)
[Eigen SparseLU](https://eigen.tuxfamily.org/dox/classEigen_1_1SparseLU.html) solver.

## Install from Pre-built Binary Package

The `power-grid-model` python package is pre-built for Windows, Linux, and macOS (both Intel and Arm-based),
for Python version 3.8, 3.9, and 3.10.
You can directly install the package from PyPI.

```
Expand Down Expand Up @@ -208,13 +177,6 @@ which are licensed under their own respective Open-Source licenses.
SPDX-License-Identifier headers are used to show which license is applicable.
The concerning license files can be found in the LICENSES directory.

## Intel Math Kernel Library License

The `power-grid-model` does not bundle or redistribute any MKL runtime library.
It only detects if MKL library is installed in the target system.
If so, it will use the library to accelerate the calculation.
The user is responsible to acquire a suitable MKL license.

# Contributing
Please read [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) and [CONTRIBUTING](CONTRIBUTING.md) for details on the process
for submitting pull requests to us.
Expand Down
28 changes: 10 additions & 18 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -e

usage() {
echo "$0 {Debug/Release} {EIGEN,MKL,MKL_RUNTIME}"
echo "$0 {Debug/Release}"
}

if [ ! "$1" = "Debug" ] && [ ! "$1" = "Release" ]; then
Expand All @@ -16,13 +16,13 @@ if [ ! "$1" = "Debug" ] && [ ! "$1" = "Release" ]; then
exit 1;
fi

if [ ! "$2" = "EIGEN" ] && [ ! "$2" = "MKL" ] && [ ! "$2" = "MKL_RUNTIME" ]; then
echo "Missing second argument"
usage
exit 1;
if [[ $2 == "Coverage" ]]; then
BUILD_COVERAGE=-DPOWER_GRID_MODEL_COVERAGE=1
else
BUILD_COVERAGE=
fi

BUILD_DIR=cpp_build_$1_$2
BUILD_DIR=cpp_build_$1
echo "Build dir: ${BUILD_DIR}"

if [[ ! -z "${VCPKG_ROOT}" ]]; then
Expand All @@ -41,27 +41,19 @@ cd ${BUILD_DIR}
# generate
cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=$1 \
-DPOWER_GRID_MODEL_SPARSE_SOLVER=$2 \
${PATH_FOR_CMAKE} \
-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1
-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1 \
${BUILD_COVERAGE}
# build
VERBOSE=1 cmake --build .
# test
./tests/cpp_unit_tests/power_grid_model_unit_tests

if [[ $2 == "MKL_RUNTIME" ]]; then
LD_LIBRARY_PATH= ./tests/cpp_unit_tests/power_grid_model_unit_tests
LD_LIBRARY_PATH= POWER_GRID_MODEL_SPARSE_SOLVER=MKL ./tests/cpp_unit_tests/power_grid_model_unit_tests
LD_LIBRARY_PATH=${MKL_LIB} ./tests/cpp_unit_tests/power_grid_model_unit_tests
LD_LIBRARY_PATH=${MKL_LIB} POWER_GRID_MODEL_SPARSE_SOLVER=MKL ./tests/cpp_unit_tests/power_grid_model_unit_tests
POWER_GRID_MODEL_SPARSE_SOLVER=EIGEN ./tests/cpp_unit_tests/power_grid_model_unit_tests
else
LD_LIBRARY_PATH=${MKL_LIB} ./tests/cpp_unit_tests/power_grid_model_unit_tests
fi


cd ..
# test coverage report for debug build and for linux
if [[ "$1" = "Debug" ]] && [[ $3 == "Coverage" ]]; then
if [[ "$1" = "Debug" ]] && [[ $2 == "Coverage" ]]; then
echo "Generating coverage report..."
if [[ ${CXX} == "clang++"* ]]; then
GCOV_TOOL="--gcov-tool llvm-gcov.sh"
Expand Down
Loading