Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c98bc16
Add a new singularity-utils library. This is the cmakelists file
adamdempsey90 Jun 3, 2026
55d08b6
Move some shared headers to a new shard library. Update the includes …
adamdempsey90 Jun 4, 2026
63646a3
Move sesame2spiner files into a library and executable src/ directori…
adamdempsey90 Jun 4, 2026
37f59e5
Modify cmake and fix some include paths to get everything to compile
adamdempsey90 Jun 4, 2026
5f041fd
Add sesame2spiner namespace
adamdempsey90 Jun 4, 2026
9c90094
Fix comment
adamdempsey90 Jun 4, 2026
ee628b5
Add back forwarding headers for the ones we lost
adamdempsey90 Jun 4, 2026
4374103
Merge remote-tracking branch 'origin/main' into dempsey/sesrefac
adamdempsey90 Jun 4, 2026
a5c40a0
Updates for non submodule mode
adamdempsey90 Jun 5, 2026
64cb334
Use correct if checks
adamdempsey90 Jun 5, 2026
d17b292
ancient formatting
adamdempsey90 Jun 5, 2026
062f35d
Try this out
adamdempsey90 Jun 9, 2026
81fdde2
Merge remote-tracking branch 'origin/main' into dempsey/sesrefac
adamdempsey90 Jun 9, 2026
02e42e2
Another attempt
adamdempsey90 Jun 9, 2026
590ff79
Install sesame2spiner as a part of singularity-eos_INTERFACE
adamdempsey90 Jun 9, 2026
c492637
Move up eigen finding
adamdempsey90 Jun 10, 2026
b6bfe26
Move the spiner param struct and some helpers into singularity-utils
adamdempsey90 Jun 11, 2026
0fc0614
Remove target sources
adamdempsey90 Jun 11, 2026
1665215
Remove headers that are now in singularity-utils
adamdempsey90 Jul 15, 2026
0fefea6
Revert "Remove headers that are now in singularity-utils"
adamdempsey90 Jul 15, 2026
b2e1992
Remove headers that are now in singularity-utils
adamdempsey90 Jul 15, 2026
1b80701
Merge branch 'main' into dempsey/sesrefac
Yurlungur Jul 16, 2026
0c9bd97
Changelog
adamdempsey90 Jul 16, 2026
2fb71a8
Merge branch 'main' into dempsey/sesrefac
Yurlungur Jul 16, 2026
1fb3090
Merge remote-tracking branch 'origin/main' into dempsey/sesrefac
adamdempsey90 Jul 16, 2026
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
- [[PR63]](https://github.com/lanl/singularity-eos/pull/639) Fixed UnitSystem temperature bug. Temperature is now treated in the same as the time, mass, and length unit factors.

### Changed (changing behavior/API/variables/...)
- [[PR641]](https://github.com/lanl/singularity-eos/pull/641) The location of some header files located in `<singularity-eos/base>` have moved to `<singularity-utils>`.

### Infrastructure (changes irrelevant to downstream codes)
- [[PR641]](https://github.com/lanl/singularity-eos/pull/641) `sesame2spiner` is now linked into `singularity-eos`. Some shared headers have been pulled out into a new `singularity-utils` library.
- [[PR636]](https://github.com/lanl/singularity-eos/pull/636) Wrap numpy arrays in a simple wrapper to make GPU compilers happy.
- [[PR633]](https://github.com/lanl/singularity-eos/pull/633) Make robust::sgn handle unsigned properly
- [[PR629]](https://github.com/lanl/singularity-eos/pull/629) Use macros and eos_base and eos_variant to reduce boiler plate
Expand Down
201 changes: 118 additions & 83 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ------------------------------------------------------------------------------#
# © 2021-2025. Triad National Security, LLC. All rights reserved. This program
# © 2021-2026. Triad National Security, LLC. All rights reserved. This program
# was produced under U.S. Government contract 89233218CNA000001 for Los Alamos
# National Laboratory (LANL), which is operated by Triad National Security, LLC
# for the U.S. Department of Energy/National Nuclear Security Administration.
Expand All @@ -11,6 +11,8 @@
# publicly and display publicly, and to permit others to do so.
# ------------------------------------------------------------------------------#

# This file was made in part with generative AI

cmake_minimum_required(VERSION 3.19)

# Disable "in-source" builds
Expand Down Expand Up @@ -174,6 +176,7 @@ endif()
# singularity-eos Library
# ------------------------------------------------------------------------------#

# Load CMake modules for finding dependencies
include(singularity-eos/Eigen3)
include(singularity-eos/eospac)
include(singularity-eos/hdf5)
Expand All @@ -190,12 +193,31 @@ add_library(singularity-eos::singularity-eos_Common ALIAS singularity-eos_Common

add_library(singularity-eos_Interface INTERFACE)
add_library(singularity-eos::singularity-eos_Interface ALIAS singularity-eos_Interface)
target_link_libraries(singularity-eos_Interface INTERFACE singularity-eos_Common)
target_link_libraries(singularity-eos_Interface INTERFACE singularity-eos_Common singularity-utils::singularity-utils)
target_link_libraries(singularity-eos INTERFACE singularity-eos_Interface)

# ld has problems with Clang's libomp.so, use ldd instead
target_link_options(singularity-eos_Interface INTERFACE $<$<CXX_COMPILER_ID:Clang>:-fuse-ld=lld>)

# ------------------------------------------------------------------------------#
# Determine if we're in submodule mode
# ------------------------------------------------------------------------------#
# This must happen before finding dependencies

# checks if this is our build, or we've been imported via `add_subdirectory`
if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
message(
STATUS
"Detected that `singularity-eos` is a subproject, will configure build in submodule mode"
)
set(SINGULARITY_SUBMODULE_MODE ON)
endif()

if(SINGULARITY_FORCE_SUBMODULE_MODE)
message(STATUS "Building as though project was a submodule.")
set(SINGULARITY_SUBMODULE_MODE ON)
endif()

# ------------------------------------------------------------------------------#
# Compiler & language setup
# ------------------------------------------------------------------------------#
Expand Down Expand Up @@ -225,31 +247,6 @@ if(SINGULARITY_BUILD_PYTHON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

# require at least C++17, but allow newer versions to become a client requirement if
# explicitly set at build time (needed for building with newer Kokkos)
if(CMAKE_CXX_STANDARD)
target_compile_features(singularity-eos_Interface INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
else()
target_compile_features(singularity-eos_Interface INTERFACE cxx_std_17)
endif()

# checks if this is our build, or we've been imported via `add_subdirectory` NB:
# this should make the `option(SINGULARITY_SUBMODULE_MODE ...)` unnecessary
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CMAKE_CXX_EXTENSIONS OFF)
else()
message(
STATUS
"Detected that `singularity-eos` is a subproject, will configure build in submodule mode"
)
set(SINGULARITY_SUBMODULE_MODE ON)
endif()

if(SINGULARITY_FORCE_SUBMODULE_MODE)
message(STATUS "Building as though project was a submodule.")
set(SINGULARITY_SUBMODULE_MODE ON)
endif()

# Use to determine if Eigen is used or not
set(SINGULARITY_USE_EIGEN
OFF
Expand All @@ -266,6 +263,83 @@ if(SINGULARITY_BUILD_CLOSURE AND NOT SINGULARITY_USE_KOKKOSKERNELS)
CACHE BOOL "" FORCE)
endif()

# ------------------------------------------------------------------------------#
# Import/Find External Dependencies
# ------------------------------------------------------------------------------#
# Must happen before building singularity-utils (which needs ports-of-call and spiner)
# Dependency order: Kokkos -> ports-of-call -> spiner -> singularity-utils

if(SINGULARITY_SUBMODULE_MODE)
# add all submodules
message(STATUS "singularity-eos configuring in submodule mode.")

# Kokkos first (ports-of-call may depend on it if PORTABILITY_STRATEGY_KOKKOS is set)
if(SINGULARITY_USE_KOKKOS)
singularity_import_kokkos()
if(SINGULARITY_USE_KOKKOSKERNELS)
singularity_import_kokkoskernels()
endif()
endif()

# Then ports-of-call
singularity_import_ports_of_call()

# Then spiner (depends on ports-of-call)
if(SINGULARITY_USE_SPINER)
singularity_import_spiner()
endif()

# Eigen (if needed)
if(SINGULARITY_USE_EIGEN)
singularity_import_eigen()
endif()
else()
# use system packages

# Kokkos first
if(SINGULARITY_USE_KOKKOS)
singularity_find_kokkos()
if(SINGULARITY_USE_KOKKOSKERNELS)
singularity_find_kokkoskernels()
endif()
endif()

# Then ports-of-call
singularity_find_ports_of_call()

# Then spiner
if(SINGULARITY_USE_SPINER)
singularity_find_spiner()
endif()

# Eigen (if needed)
if(SINGULARITY_USE_EIGEN)
singularity_find_eigen()
endif()
endif()

# Build singularity-utils first - it's a dependency for both
# singularity-eos and sesame2spiner
add_subdirectory(singularity-utils)

# Enable HDF5 and EOSPAC now that languages and dependencies are set up
if(SINGULARITY_USE_SPINER_WITH_HDF5)
singularity_enable_hdf5(singularity-eos_Common)
endif()

if(SINGULARITY_USE_EOSPAC)
# NB This will add the `eospac-wrapper` directory.
singularity_enable_eospac(singularity-eos_Common)
endif()

# require at least C++17, but allow newer versions to become a client requirement if
# explicitly set at build time (needed for building with newer Kokkos)
if(CMAKE_CXX_STANDARD)
target_compile_features(singularity-eos_Interface INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
else()
target_compile_features(singularity-eos_Interface INTERFACE cxx_std_17)
endif()

# ------------------------------------------------------------------------------#
# De-thaw some options
# ------------------------------------------------------------------------------#
Expand Down Expand Up @@ -300,13 +374,28 @@ if(SINGULARITY_BUILD_EXAMPLES)
add_subdirectory(example)
endif()

# add subdirs
# Enable dependencies for singularity-eos_Interface
singularity_enable_ports_of_call(singularity-eos_Interface)

if(SINGULARITY_USE_SPINER)
singularity_enable_spiner(singularity-eos_Interface)
# if(SINGULARITY_USE_SPINER_WITH_HDF5)
# singularity_enable_hdf5(singularity-eos_Interface) endif()
endif()

# ------------------------------------------------------------------------------#
# Add subdirectories
# ------------------------------------------------------------------------------#

if(SINGULARITY_BUILD_PYTHON)
add_subdirectory(python)
endif()

if(SINGULARITY_BUILD_SESAME2SPINER)
add_subdirectory(sesame2spiner)
# Link sesame2spiner library into singularity-eos
target_link_libraries(singularity-eos_Interface INTERFACE sesame2spiner-lib)
target_compile_definitions(singularity-eos_Interface INTERFACE SINGULARITY_USE_SESAME2SPINER)
endif()

if(SINGULARITY_BUILD_STELLARCOLLAPSE2SPINER)
Expand Down Expand Up @@ -379,59 +468,6 @@ endif()
# building are not located outside of the source directory, except for explicit
# cases.

if(SINGULARITY_USE_SPINER_WITH_HDF5)
singularity_enable_hdf5(singularity-eos_Common)
endif()

if(SINGULARITY_USE_EOSPAC)
# NB This will add the `eospac-wrapper` directory.
singularity_enable_eospac(singularity-eos_Common)
endif()

if(SINGULARITY_SUBMODULE_MODE)
# add all submodules
message(STATUS "singularity-eos configuring in submodule mode.")
singularity_import_ports_of_call()
if(SINGULARITY_USE_SPINER)
singularity_import_spiner()
endif()
if(SINGULARITY_USE_KOKKOS)
singularity_import_kokkos()
if(SINGULARITY_USE_KOKKOSKERNELS)
singularity_import_kokkoskernels()
endif()
endif()

if(SINGULARITY_USE_EIGEN)
singularity_import_eigen()
endif()
else()
# use system packages
singularity_find_ports_of_call()
if(SINGULARITY_USE_SPINER)
singularity_find_spiner()
endif()

if(SINGULARITY_USE_KOKKOS)
singularity_find_kokkos()
if(SINGULARITY_USE_KOKKOSKERNELS)
singularity_find_kokkoskernels()
endif()
endif()
if(SINGULARITY_USE_EIGEN)
singularity_find_eigen()
endif()

endif()

singularity_enable_ports_of_call(singularity-eos_Interface)

if(SINGULARITY_USE_SPINER)
singularity_enable_spiner(singularity-eos_Interface)
# if(SINGULARITY_USE_SPINER_WITH_HDF5)
# singularity_enable_hdf5(singularity-eos_Interface) endif()
endif()

# Both the interface (headers) and the library (compiled) need to link to Kokkos
# see get_sg_eos.cpp
if(SINGULARITY_USE_KOKKOS)
Expand Down Expand Up @@ -589,8 +625,7 @@ target_compile_options(
# `-Wclass-memaccess now default with -Wall but we explicitly
# manage this ourselves in our serialization routines.
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:CXX>>:-Wno-class-memaccess>
# Intel compilers enable -ffast-math even in Debug builds. This disables finite-math-only in
# Debug builds to allow NaN/Inf checks without pages of warnings
# Disable finite-math-only in Debug builds to allow NaN/Inf checks (Intel compilers)
Comment thread
Yurlungur marked this conversation as resolved.
$<$<AND:$<CONFIG:Debug>,$<OR:$<CXX_COMPILER_ID:IntelLLVM>,$<CXX_COMPILER_ID:Intel>>>:-fno-finite-math-only>
)
if (SINGULARITY_STRICT_WARNINGS)
Expand Down
22 changes: 22 additions & 0 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ install(
NAMESPACE "singularity-eos::"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/singularity-eos)

# Install singularity-utils (required by singularity-eos_Interface)
install(
TARGETS singularity-utils
Comment thread
Yurlungur marked this conversation as resolved.
EXPORT singularity-eos_Interface
DESTINATION ${CMAKE_INSTALL_LIBDIR})

# Install sesame2spiner-lib if it was built (required by singularity-eos_Interface when enabled)
if(TARGET sesame2spiner-lib)
install(
TARGETS sesame2spiner-lib
EXPORT singularity-eos_Interface
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION include
)
endif()
install(
TARGETS singularity-eos_Interface
EXPORT singularity-eos_Interface
Expand Down Expand Up @@ -123,6 +139,12 @@ export(
FILE ${CMAKE_CURRENT_BINARY_DIR}/singularity-eos_Common.cmake
NAMESPACE singularity-eos::)

# Export singularity-utils with singularity-eos_Interface
export(
TARGETS singularity-utils
FILE ${CMAKE_CURRENT_BINARY_DIR}/singularity-utils.cmake
NAMESPACE singularity-utils::)

export(
EXPORT singularity-eos_Interface
FILE ${CMAKE_CURRENT_BINARY_DIR}/singularity-eos_Interface.cmake
Expand Down
4 changes: 3 additions & 1 deletion cmake/singularity-eos/hdf5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ macro(singularity_enable_hdf5 target)
# If we're doing an in-tree cray build, skip all this stuff. Fixes
# in-tree builds on Roci + Chicoma This is if (NOT (IN_TREE AND
# CRAY_THING)), but no composite expressions in cmake
if(NOT HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE OR NOT SINGULARITY_FORCE_SUBMODULE_MODE)
# Check both HDF5_C_COMPILER_NO_INTERROGATE and HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE
# as the variable name may differ across CMake/HDF5 versions
if(NOT ((HDF5_C_COMPILER_NO_INTERROGATE OR HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE) AND SINGULARITY_FORCE_SUBMODULE_MODE))

Comment thread
Yurlungur marked this conversation as resolved.
# I'm bailing out here if these arn't filled in. I don't know if this is
# correct for every downstream use, but right now we need to enforce some kind
Expand Down
2 changes: 1 addition & 1 deletion eospac-wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ endif()

target_include_directories(eospac-wrapper
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>
)

Expand Down
4 changes: 2 additions & 2 deletions example/benchmark_spiner_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// Spiner headers
#include <ports-of-call/portability.hpp>
#include <singularity-eos/base/sp5/singularity_eos_sp5.hpp>
#include <singularity-utils/sp5/singularity_eos_sp5.hpp>
#include <spiner/databox.hpp>
#include <spiner/interpolation.hpp>
#include <spiner/sp5.hpp>
Expand Down Expand Up @@ -448,4 +448,4 @@ int main(int argc, char *argv[]) {
std::cout << "Benchmark complete for material " << std::to_string(matid) << "\n";
}
return 0;
}
}
2 changes: 1 addition & 1 deletion example/benchmark_spiner_kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

// Spiner headers
#include <ports-of-call/portability.hpp>
#include <singularity-eos/base/sp5/singularity_eos_sp5.hpp>
#include <singularity-utils/sp5/singularity_eos_sp5.hpp>
#include <spiner/databox.hpp>
#include <spiner/interpolation.hpp>
#include <spiner/sp5.hpp>
Expand Down
2 changes: 1 addition & 1 deletion example/eos_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <ports-of-call/portability.hpp>

// This contains useful tools for preventing things like divide by zero
#include <singularity-eos/base/robust_utils.hpp>
#include <singularity-utils/robust_utils.hpp>
// Needed to import the eos models
#include <singularity-eos/eos/eos.hpp>

Expand Down
2 changes: 1 addition & 1 deletion example/get_sound_speed_press.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <iostream>

// This contains useful tools for preventing things like divide by zero
#include <singularity-eos/base/robust_utils.hpp>
#include <singularity-utils/robust_utils.hpp>
// Needed to import the eos models
#include <singularity-eos/eos/eos.hpp>
// One way of initializing models with modifiers
Expand Down
4 changes: 2 additions & 2 deletions example/map_pt_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
#include <ports-of-call/portable_errors.hpp>

// This contains useful tools for preventing things like divide by zero
#include <singularity-eos/base/robust_utils.hpp>
#include <singularity-utils/robust_utils.hpp>
// 1D root finding
#include <singularity-eos/base/root-finding-1d/root_finding.hpp>
#include <singularity-utils/root-finding-1d/root_finding.hpp>
// Needed to import the eos models
#include <singularity-eos/eos/eos.hpp>

Expand Down
Loading
Loading