diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bbbe34c6e8..c12744f35f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,6 +15,7 @@ variables: SINGULARITY_EOS_OPENMPI_VERSION: "4.1.1" SINGULARITY_EOS_CUDA_VERSION: "11.6.0" SINGULARITY_EOS_BUILD_TYPE: "RelWithDebInfo" + SINGULARITY_EOS_CXX_STANDARD: 14 SINGULARITY_EOS_SPACK_SPEC: "singularity-eos@main+mpi+spiner+hdf5+python+tests%gcc@=${SINGULARITY_EOS_GCC_VERSION} ^openmpi@${SINGULARITY_EOS_OPENMPI_VERSION}" COLOR_CYAN: "\e[1;36m" COLOR_PLAIN: "\e[0m" @@ -165,7 +166,6 @@ default: spack repo add spack-repo spack develop --no-clone -p ${CI_PROJECT_DIR}/utils/spiner spiner@main spack develop --no-clone -p ${CI_PROJECT_DIR}/utils/ports-of-call ports-of-call@main - spack develop --no-clone -p ${CI_PROJECT_DIR} singularity-eos@main spack config add upstreams:default:install_tree:${PROJECT_SPACK_ROOT}/opt/spack/ spack dev-build -j $(nproc) ${SINGULARITY_EOS_SPACK_SPEC} spack env deactivate @@ -196,6 +196,7 @@ default: - | cmake -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install ${SINGULARITY_CMAKE_CXX_COMPILER_FLAG} \ -DCMAKE_BUILD_TYPE=${SINGULARITY_EOS_BUILD_TYPE} \ + -DCMAKE_CXX_STANDARD=${SINGULARITY_EOS_CXX_STANDARD} \ -DSINGULARITY_USE_EOSPAC=ON \ -DSINGULARITY_USE_SPINER=ON \ -DSINGULARITY_USE_SPINER_WITH_HDF5=ON \ @@ -270,6 +271,34 @@ install_gnu_skylake_fort: <<: *python <<: *fort +install_gnu_skylake_fort_kokkos: + needs: [download_prereq] + extends: .test + variables: + <<: *skylake + <<: *python + <<: *fort + SINGULARITY_EOS_SPACK_SPEC: "singularity-eos@main+python+mpi+tests+kokkos+spiner+hdf5+kokkos-kernels%gcc@=${SINGULARITY_EOS_GCC_VERSION} ^kokkos std=${SINGULARITY_EOS_CXX_STANDARD} +openmp ^openmpi@${SINGULARITY_EOS_OPENMPI_VERSION}" + +install_gnu_skylake_fort_kokkos_cxx17: + needs: [download_prereq] + extends: .test + variables: + <<: *skylake + <<: *python + <<: *fort + SINGULARITY_EOS_CXX_STANDARD: 17 + SINGULARITY_EOS_SPACK_SPEC: "singularity-eos@main+python+mpi+tests+kokkos+spiner+hdf5+kokkos-kernels%gcc@=${SINGULARITY_EOS_GCC_VERSION} ^kokkos std=${SINGULARITY_EOS_CXX_STANDARD} +openmp ^openmpi@${SINGULARITY_EOS_OPENMPI_VERSION}" + +install_gnu_skylake_fort_static_kokkos: + needs: [download_prereq] + extends: .test + variables: + <<: *skylake + <<: *python + <<: *fort + SINGULARITY_EOS_SPACK_SPEC: "singularity-eos@main+python+mpi+tests+kokkos+spiner+hdf5+kokkos-kernels%gcc@=${SINGULARITY_EOS_GCC_VERSION} ^kokkos std=${SINGULARITY_EOS_CXX_STANDARD} ~shared +openmp ^kokkos-kernels~shared ^openmpi@${SINGULARITY_EOS_OPENMPI_VERSION}" + install_gnu_skylake_nofort: needs: [download_prereq] extends: .test diff --git a/CHANGELOG.md b/CHANGELOG.md index 6232dfc1d7..cbc326098b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added (new features/APIs/variables/...) - [[PR#339]](https://github.com/lanl/singularity-eos/pull/339) Added COMPONENTS to singularity-eos CMake install, allowing to select a minimal subset needed e.g. for Fortran bindings only - [[PR#336]](https://github.com/lanl/singularity-eos/pull/336) Included code and documentation for a full, temperature consistent, Mie-Gruneisen EOS based on a pressure power law expansion in eta = 1-V/V0. PowerMG. +- [[PR#357]](https://github.com/lanl/singularity-eos/pull/357) Added support for C++17 (e.g., needed when using newer Kokkos). ### Fixed (Repair bugs, etc) - [[PR343]](https://github.com/lanl/singularity-eos/pull/343) Add chemical potentials to stellar collapse gold files diff --git a/CMakeLists.txt b/CMakeLists.txt index b36680e5ec..7d2349059c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,11 +167,17 @@ if(SINGULARITY_BUILD_PYTHON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +# require at least C++14, 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_14) +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_STANDARD 14) - set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) else() message( diff --git a/spack-repo/packages/singularity-eos/package.py b/spack-repo/packages/singularity-eos/package.py index 9bc0436e74..f778e2596c 100644 --- a/spack-repo/packages/singularity-eos/package.py +++ b/spack-repo/packages/singularity-eos/package.py @@ -78,6 +78,7 @@ class SingularityEos(CMakePackage, CudaPackage): variant("spiner", default=True, description="Use Spiner") variant("closure", default=True, description="Build closure module") + variant("shared", default=False, description="Build shared libs") plugins = {} @@ -140,9 +141,11 @@ class SingularityEos(CMakePackage, CudaPackage): # set up kokkos offloading dependencies for _flag in ("~cuda", "+cuda"): - depends_on("kokkos ~shared" + _flag, when="+kokkos" + _flag) + depends_on("kokkos" + _flag, when="+kokkos" + _flag) depends_on("kokkos-kernels" + _flag, when="+kokkos-kernels" + _flag) + depends_on("kokkos+pic", when="+kokkos-kernels") + # specfic specs when using GPU/cuda offloading # TODO remove +wrapper for clang builds # TODO version guard +cuda_lambda @@ -150,7 +153,7 @@ class SingularityEos(CMakePackage, CudaPackage): # fix for older spacks if spack.version.Version(spack.spack_version) >= spack.version.Version("0.17"): - depends_on("kokkos-kernels ~shared", when="+kokkos-kernels") + depends_on("kokkos-kernels", when="+kokkos-kernels") for _flag in list(CudaPackage.cuda_arch_values): depends_on("kokkos cuda_arch=" + _flag, when="+cuda+kokkos cuda_arch=" + _flag) @@ -188,6 +191,7 @@ def cmake_args(self): self.define_from_variant("SINGULARITY_BUILD_PYTHON", "python"), self.define_from_variant("SINGULARITY_USE_SPINER", "spiner"), self.define_from_variant("SINGULARITY_USE_SPINER_WITH_HDF5", "hdf5"), + self.define_from_variant("BUILD_SHARED_LIBS", "shared"), self.define("SINGULARITY_BUILD_TESTS", self.run_tests), self.define( "SINGULARITY_BUILD_SESAME2SPINER", "sesame" in self.spec.variants["build_extra"].value @@ -222,6 +226,13 @@ def cmake_args(self): if "+kokkos+cuda" in self.spec: args.append(self.define("CMAKE_CXX_COMPILER", self.spec["kokkos"].kokkos_cxx)) + if "+kokkos" in self.spec: + if "cxxstd" in self.spec["kokkos"].variants: + cxx_std_variant = "cxxstd" # current spack + else: + cxx_std_variant = "std" # older spack + args.append(self.define("CMAKE_CXX_STANDARD", self.spec["kokkos"].variants[cxx_std_variant].value)) + return args def setup_run_environment(self, env):