Skip to content
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

Include SUNDIALS 3.2.1 in ThirdParty/ subdir #79

Merged
merged 2 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions BUILD-LINUX.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Build HDF5 yourself:
* Execute `ctest -S HDF5config.cmake,BUILD_GENERATOR=Unix,INSTALLDIR="<ROOT>/Libs/hdf5" -C Release -V`
* Extract the created `HDF5-1.10.0-patch1-Linux.tar.gz` file to `<ROOT>/Libs/hdf5` such that you have `<ROOT>/Libs/hdf5/lib`

## SUNDIALS
## SUNDIALS (Optional)

* Download SUNDIALS source from http://computation.llnl.gov/projects/sundials/sundials-software (version <= 3.2.1)
* Unzip
Expand All @@ -55,7 +55,7 @@ You can either use a LAPACK implementation provided by your distribution or inst
Obtain LAPACK from your distribution:
* Install the packages (LAPACK and BLAS) of your distribution (e.g., `liblapack3`, `liblapack-dev`, `libblas3`, `libblas-dev` for Ubuntu and Debian). Note that some packages only provide reference (i.e., slow) implementations and others (e.g., ATLAS, GOTO) perform much faster.

## SuperLU
## SuperLU (Optional)

* Download SuperLU source from https://github.com/xiaoyeli/superlu
* Unzip
Expand All @@ -65,7 +65,7 @@ Obtain LAPACK from your distribution:
* Execute `make install`
* Delete the folder `superlubuild` (e.g., execute `rm -rf superlubuild` in the parent directory of `superlubuild`)

## UMFPACK
## UMFPACK (Optional)

* Download SuiteSparse source from http://faculty.cse.tamu.edu/davis/suitesparse.html
* Unzip
Expand All @@ -78,9 +78,9 @@ Obtain LAPACK from your distribution:
* Place the source in `<ROOT>/code` and create the directory `<ROOT>/build`
* Open a terminal and change to `<ROOT>/build`
* If you have built HDF5 yourself, execute `export HDF5_ROOT=<ROOT>/Libs/hdf5`
* Execute `export SUNDIALS_ROOT=<ROOT>/Libs/sundials`
* Execute `export SUPERLU_ROOT=<ROOT>/Libs/superlu`
* Execute `export UMFPACK_ROOT=<ROOT>/Libs/suitesparse`
* If you have built SUNDIALS, execute `export SUNDIALS_ROOT=<ROOT>/Libs/sundials` and add `-DENABLE_PACKAGED_SUNDIALS=OFF` to the CMake command (see below)
* If you have built SuperLU, execute `export SUPERLU_ROOT=<ROOT>/Libs/superlu`
* If you have built UMFPACK, execute `export UMFPACK_ROOT=<ROOT>/Libs/suitesparse`
* If using MKL, execute `export MKLROOT=/opt/intel/mkl`
* Using standard LAPACK: Execute `cmake -DCMAKE_INSTALL_PREFIX="<ROOT>/cadet" ../code/`

Expand Down
12 changes: 6 additions & 6 deletions BUILD-OSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Build HDF5 yourself:
* Execute `ctest -S HDF5config.cmake,BUILD_GENERATOR=Unix,INSTALLDIR="<ROOT>/Libs/hdf5" -C Release -V`
* Extract the created `HDF5-1.10.0-patch1-Darwin.tar.gz` file to `<ROOT>/Libs/hdf5` such that you have `<ROOT>/Libs/hdf5/lib`

## SUNDIALS
## SUNDIALS (Optional)

You can either build SUNDIALS yourself or rely on the `sundials` package of [Homebrew](http://brew.sh/).
Note that a version <= 3.2.1 is required whereas the current version provided by Homebrew is >= 5.1.0.
Expand All @@ -62,7 +62,7 @@ Build SUNDIALS yourself:

You can either use the native LAPACK implementation provided by Mac OS X (vecLib, Accelerate) or install the freely available [Intel MKL](https://software.intel.com/sites/campaigns/nest/) which is very fast and probably faster than Accelerate.

## SuperLU
## SuperLU (Optional)

* Download SuperLU source from https://github.com/xiaoyeli/superlu
* Unzip
Expand All @@ -72,7 +72,7 @@ You can either use the native LAPACK implementation provided by Mac OS X (vecLib
* Execute `make install`
* Delete the folder `superlubuild` (e.g., execute `rm -rf superlubuild` in the parent directory of `superlubuild`)

## UMFPACK
## UMFPACK (Optional)

* Download SuiteSparse source from http://faculty.cse.tamu.edu/davis/suitesparse.html
* Unzip
Expand All @@ -85,9 +85,9 @@ You can either use the native LAPACK implementation provided by Mac OS X (vecLib
* Place the source in `<ROOT>/code` and create the directory `<ROOT>/build`
* Open a terminal and change to `<ROOT>/build`
* If you have built HDF5 yourself, execute `export HDF5_ROOT=<ROOT>/Libs/hdf5`
* If you have built SUNDIALS yourself, execute `export SUNDIALS_ROOT=<ROOT>/Libs/sundials`
* Execute `export SUPERLU_ROOT=<ROOT>/Libs/superlu`
* Execute `export UMFPACK_ROOT=<ROOT>/Libs/suitesparse`
* If you have built SUNDIALS yourself, execute `export SUNDIALS_ROOT=<ROOT>/Libs/sundials` and add `-DENABLE_PACKAGED_SUNDIALS=OFF` to the CMake command (see below)
* If you have built SuperLU, execute `export SUPERLU_ROOT=<ROOT>/Libs/superlu`
* If you have built UMFPACK, execute `export UMFPACK_ROOT=<ROOT>/Libs/suitesparse`
* If using MKL, execute `export MKLROOT=/opt/intel/mkl`
* Using standard LAPACK: Execute `cmake -DCMAKE_INSTALL_PREFIX="<ROOT>/cadet" ../code/`

Expand Down
8 changes: 4 additions & 4 deletions BUILD-WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ We also assume that Intel MKL is installed.
* Execute `ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201964,INSTALLDIR="<ROOT>\Libs\hdf5" -C Release -V`
* Extract the created `HDF5-1.12.0-win64.zip` file to `<ROOT>/Libs/hdf5` such that you have `<ROOT>/Libs/hdf5/lib`

## SUNDIALS
## SUNDIALS (Optional)

* Download SUNDIALS source from http://computation.llnl.gov/projects/sundials/sundials-software (version <= 3.2.1)
* Unzip
Expand Down Expand Up @@ -65,7 +65,7 @@ If MKL is used, skip this step.
* Download a release from https://github.com/oneapi-src/oneTBB/releases
* Unzip to `<ROOT>/Libs/tbb` such that you have `<ROOT>/Libs/tbb/README`

## SuiteSparse
## UMFPACK (Optional)

* Download SuiteSparse source from http://faculty.cse.tamu.edu/davis/suitesparse.html
* Download CMake build system source from https://github.com/jlblancoc/suitesparse-metis-for-windows
Expand All @@ -85,8 +85,8 @@ If MKL is used, skip this step.
* Download release of CADET or checkout from git
* Place the source in `<ROOT>\code` and create the directory `<ROOT>\build`
* Open VS2019x64 Command Prompt and change to `<ROOT>\build`
* Execute `set SUNDIALS_ROOT=<ROOT>\Libs\sundials`
* Execute `set UMFPACK_ROOT=<ROOT>\Libs\suitesparse`
* If you have built SUNDIALS, execute `set SUNDIALS_ROOT=<ROOT>\Libs\sundials` and add `-DENABLE_PACKAGED_SUNDIALS=OFF` to the CMake command (see below)
* If you have built UMFPACK, execute `set UMFPACK_ROOT=<ROOT>\Libs\suitesparse`
* Execute `set TBB_ROOT=<ROOT>\Libs\tbb`
* Execute `set HDF5_ROOT=<ROOT>\Libs\hdf5`
* If using MKL, execute `set MKLROOT=C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020.0.166\windows\mkl`
Expand Down
92 changes: 58 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ add_feature_info(ENABLE_SUNDIALS_OPENMP ENABLE_SUNDIALS_OPENMP "Prefer OpenMP ve
option(ENABLE_ANALYTIC_JACOBIAN_CHECK "Enable verification of analytical Jacobian by AD" OFF)
add_feature_info(ENABLE_ANALYTIC_JACOBIAN_CHECK ENABLE_ANALYTIC_JACOBIAN_CHECK "Enable verification of analytical Jacobian by AD")

set (ADLIB "sfad" CACHE STRING "Selects the AD library, options are 'sfad', 'setfad'")
set(ADLIB "sfad" CACHE STRING "Selects the AD library, options are 'sfad', 'setfad'")
string(TOLOWER ${ADLIB} ADLIB)


Expand All @@ -127,6 +127,8 @@ add_feature_info(ENABLE_CADET_TOOLS ENABLE_CADET_TOOLS "Build CADET tools")
option(ENABLE_TESTS "Build CADET tests" ON)
add_feature_info(ENABLE_TESTS ENABLE_TESTS "Build CADET tests")

option(ENABLE_PACKAGED_SUNDIALS "Use packaged SUNDIALS code" ON)
add_feature_info(ENABLE_PACKAGED_SUNDIALS ENABLE_TESTS "Use packaged SUNDIALS code")

option(ENABLE_IPO "Enable interprocedural optimization if compiler supports it" ON)
add_feature_info(ENABLE_IPO ENABLE_IPO "Enable interprocedural optimization if compiler supports it")
Expand Down Expand Up @@ -228,40 +230,56 @@ set_package_properties(LAPACK PROPERTIES
PURPOSE "Solution of dense linear systems"
)

# SUNDIALS_ROOT environment variable can be used to find SUNDIALS package
set(SUNDIALS_PREFER_STATIC_LIBRARIES ${ENABLE_STATIC_LINK_DEPS})
find_package(SUNDIALS REQUIRED COMPONENTS sundials_idas sundials_nvecserial OPTIONAL_COMPONENTS sundials_nvecopenmp)
set_package_properties(SUNDIALS PROPERTIES
TYPE REQUIRED
PURPOSE "Time integration"
)
if (NOT ENABLE_PACKAGED_SUNDIALS)
# SUNDIALS_ROOT environment variable can be used to find SUNDIALS package
set(SUNDIALS_PREFER_STATIC_LIBRARIES ${ENABLE_STATIC_LINK_DEPS})
find_package(SUNDIALS REQUIRED COMPONENTS sundials_idas sundials_nvecserial OPTIONAL_COMPONENTS sundials_nvecopenmp)
set_package_properties(SUNDIALS PROPERTIES
TYPE REQUIRED
PURPOSE "Time integration"
)

# Check whether OpenMP is available in SUNDIAL'S NVECTOR module
set(SUNDIALS_NVEC_TARGET "SUNDIALS::sundials_nvecserial")
if (SUNDIALS_sundials_nvecopenmp_LIBRARY AND ENABLE_SUNDIALS_OPENMP)
# Prefer OpenMP over serial version
set(SUNDIALS_NVEC_TARGET "SUNDIALS::sundials_nvecopenmp")
# Check whether OpenMP is available in SUNDIAL'S NVECTOR module
set(SUNDIALS_NVEC_TARGET "SUNDIALS::sundials_nvecserial")
if (SUNDIALS_sundials_nvecopenmp_LIBRARY AND ENABLE_SUNDIALS_OPENMP)
# Prefer OpenMP over serial version
set(SUNDIALS_NVEC_TARGET "SUNDIALS::sundials_nvecopenmp")

get_target_property(SUNDIALS_IFACE_COMP_DEF SUNDIALS::sundials_nvecopenmp INTERFACE_COMPILE_DEFINITIONS)
if (SUNDIALS_IFACE_COMP_DEF)
list(APPEND SUNDIALS_IFACE_COMP_DEF "CADET_SUNDIALS_OPENMP")
else()
set(SUNDIALS_IFACE_COMP_DEF "CADET_SUNDIALS_OPENMP")
get_target_property(SUNDIALS_IFACE_COMP_DEF SUNDIALS::sundials_nvecopenmp INTERFACE_COMPILE_DEFINITIONS)
if (SUNDIALS_IFACE_COMP_DEF)
list(APPEND SUNDIALS_IFACE_COMP_DEF "CADET_SUNDIALS_OPENMP")
else()
set(SUNDIALS_IFACE_COMP_DEF "CADET_SUNDIALS_OPENMP")
endif()
set_target_properties(SUNDIALS::sundials_nvecopenmp PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${SUNDIALS_IFACE_COMP_DEF}")
unset(SUNDIALS_IFACE_COMP_DEF)
endif()
set_target_properties(SUNDIALS::sundials_nvecopenmp PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${SUNDIALS_IFACE_COMP_DEF}")
unset(SUNDIALS_IFACE_COMP_DEF)
endif()

# Determine SUNDIALS interface version
if (SUNDIALS_FOUND)
get_target_property(SUNDIALS_IFACE_COMP_DEF SUNDIALS::sundials_idas INTERFACE_COMPILE_DEFINITIONS)
if (SUNDIALS_IFACE_COMP_DEF)
list(APPEND SUNDIALS_IFACE_COMP_DEF "CADET_SUNDIALS_IFACE=${SUNDIALS_VERSION_MAJOR}")
else()
set(SUNDIALS_IFACE_COMP_DEF "CADET_SUNDIALS_IFACE=${SUNDIALS_VERSION_MAJOR}")
# Determine SUNDIALS interface version
if (SUNDIALS_FOUND)
get_target_property(SUNDIALS_IFACE_COMP_DEF SUNDIALS::sundials_idas INTERFACE_COMPILE_DEFINITIONS)
if (SUNDIALS_IFACE_COMP_DEF)
list(APPEND SUNDIALS_IFACE_COMP_DEF "CADET_SUNDIALS_IFACE=${SUNDIALS_VERSION_MAJOR}")
else()
set(SUNDIALS_IFACE_COMP_DEF "CADET_SUNDIALS_IFACE=${SUNDIALS_VERSION_MAJOR}")
endif()
set_target_properties(SUNDIALS::sundials_idas PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${SUNDIALS_IFACE_COMP_DEF}")
unset(SUNDIALS_IFACE_COMP_DEF)
endif()
set_target_properties(SUNDIALS::sundials_idas PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${SUNDIALS_IFACE_COMP_DEF}")
unset(SUNDIALS_IFACE_COMP_DEF)
else()
set(SUNDIALS_FOUND TRUE)
set(SUNDIALS_VERSION "3.2.1")
set(SUNDIALS_NVEC_TARGET "SUNDIALS::sundials_nvecserial")
add_subdirectory(ThirdParty/sundials)

add_library(SUNDIALS::sundials_idas INTERFACE IMPORTED)
target_link_libraries(SUNDIALS::sundials_idas INTERFACE sundials_idas_static)
target_include_directories(SUNDIALS::sundials_idas INTERFACE ThirdParty/sundials/include ThirdParty/sundials/src "${CMAKE_BINARY_DIR}/ThirdParty/sundials/include")
set_target_properties(SUNDIALS::sundials_idas PROPERTIES INTERFACE_COMPILE_DEFINITIONS "CADET_SUNDIALS_IFACE=3")

add_library(SUNDIALS::sundials_nvecserial INTERFACE IMPORTED)
target_include_directories(SUNDIALS::sundials_nvecserial INTERFACE ThirdParty/sundials/include "${CMAKE_BINARY_DIR}/ThirdParty/sundials/include")
target_link_libraries(SUNDIALS::sundials_nvecserial INTERFACE sundials_nvecserial_static)
endif()

if (ENABLE_CADET_TOOLS OR ENABLE_CADET_CLI)
Expand Down Expand Up @@ -611,11 +629,17 @@ if (TBB_FOUND)
message(" Libs ${TBB_LIBRARIES}")
endif()

message("Found SUNDIALS: ${SUNDIALS_FOUND}")
if (SUNDIALS_FOUND)
if (ENABLE_PACKAGED_SUNDIALS)
message("Found SUNDIALS: ${SUNDIALS_FOUND}")
message(" Version ${SUNDIALS_VERSION}")
message(" Includes ${SUNDIALS_INCLUDE_DIRS}")
message(" Libs ${SUNDIALS_LIBRARIES}")
message(" Packaged")
else()
message("Found SUNDIALS: ${SUNDIALS_FOUND}")
if (SUNDIALS_FOUND)
message(" Version ${SUNDIALS_VERSION}")
message(" Includes ${SUNDIALS_INCLUDE_DIRS}")
message(" Libs ${SUNDIALS_LIBRARIES}")
endif()
endif()

if (ENABLE_GRM_2D)
Expand Down