diff --git a/.github/hubcast.yml b/.github/hubcast.yml index bf7f35e28f..8989f9e6e8 100644 --- a/.github/hubcast.yml +++ b/.github/hubcast.yml @@ -1,21 +1,25 @@ -Repo: - # Required: organization or user that owns the repo on CZ GitLab - dest_org: sundials - - # Required: name of the destination repository on CZ GitLab - dest_name: sundials - - # Optional: name of the CI check as reported back to GitHub (default: gitlab-ci) - check_name: llnl-lc-gitlab-ci - - # Optional: granularity of CI statuses reported to GitHub (default: [pipeline]) - # Set to [pipeline] for overall pipeline status only - # Set to [jobs] for individual job statuses only - # Set to [pipeline, jobs] to report both - check_types: [pipeline, jobs] - - # Optional: delete branches from destination when source PR is closed (default: true) - delete_closed: true - - # Optional: sync draft PRs/MRs (default: true) - sync_drafts: true +# Hubcast configuration is disabled; CI runs on GitHub-hosted resources only. +# To re-enable mirroring to LLNL CZ GitLab (and the llnl-lc-gitlab-ci checks +# on LLNL clusters), uncomment the block below. +# +# Repo: +# # Required: organization or user that owns the repo on CZ GitLab +# dest_org: sundials +# +# # Required: name of the destination repository on CZ GitLab +# dest_name: sundials +# +# # Optional: name of the CI check as reported back to GitHub (default: gitlab-ci) +# check_name: llnl-lc-gitlab-ci +# +# # Optional: granularity of CI statuses reported to GitHub (default: [pipeline]) +# # Set to [pipeline] for overall pipeline status only +# # Set to [jobs] for individual job statuses only +# # Set to [pipeline, jobs] to report both +# check_types: [pipeline, jobs] +# +# # Optional: delete branches from destination when source PR is closed (default: true) +# delete_closed: true +# +# # Optional: sync draft PRs/MRs (default: true) +# sync_drafts: true diff --git a/cmake/SundialsSetupCompilers.cmake b/cmake/SundialsSetupCompilers.cmake index 3a82d9b841..58ffca0d6d 100644 --- a/cmake/SundialsSetupCompilers.cmake +++ b/cmake/SundialsSetupCompilers.cmake @@ -438,7 +438,8 @@ if(SUNDIALS_ENABLE_BENCHMARKS OR SUNDIALS_ENABLE_MAGMA OR SUNDIALS_ENABLE_GINKGO OR SUNDIALS_ENABLE_KOKKOS - OR SUNDIALS_ENABLE_ADIAK) + OR SUNDIALS_ENABLE_ADIAK + OR SUNDIALS_ENABLE_RESOLVE) include(SundialsSetupCXX) endif() diff --git a/cmake/SundialsSetupTPLs.cmake b/cmake/SundialsSetupTPLs.cmake index 44b60d26ee..ab7f7c75e5 100644 --- a/cmake/SundialsSetupTPLs.cmake +++ b/cmake/SundialsSetupTPLs.cmake @@ -170,6 +170,15 @@ if(SUNDIALS_ENABLE_RAJA) list(APPEND SUNDIALS_TPL_LIST "RAJA") endif() +# --------------------------------------------------------------- +# Find (and test) the ReSolve libraries +# --------------------------------------------------------------- + +if(SUNDIALS_ENABLE_RESOLVE) + include(SundialsReSolve) + list(APPEND SUNDIALS_TPL_LIST "RESOLVE") +endif() + # --------------------------------------------------------------- # Find (and test) the SuperLUDIST libraries # --------------------------------------------------------------- diff --git a/cmake/SundialsTPLOptions.cmake b/cmake/SundialsTPLOptions.cmake index f5c5f2360d..98fe8ac331 100644 --- a/cmake/SundialsTPLOptions.cmake +++ b/cmake/SundialsTPLOptions.cmake @@ -560,3 +560,21 @@ sundials_option( DEPRECATED_NAMES KOKKOS_KERNELS_WORKS NEGATE_DEPRECATED) + +# --------------------------------------------------------------- +# Enable ReSolve support? +# --------------------------------------------------------------- + +sundials_option(SUNDIALS_ENABLE_RESOLVE BOOL "Enable ReSolve support" OFF) + +sundials_option(ReSolve_DIR PATH "Path to the root of a ReSolve installation" + "${ReSolve_DIR}") + +sundials_option(ReSolve_INCLUDE_DIR PATH "ReSolve include directory" + "${ReSolve_INCLUDE_DIR}" ADVANCED) + +sundials_option(ReSolve_LIBRARY_DIR PATH "ReSolve library directory" + "${ReSolve_LIBRARY_DIR}" ADVANCED) + +sundials_option(SUNDIALS_ENABLE_RESOLVE_CHECKS BOOL + "Enable ReSolve compatibility checks" ON ADVANCED) diff --git a/cmake/tpl/FindReSolve.cmake b/cmake/tpl/FindReSolve.cmake new file mode 100644 index 0000000000..8fd9fc7072 --- /dev/null +++ b/cmake/tpl/FindReSolve.cmake @@ -0,0 +1,106 @@ +# ------------------------------------------------------------------------------ +# Programmer(s): Slaven Peles @ ORNL +# ------------------------------------------------------------------------------ +# SUNDIALS Copyright Start +# Copyright (c) 2025-2026, Lawrence Livermore National Security, +# University of Maryland Baltimore County, and the SUNDIALS contributors. +# Copyright (c) 2013-2025, Lawrence Livermore National Security +# and Southern Methodist University. +# Copyright (c) 2002-2013, Lawrence Livermore National Security. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# ------------------------------------------------------------------------------ +# ReSolve find module that creates an imported target for ReSolve. +# The target is SUNDIALS::ReSolve. +# +# The variable ReSolve_DIR can be used to control where the module +# looks for the library (path to the root of a ReSolve installation or +# to a directory containing ReSolveConfig.cmake). +# +# The variable ReSolve_INCLUDE_DIR can be used to set the include path. +# The variable ReSolve_LIBRARY_DIR can be used to set the library path. +# +# This module also defines variables, but it is best to use the defined +# target to ensure includes and compile/link options are correctly passed +# to consumers. +# +# ReSolve_FOUND - system has the ReSolve library +# ReSolve_LIBRARY - the ReSolve library +# ReSolve_INCLUDE_DIR - the ReSolve include path +# ReSolve_LIBRARIES - all libraries needed for ReSolve +# ------------------------------------------------------------------------------ + +# Prefer the upstream CMake config file if the user did not point to a specific +# include/library directory. +if(NOT + (ReSolve_INCLUDE_DIR + OR ReSolve_LIBRARY_DIR + OR ReSolve_LIBRARY)) + + find_package( + ReSolve + CONFIG + QUIET + PATHS + "${ReSolve_DIR}" + PATH_SUFFIXES + lib/cmake/ReSolve + cmake/ReSolve) + + if(ReSolve_FOUND AND TARGET ReSolve::ReSolve) + if(NOT TARGET SUNDIALS::ReSolve) + add_library(SUNDIALS::ReSolve ALIAS ReSolve::ReSolve) + endif() + return() + endif() + +endif() + +# Fall back to manual detection using ReSolve_DIR, ReSolve_INCLUDE_DIR, and +# ReSolve_LIBRARY_DIR. + +# Find the include directory +find_path( + ReSolve_INCLUDE_DIR resolve/SystemSolver.hpp + PATHS "${ReSolve_DIR}" + PATH_SUFFIXES include + DOC "ReSolve include directory") + +if(ReSolve_LIBRARY) + get_filename_component(ReSolve_LIBRARY_DIR "${ReSolve_LIBRARY}" PATH) + set(ReSolve_LIBRARY_DIR + "${ReSolve_LIBRARY_DIR}" + CACHE PATH "" FORCE) +else() + find_library( + ReSolve_LIBRARY resolve + PATHS "${ReSolve_DIR}" "${ReSolve_LIBRARY_DIR}" + PATH_SUFFIXES lib lib64 + DOC "ReSolve library") +endif() +mark_as_advanced(ReSolve_LIBRARY) + +set(ReSolve_LIBRARIES "${ReSolve_LIBRARY}") + +# Set package variables including ReSolve_FOUND +find_package_handle_standard_args( + ReSolve REQUIRED_VARS ReSolve_LIBRARY ReSolve_LIBRARIES ReSolve_INCLUDE_DIR) + +# Create the SUNDIALS::ReSolve imported target +if(ReSolve_FOUND) + + if(NOT TARGET SUNDIALS::ReSolve) + add_library(SUNDIALS::ReSolve UNKNOWN IMPORTED) + endif() + + set_target_properties( + SUNDIALS::ReSolve + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ReSolve_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${ReSolve_LIBRARIES}" + IMPORTED_LOCATION "${ReSolve_LIBRARY}") + +endif() diff --git a/cmake/tpl/SundialsReSolve.cmake b/cmake/tpl/SundialsReSolve.cmake new file mode 100644 index 0000000000..7aded013d3 --- /dev/null +++ b/cmake/tpl/SundialsReSolve.cmake @@ -0,0 +1,89 @@ +# ----------------------------------------------------------------------------- +# Programmer(s): Slaven Peles @ ORNL +# ----------------------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2025-2026, Lawrence Livermore National Security, +# University of Maryland Baltimore County, and the SUNDIALS contributors. +# Copyright (c) 2013-2025, Lawrence Livermore National Security +# and Southern Methodist University. +# Copyright (c) 2002-2013, Lawrence Livermore National Security. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# ----------------------------------------------------------------------------- +# Module to find and setup ReSolve. +# ReSolve is a GPU-friendly linear solver library developed at ORNL: +# https://github.com/ORNL/ReSolve +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- +# Section 1: Include guard +# ----------------------------------------------------------------------------- + +include_guard(GLOBAL) + +# ----------------------------------------------------------------------------- +# Section 2: Check to make sure options are compatible +# ----------------------------------------------------------------------------- + +# ReSolve is a C++ library; CXX must be enabled (SundialsSetupCompilers.cmake +# gates include(SundialsSetupCXX) on SUNDIALS_ENABLE_RESOLVE). +if(NOT CMAKE_CXX_COMPILER_LOADED) + message(FATAL_ERROR "ReSolve requires C++ but no C++ compiler was found. " + "Enable a C++ compiler or set CMAKE_CXX_COMPILER.") +endif() + +if(CMAKE_CXX_STANDARD LESS "14") + message(FATAL_ERROR "CMAKE_CXX_STANDARD must be >= 14 when using ReSolve") +endif() + +# ----------------------------------------------------------------------------- +# Section 3: Find the TPL +# ----------------------------------------------------------------------------- + +find_package(ReSolve REQUIRED) + +message(STATUS "ReSolve_LIBRARIES: ${ReSolve_LIBRARIES}") +message(STATUS "ReSolve_INCLUDE_DIR: ${ReSolve_INCLUDE_DIR}") + +# ----------------------------------------------------------------------------- +# Section 4: Test the TPL +# ----------------------------------------------------------------------------- + +if(SUNDIALS_ENABLE_RESOLVE_CHECKS) + + message(CHECK_START "Testing ReSolve") + + set(TEST_DIR ${PROJECT_BINARY_DIR}/RESOLVE_TEST) + + # Use the self-contained Common.hpp rather than SystemSolver.hpp; the latter + # has missing internal includes in some ReSolve versions. + file( + WRITE ${TEST_DIR}/test.cpp + "\#include \n" "int main(void) {\n" + " ReSolve::real_type x = ReSolve::constants::ONE;\n" " (void)x;\n" + " return 0;\n" "}\n") + + try_compile( + COMPILE_OK ${TEST_DIR} + ${TEST_DIR}/test.cpp + LINK_LIBRARIES ReSolve::ReSolve + OUTPUT_VARIABLE COMPILE_OUTPUT) + + if(COMPILE_OK) + message(CHECK_PASS "success") + else() + message(CHECK_FAIL "failed") + file(WRITE ${TEST_DIR}/compile.out "${COMPILE_OUTPUT}") + message( + FATAL_ERROR + "Could not compile ReSolve test. Check output in ${TEST_DIR}/compile.out" + ) + endif() + +else() + message(STATUS "Skipped ReSolve checks.") +endif() diff --git a/docker/sundials-ci/spack-nightly/int32-double/spack.yaml b/docker/sundials-ci/spack-nightly/int32-double/spack.yaml index 4291a71a27..cbb78c8e50 100644 --- a/docker/sundials-ci/spack-nightly/int32-double/spack.yaml +++ b/docker/sundials-ci/spack-nightly/int32-double/spack.yaml @@ -20,6 +20,7 @@ spack: - superlu-dist~int64 ^parmetis~int64 arch=x86_64 %gcc@9.4.0 - trilinos+tpetra gotype=int arch=x86_64 %gcc@9.4.0 - xbraid arch=x86_64 %gcc@9.4.0 + - resolve~cuda~rocm arch=x86_64 %gcc@9.4.0 config: install_tree: /opt/software mirrors: diff --git a/docker/sundials-ci/spack-nightly/int64-double/spack.yaml b/docker/sundials-ci/spack-nightly/int64-double/spack.yaml index 2e0f859aa6..50b380d64b 100644 --- a/docker/sundials-ci/spack-nightly/int64-double/spack.yaml +++ b/docker/sundials-ci/spack-nightly/int64-double/spack.yaml @@ -20,6 +20,7 @@ spack: - superlu-dist+int64 ^parmetis+int64 ^netlib-lapack arch=x86_64 %gcc@9.4.0 - trilinos+tpetra gotype=long_long arch=x86_64 %gcc@9.4.0 - xbraid arch=x86_64 %gcc@9.4.0 + - resolve~cuda~rocm arch=x86_64 %gcc@9.4.0 config: install_tree: /opt/software mirrors: diff --git a/test/config_cmake.py b/test/config_cmake.py index a208260299..bb02013388 100644 --- a/test/config_cmake.py +++ b/test/config_cmake.py @@ -1156,6 +1156,30 @@ def main(): dependson="--xbraid", ) + # ReSolve + group = parser.add_argument_group("ReSolve Options") + + add_arg( + group, + "--resolve", + "SUNDIALS_RESOLVE", + "SUNDIALS_ENABLE_RESOLVE", + "OFF", + "BOOL", + "SUNDIALS ReSolve support", + ) + + add_arg( + group, + "--resolve-dir", + "RESOLVE_ROOT", + "ReSolve_DIR", + None, + "PATH", + "ReSolve install directory", + dependson="--resolve", + ) + # -------- # Testing # -------- diff --git a/test/env/docker.sh b/test/env/docker.sh index b26abc1cd1..88080b8a8d 100644 --- a/test/env/docker.sh +++ b/test/env/docker.sh @@ -360,3 +360,15 @@ else export SUNDIALS_XBRAID=OFF unset XBRAID_ROOT fi + +# ------- +# resolve +# ------- + +if [ "$SUNDIALS_PRECISION" == "double" ]; then + export SUNDIALS_RESOLVE=ON + export RESOLVE_ROOT=/opt/view +else + export SUNDIALS_RESOLVE=OFF + unset RESOLVE_ROOT +fi