Skip to content

Update suitesparse and sundials for windows #40

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

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b30646c
Switch version
kratman Apr 29, 2025
764ccfc
Fix include path
kratman Apr 29, 2025
887169b
Update build scripts
kratman Apr 29, 2025
dd253d9
Get rid of excess script
kratman Apr 29, 2025
e0dd25a
Minor patch
kratman Apr 29, 2025
69b1ce1
Revert change
kratman Apr 29, 2025
f061544
Apply suggestions from code review
kratman Apr 29, 2025
4b3f8d8
Update .github/workflows/build_wheels.yml
kratman Apr 29, 2025
b5b13ae
Put script changes back
kratman Apr 29, 2025
34bc3ef
Re-trigger ci
kratman Apr 29, 2025
1eed1fe
Update sundials
kratman Apr 30, 2025
4946555
Type fixes
kratman Apr 30, 2025
26e33fc
Revert some type changes
kratman Apr 30, 2025
3f24e5e
Switch vcpkg hash
kratman May 1, 2025
b72b52c
Delete CI to speed up testing
kratman May 1, 2025
4076299
Fix baseline
kratman May 1, 2025
35bd50d
Switch to default casadi
kratman May 1, 2025
34eb1d9
Fix license
kratman May 1, 2025
c6bf467
Attempt to use config mode
kratman May 1, 2025
78791aa
Fix project file
kratman May 1, 2025
5acb3fe
CMake experiment
kratman May 1, 2025
d45a8e3
Use sundials logic for for KLU
kratman May 2, 2025
4a10e2a
More KLU BS
kratman May 2, 2025
c85710b
Trying another include method
kratman May 2, 2025
82e3ed9
Try the basic find method
kratman May 2, 2025
43a24aa
Try again
kratman May 2, 2025
686a3b5
re-trigger
kratman May 2, 2025
8cb6052
Debug
kratman May 4, 2025
1714ba8
Reduce build time
kratman May 5, 2025
e980181
Put find package back
kratman May 5, 2025
3c45555
Put find package back
kratman May 5, 2025
384fdc4
Merge branch 'main' of github.com:pybamm-team/pybammsolvers into feat…
kratman May 6, 2025
9a7fda6
Put files back
kratman May 6, 2025
1195321
Merge branch 'main' into feat/windowsSundials
kratman May 15, 2025
fe6b428
Pull in other changes
kratman May 15, 2025
c6e2019
Merge branch 'main' of https://github.com/pybamm-team/pybammsolvers i…
kratman Jun 17, 2025
33c8689
Autoformat
kratman Jun 17, 2025
500a328
Merge branch 'main' of github.com:pybamm-team/pybammsolvers into feat…
kratman Jun 17, 2025
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
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,28 @@ endif ()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
# Sundials
find_package(SUNDIALS REQUIRED)
message("SUNDIALS found in ${SUNDIALS_INCLUDE_DIR}: ${SUNDIALS_LIBRARIES}")
if (DEFINED VCPKG_ROOT_DIR)
find_package(SUNDIALS CONFIG REQUIRED)
else ()
find_package(SUNDIALS REQUIRED)
message("SUNDIALS found in ${SUNDIALS_INCLUDE_DIR}: ${SUNDIALS_LIBRARIES}")
endif ()
target_include_directories(idaklu PRIVATE ${SUNDIALS_INCLUDE_DIR})
target_link_libraries(idaklu PRIVATE ${SUNDIALS_LIBRARIES} casadi)

# link suitesparse
# if using vcpkg, use config mode to
# find suitesparse. Otherwise, use FindSuiteSparse module
if (DEFINED VCPKG_ROOT_DIR)
find_package(SuiteSparse CONFIG REQUIRED)
find_package(KLU REQUIRED)
include_directories(${KLU_INCLUDE_DIRS})
target_link_libraries(idaklu PRIVATE ${KLU_LIBRARIES})
else ()
find_package(SuiteSparse REQUIRED)
message("SuiteSparse found in ${SuiteSparse_INCLUDE_DIRS}: ${SuiteSparse_LIBRARIES}")
include_directories(${SuiteSparse_INCLUDE_DIRS})
target_link_libraries(idaklu PRIVATE ${SuiteSparse_LIBRARIES})
endif ()
include_directories(${SuiteSparse_INCLUDE_DIRS})
target_link_libraries(idaklu PRIVATE ${SuiteSparse_LIBRARIES})

# IREE (MLIR compiler and runtime library) build settings
if (${PYBAMM_IDAKLU_EXPR_IREE} STREQUAL "ON")
Expand Down
4 changes: 2 additions & 2 deletions FindSuiteSparse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

find_package(BLAS QUIET)

# look for desired componenents
# look for desired components
set(SUITESPARSE_COMPONENTS ${SuiteSparse_FIND_COMPONENTS})

# resolve inter-component dependencies
Expand Down Expand Up @@ -217,7 +217,7 @@ if(SuiteSparse_FOUND)
set(SuiteSparse_INCLUDE_DIRS ${SUITESPARSE_INCLUDE_DIR})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining location of SuiteSparse succeded:\n"
"Determining location of SuiteSparse succeeded:\n"
"Include directory: ${SuiteSparse_INCLUDE_DIRS}\n"
"Library directory: ${SuiteSparse_LIBRARIES}\n\n")
set(SuiteSparse_COMPILER_FLAGS)
Expand Down
13 changes: 6 additions & 7 deletions install_KLU_Sundials.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def install_sundials():
"-DCMAKE_INSTALL_NAME_DIR=" + KLU_LIBRARY_DIR,
]

# try to find OpenMP on mac
# try to find OpenMP on Mac
if platform.system() == "Darwin":
# flags to find OpenMP on mac
# flags to find OpenMP on Mac
if platform.processor() == "arm":
OpenMP_C_FLAGS = (
"-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include"
Expand Down Expand Up @@ -118,14 +118,9 @@ def install_sundials():

build_dir = pathlib.Path("build_sundials")
if not os.path.exists(build_dir):
print("\n-" * 10, "Creating build dir", "-" * 40)
os.makedirs(build_dir)

sundials_src = "../sundials"
print("-" * 10, "Running CMake prepare", "-" * 40)
subprocess.run(["cmake", sundials_src, *cmake_args], cwd=build_dir, check=True)

print("-" * 10, "Building SUNDIALS", "-" * 40)
make_cmd = ["make", f"-j{cpu_count()}", "install"]
subprocess.run(make_cmd, cwd=build_dir, check=True)

Expand All @@ -147,6 +142,10 @@ def check_libraries_installed():
sundials_files = [file + ".so" for file in sundials_files]
elif platform.system() == "Darwin":
sundials_files = [file + ".dylib" for file in sundials_files]
else:
raise NotImplementedError(
f"Unsupported operating system: {platform.system()}. This script currently supports only Linux and macOS."
)
sundials_lib_found = True
# Check for SUNDIALS libraries in each directory
for lib_file in sundials_files:
Expand Down
11 changes: 2 additions & 9 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@
{
"kind": "git",
"repository": "https://github.com/pybamm-team/sundials-vcpkg-registry.git",
"baseline": "13d432fcf5da8591bb6cb2d46be9d6acf39cd02b",
"reference": "13d432fcf5da8591bb6cb2d46be9d6acf39cd02b",
"baseline": "d8a1a872520d414f588c78ac34373e3b4fc91fbd",
"reference": "d8a1a872520d414f588c78ac34373e3b4fc91fbd",
"packages": ["sundials"]
},
{
"kind": "git",
"repository": "https://github.com/pybamm-team/casadi-vcpkg-registry.git",
"baseline": "e4b797736790af90de505e0296b07e87719cb1a6",
"reference": "e4b797736790af90de505e0296b07e87719cb1a6",
"packages": ["casadi"]
}
]
}
10 changes: 9 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
"name": "pybammsolvers",
"version-string": "0.1.0",
"dependencies": [
"casadi",
{
"name": "casadi"
},
{
"name": "sundials",
"default-features": false,
"features": ["klu"]
}
],
"overrides": [
{
"name": "casadi",
"version": "3.6.7"
}
]
}
Loading