Skip to content

Commit

Permalink
Upgrade SUNDIALS to 7.1.1 (#2513)
Browse files Browse the repository at this point in the history
We've been lagging behind SUNDIALS development. This updates the SUNDIALS library from v5.8.0 to [v7.1.1](https://sundials.readthedocs.io/en/latest/Changelog_link.html#changes-to-sundials-in-release-7-1-1).

Note:
* This includes the post-7.1.1 changes to `cmake/tpl/FindKLU.cmake` from LLNL/sundials#582
* This includes the post-7.1.1 changes to [`sundials/src/sunmatrix/sparse/sunmatrix_sparse.c:SUNMatScaleAddI_Sparse`](https://github.com/LLNL/sundials/blob/736369d543cb80956b1ba87377ffc0c8cf6b342b/src/sunmatrix/sparse/sunmatrix_sparse.c#L625C1-L694C2) from  LLNL/sundials#584, fixing LLNL/sundials#581

The majority of changes inside amici are related to the introduction of [SUNContext](https://sundials.readthedocs.io/en/latest/sundials/SUNContext_link.html#the-suncontext-type), which is required for the construction of all SUNDIALS objects. Other trivial changes are related to renamed types and macros.

Furthermore, the error handling strategy has changed. As a consequence, simulation error messages will look slightly different.

Closes #1565
  • Loading branch information
dweindl authored Oct 7, 2024
1 parent e89a1de commit cd56633
Show file tree
Hide file tree
Showing 278 changed files with 43,026 additions and 30,627 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ target_compile_definitions(

target_link_libraries(
${PROJECT_NAME}
PUBLIC SUNDIALS::generic_static
SUNDIALS::nvecserial_static
PUBLIC SUNDIALS::nvecserial_static
SUNDIALS::sunmatrixband_static
SUNDIALS::sunmatrixdense_static
SUNDIALS::sunmatrixsparse_static
Expand Down
119 changes: 119 additions & 0 deletions ThirdParty/sundials/CITATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Citing SUNDIALS

We ask users of SUNDIALS to cite the following papers in any publications
reporting work done with SUNDIALS:

```bibtex
@article{gardner2022sundials,
title = {Enabling new flexibility in the {SUNDIALS} suite of nonlinear and differential/algebraic equation solvers},
author = {Gardner, David J and Reynolds, Daniel R and Woodward, Carol S and Balos, Cody J},
journal = {ACM Transactions on Mathematical Software (TOMS)},
publisher = {ACM},
volume = {48},
number = {3},
pages = {1--24},
year = {2022},
doi = {10.1145/3539801}
}
```

```bibtex
@article{hindmarsh2005sundials,
title = {{SUNDIALS}: Suite of nonlinear and differential/algebraic equation solvers},
author = {Hindmarsh, Alan C and Brown, Peter N and Grant, Keith E and Lee, Steven L and Serban, Radu and Shumaker, Dan E and Woodward, Carol S},
journal = {ACM Transactions on Mathematical Software (TOMS)},
publisher = {ACM},
volume = {31},
number = {3},
pages = {363--396},
year = {2005},
doi = {10.1145/1089014.1089020}
}
```

If any GPU features of SUNDIALS were utilized, please also cite:

```bibtex
@article{balos2021enabling,
title = {{Enabling GPU accelerated computing in the SUNDIALS time integration library}},
author = {Balos, Cody J and Gardner, David J and Woodward, Carol S and Reynolds, Daniel R},
journal = {Parallel Computing},
publisher = {Elsevier},
volume = {108},
pages = {102836},
year = {2021},
doi = {10.1016/j.parco.2021.102836}
}
```

When using the ARKODE package from SUNDIALS, please also cite:

```bibtex
@article{reynolds2023arkode,
title = {{ARKODE: A flexible IVP solver infrastructure for one-step methods}},
author = {Reynolds, Daniel R and Gardner, David J and Woodward, Carol S and Chinomona, Rujeko},
journal = {ACM Transactions on Mathematical Software},
volume = {49},
number = {2},
pages = {1--26},
year = {2023},
doi = {10.1145/3594632}
}
```

We also ask that users cite the documentation for the package and version that
they are using rather than the combined SUNDIALS online guide:

```bibtex
@Misc{arkodeDocumentation,
author = {Daniel R. Reynolds and David J. Gardner and Carol S. Woodward and Cody J. Balos},
title = {User Documentation for ARKODE},
year = {2024},
note = {v6.1.1}
}
```

```bibtex
@Misc{cvodeDocumentation,
author = {Alan C. Hindmarsh and Radu Serban and Cody J. Balos and David J. Gardner and Daniel R. Reynolds and Carol S. Woodward},
title = {User Documentation for CVODE},
year = {2024},
note = {v7.1.1}
}
```

```bibtex
@Misc{cvodesDocumentation,
author = {Alan C. Hindmarsh and Radu Serban and Cody J. Balos and David J. Gardner and Daniel R. Reynolds and Carol S. Woodward},
title = {User Documentation for CVODES},
year = {2024},
note = {v7.1.1}
}
```

```bibtex
@Misc{idaDocumentation,
author = {Alan C. Hindmarsh and Radu Serban and Cody J. Balos and David J. Gardner and Daniel R. Reynolds and Carol S. Woodward},
title = {User Documentation for IDA},
year = {2024},
note = {v7.1.1}
}
```

```bibtex
@Misc{idasDocumentation,
author = {Radu Serban and Cosmin Petra and Alan C. Hindmarsh and Cody J. Balos and David J. Gardner and Daniel R. Reynolds and Carol S. Woodward},
title = {User Documentation for IDAS},
year = {2024},
note = {v6.1.1}
}
```

```bibtex
@Misc{kinsolDocumentation,
author = {Alan C. Hindmarsh and Radu Serban and Cody J. Balos and David J. Gardner and Daniel R. Reynolds and Carol S. Woodward},
title = {User Documentation for KINSOL},
year = {2024},
note = {v7.1.1}
}
```
108 changes: 71 additions & 37 deletions ThirdParty/sundials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# and Slaven Peles @ LLNL
# ---------------------------------------------------------------
# SUNDIALS Copyright Start
# Copyright (c) 2002-2021, Lawrence Livermore National Security
# Copyright (c) 2002-2024, Lawrence Livermore National Security
# and Southern Methodist University.
# All rights reserved.
#
Expand All @@ -19,38 +19,46 @@
# Initial setup.
# ===============================================================

cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.18)

# Address DOWNLOAD_EXTRACT_TIMESTAMP warning with CMake 3.24+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
cmake_policy(SET CMP0135 NEW)
endif()

# Project SUNDIALS (initially only C supported)
# sets PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR variables.
project(SUNDIALS C)

# Specify the location of additional CMAKE modules
set(CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake"
"${PROJECT_SOURCE_DIR}/cmake/macros"
"${PROJECT_SOURCE_DIR}/cmake/tpl"
${CMAKE_MODULE_PATH}
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_SOURCE_DIR}/cmake/macros
${PROJECT_SOURCE_DIR}/cmake/tpl
)

# MACRO definitions
include(SundialsCMakeMacros)
include(FindPackageHandleStandardArgs)
include(CMakePrintHelpers)
include(CheckCSourceCompiles)
include(FindPackageHandleStandardArgs)


# Set some variables with info on the SUNDIALS project
set(PACKAGE_BUGREPORT "[email protected]")
set(PACKAGE_NAME "SUNDIALS")
set(PACKAGE_STRING "SUNDIALS 5.8.0")
set(PACKAGE_STRING "SUNDIALS 7.1.1")
set(PACKAGE_TARNAME "sundials")

# Set SUNDIALS version numbers
sundials_git_version() # sets SUNDIALS_GIT_VERSION
message(STATUS "SUNDIALS_GIT_VERSION: ${SUNDIALS_GIT_VERSION}")

# (use "" for the version label if none is needed)
set(PACKAGE_VERSION_MAJOR "5")
set(PACKAGE_VERSION_MINOR "8")
set(PACKAGE_VERSION_PATCH "0")
set(PACKAGE_VERSION_MAJOR "7")
set(PACKAGE_VERSION_MINOR "1")
set(PACKAGE_VERSION_PATCH "1")
set(PACKAGE_VERSION_LABEL "")

if(PACKAGE_VERSION_LABEL)
Expand All @@ -65,38 +73,38 @@ endif()

# Specify the VERSION and SOVERSION for shared libraries

set(arkodelib_VERSION "4.8.0")
set(arkodelib_SOVERSION "4")
set(arkodelib_VERSION "6.1.1")
set(arkodelib_SOVERSION "6")

set(cvodelib_VERSION "5.8.0")
set(cvodelib_SOVERSION "5")
set(cvodelib_VERSION "7.1.1")
set(cvodelib_SOVERSION "7")

set(cvodeslib_VERSION "5.8.0")
set(cvodeslib_SOVERSION "5")
set(cvodeslib_VERSION "7.1.1")
set(cvodeslib_SOVERSION "7")

set(idalib_VERSION "5.8.0")
set(idalib_SOVERSION "5")
set(idalib_VERSION "7.1.1")
set(idalib_SOVERSION "7")

set(idaslib_VERSION "4.8.0")
set(idaslib_SOVERSION "4")
set(idaslib_VERSION "6.1.1")
set(idaslib_SOVERSION "6")

set(kinsollib_VERSION "5.8.0")
set(kinsollib_SOVERSION "5")
set(kinsollib_VERSION "7.1.1")
set(kinsollib_SOVERSION "7")

set(cpodeslib_VERSION "0.0.0")
set(cpodeslib_SOVERSION "0")

set(nveclib_VERSION "5.8.0")
set(nveclib_SOVERSION "5")
set(nveclib_VERSION "7.1.1")
set(nveclib_SOVERSION "7")

set(sunmatrixlib_VERSION "3.8.0")
set(sunmatrixlib_SOVERSION "3")
set(sunmatrixlib_VERSION "5.1.1")
set(sunmatrixlib_SOVERSION "5")

set(sunlinsollib_VERSION "3.8.0")
set(sunlinsollib_SOVERSION "3")
set(sunlinsollib_VERSION "5.1.1")
set(sunlinsollib_SOVERSION "5")

set(sunnonlinsollib_VERSION "2.8.0")
set(sunnonlinsollib_SOVERSION "2")
set(sunnonlinsollib_VERSION "4.1.1")
set(sunnonlinsollib_SOVERSION "4")

set(sundialslib_VERSION
"${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}"
Expand All @@ -109,7 +117,7 @@ set(sundialslib_SOVERSION "${PACKAGE_VERSION_MAJOR}")

# Prohibit in-source build
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
print_error("In-source build prohibited.")
message(FATAL_ERROR "In-source build prohibited.")
endif()

# Organize targets into folders when using an IDE
Expand All @@ -136,6 +144,16 @@ set(_SHARED_LIB_SUFFIX
set(_SUNDIALS_ALIAS_TARGETS ""
CACHE INTERNAL "" FORCE)

# We default to release builds
set(_DEFAULT_CMAKE_BUILD_TYPE RelWithDebInfo)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Building SUNDIALS in '${_DEFAULT_CMAKE_BUILD_TYPE}' mode as CMAKE_BUILD_TYPE was not specified.")
set(CMAKE_BUILD_TYPE "${_DEFAULT_CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
else()
message(STATUS "Building SUNDIALS in '${CMAKE_BUILD_TYPE}' mode.")
endif()

# ===============================================================
# Build options to be processed first
# ===============================================================
Expand Down Expand Up @@ -193,6 +211,20 @@ if(_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# Add benchmarks to the build
if(BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()

# Add unit tests to the build if they are enabled
if(SUNDIALS_TEST_UNITTESTS)
add_subdirectory(test/unit_tests)
endif()

if(SUNDIALS_ENABLE_EXTERNAL_ADDONS)
add_subdirectory(external)
endif()

# ===============================================================
# Install configuration header files and license file.
# ===============================================================
Expand All @@ -207,11 +239,6 @@ install(FILES "${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials"
)

# install configured header file for Fortran 90
install(FILES "${PROJECT_BINARY_DIR}/include/sundials/sundials_fconfig.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials"
)

# install shared Fortran 2003 modules
if(BUILD_FORTRAN_MODULE_INTERFACE)
# While the .mod files get generated for static and shared
Expand Down Expand Up @@ -241,7 +268,7 @@ include(CMakePackageConfigHelpers)
write_basic_package_version_file(
SUNDIALSConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
COMPATIBILITY AnyNewerVersion
)

# install targets
Expand All @@ -262,3 +289,10 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfigVersion.cmake"
DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}"
)

# Export targets so build directory can be used directly
export(
EXPORT sundials-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSTargets.cmake"
NAMESPACE SUNDIALS::
)
Loading

0 comments on commit cd56633

Please sign in to comment.