Skip to content

Commit f176791

Browse files
authored
Merge pull request #340 from LLNL/feature/LEOS
Adding LEOS interface
2 parents 8103e15 + a91403e commit f176791

26 files changed

Lines changed: 3270 additions & 7 deletions

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Notable changes include:
2121
couple damaged to undamaged material.
2222
* planeStrain has been removed as an option in FSISPH as part of unifying deviatoric evolution with other
2323
hydros.
24+
* LEOS (Livermore Equation Of State) package now available in Spheral. Requires access to the LEOS
25+
package itself, which most folks outside LLNL will not necessarily have.
2426

2527
* Build changes / improvements:
2628
* Native Spack environments are now being used.

cmake/InstallTPLs.cmake

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ else()
158158
add_subdirectory(${chai_DIR})
159159
endif()
160160

161+
list(APPEND SPHERAL_BLT_DEPENDS chai camp RAJA umpire)
162+
list(APPEND SPHERAL_FP_TPLS RAJA umpire)
163+
list(APPEND SPHERAL_FP_DIRS ${raja_DIR} ${umpire_DIR})
164+
set_property(GLOBAL PROPERTY SPHERAL_FP_TPLS ${SPHERAL_FP_TPLS})
165+
set_property(GLOBAL PROPERTY SPHERAL_FP_DIRS ${SPHERAL_FP_DIRS})
166+
161167
message("-----------------------------------------------------------------------------")
162168
# Use find_package to get Sundials
163169
if (ENABLE_SUNDIALS)
@@ -173,15 +179,12 @@ if (ENABLE_SUNDIALS)
173179
endif()
174180
endif()
175181

176-
list(APPEND SPHERAL_BLT_DEPENDS chai camp RAJA umpire)
177-
list(APPEND SPHERAL_FP_TPLS RAJA umpire)
178-
list(APPEND SPHERAL_FP_DIRS ${raja_DIR} ${umpire_DIR})
179-
set_property(GLOBAL PROPERTY SPHERAL_FP_TPLS ${SPHERAL_FP_TPLS})
180-
set_property(GLOBAL PROPERTY SPHERAL_FP_DIRS ${SPHERAL_FP_DIRS})
181-
182182
message("-----------------------------------------------------------------------------")
183183
# TPLs that must be imported
184184
list(APPEND SPHERAL_EXTERN_LIBS boost eigen qhull silo hdf5 polytope)
185+
if (ENABLE_LEOS)
186+
list(APPEND SPHERAL_EXTERN_LIBS leos)
187+
endif()
185188

186189
blt_list_append( TO SPHERAL_EXTERN_LIBS ELEMENTS aneos IF ENABLE_ANEOS)
187190
blt_list_append( TO SPHERAL_EXTERN_LIBS ELEMENTS opensubdiv IF ENABLE_OPENSUBDIV)

cmake/tpl/leos.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(leos_libs libleos_C.a libleos.a liblip-cpp.a libyaml-cpp.a libleospact.a)
2+
# If we ever support debug TPL builds we'll need the following since the name of the libarary changes
3+
# if (CMAKE_BUILD_TYPE STREQUAL "Debug")
4+
# list(APPEND leos_libs libyaml-cppd.a)
5+
# else()
6+
# list(APPEND leos_libs libyaml-cpp.a)
7+
# endif()

scripts/spack/packages/leos/package.py

Lines changed: 618 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
diff -u -b -r a/interfaces/fortran/LEOS_types_F.F90 b/interfaces/fortran/LEOS_types_F.F90
2+
--- a/interfaces/fortran/LEOS_types_F.F90 2019-07-03 13:36:54.000000000 -0700
3+
+++ b/interfaces/fortran/LEOS_types_F.F90 2019-10-03 14:29:04.386600979 -0700
4+
@@ -111,11 +111,6 @@
5+
TYPE(C_ptr) :: vp = C_NULL_ptr
6+
END TYPE LEOS_map_ss_C
7+
8+
- TYPE LEOS_map_sm
9+
- CHARACTER, POINTER :: key(:)
10+
- INTEGER(KIND(LEOS_metadataDatatype_t)) :: mtype
11+
- END TYPE LEOS_map_sm
12+
-
13+
TYPE LEOS_map_sm_C
14+
TYPE(C_ptr) :: kp = C_NULL_ptr
15+
INTEGER(C_int) :: mtype
16+
@@ -197,6 +192,11 @@
17+
END ENUM
18+
INTEGER(KIND(LEOS_METADATA_UNKNOWN_TYPE)) :: LEOS_metadataDatatype_t
19+
20+
+ TYPE LEOS_map_sm
21+
+ CHARACTER, POINTER :: key(:)
22+
+ INTEGER(KIND(LEOS_metadataDatatype_t)) :: mtype
23+
+ END TYPE LEOS_map_sm
24+
+
25+
ENUM, BIND(C)
26+
ENUMERATOR :: LEOS_QUIET, LEOS_BASIC, LEOS_MEDIUM, LEOS_VERBOSE
27+
END ENUM
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
diff --git a/LIP/cpp_source/Implementation/LIP_MemoryManager.cpp b/LIP/cpp_source/Implementation/LIP_MemoryManager.cpp
2+
index 6fef6c3..7a237a3 100644
3+
--- a/LIP/cpp_source/Implementation/LIP_MemoryManager.cpp
4+
+++ b/LIP/cpp_source/Implementation/LIP_MemoryManager.cpp
5+
@@ -36,6 +36,8 @@
6+
7+
#endif // UMPIRE_ENABLE_IPC_SHARED_MEMORY
8+
9+
+using LIP_Umpire_Exception = umpire::out_of_memory_error::exception;
10+
+
11+
#endif // LIP_USE_UMPIRE
12+
13+
#include "LIP_MemoryManager.hxx"
14+
@@ -164,7 +166,7 @@ void* MemoryManager::allocate(std::size_t nbytes, MemoryType_t mem_type,
15+
#else
16+
ptr = alloc.allocate(nbytes);
17+
#endif
18+
- } catch (umpire::util::Exception &e) {
19+
+ } catch (LIP_Umpire_Exception &e) {
20+
// Just return the nullptr.
21+
// TODO: Throw exception instead?
22+
std::cout << "Umpire exception at allocation: " << e.what() << std::endl;
23+
@@ -219,7 +221,7 @@ void MemoryManager::deallocate(void *ptr, MemoryType_t mem_type)
24+
auto alloc = getUmpireAllocator(mem_type);
25+
alloc.deallocate(ptr);
26+
27+
- } catch (umpire::util::Exception &e) {
28+
+ } catch (LIP_Umpire_Exception &e) {
29+
// Just catch the exception. No way to handle this.
30+
// TODO: Throw exception instead?
31+
// throw e;
32+
@@ -272,9 +274,9 @@ void MemoryManager::real_copy(void *dest, void *src,
33+
try {
34+
auto &rm = umpire::ResourceManager::getInstance();
35+
rm.copy(dest, src, nbytes);
36+
- } catch (umpire::util::Exception e) {
37+
+ } catch (LIP_Umpire_Exception& e) {
38+
39+
- std::string message(ERR_COPY_FAILED_S + " " + e.message() );
40+
+ std::string message(ERR_COPY_FAILED_S + " " + e.what() );
41+
status.setStatus(Status::SL_ERROR, __func__, ERR_COPY_FAILED, message);
42+
43+
}
44+
@@ -326,7 +328,7 @@ bool MemoryManager::isMemoryOnCPU( MemoryType_t const mem_type )
45+
*/
46+
return( platform == umpire::Platform::host);
47+
48+
- } catch (umpire::util::Exception &e) {
49+
+ } catch (LIP_Umpire_Exception &e) {
50+
51+
// TODO: Is there a better way to handle this? May cause crash soon after call.
52+
// TODO: Throw exception instead?
53+
@@ -367,7 +369,7 @@ bool MemoryManager::isMemoryOnGPU( MemoryType_t const mem_type )
54+
return( platform == umpire::Platform::cuda);
55+
#endif
56+
57+
- } catch (umpire::util::Exception &e) {
58+
+ } catch (LIP_Umpire_Exception &e) {
59+
60+
// TODO: Is there a better way to handle this? May cause crash soon after call.
61+
// TODO: Throw exception instead?
62+
@@ -455,7 +457,7 @@ bool MemoryManager::isSharedMemory(MemoryType_t const mem_type)
63+
64+
is_shared = isSharedAllocator(alloc);
65+
66+
- } catch (umpire::util::Exception &e) {
67+
+ } catch (LIP_Umpire_Exception &e) {
68+
69+
// TODO: Is there a better way to handle this? May cause crash soon after call.
70+
// TODO: Throw exception instead?
71+
@@ -506,7 +508,7 @@ bool MemoryManager::isMemoryOwner(MemoryType_t const mem_type )
72+
73+
isOwner = isMemoryOwner(alloc);
74+
75+
- } catch (umpire::util::Exception &e) {
76+
+ } catch (LIP_Umpire_Exception &e) {
77+
// Just catch the exception. No way to handle this.
78+
// leave isOwner = true
79+
// TODO: Throw exception instead?
80+
@@ -578,7 +580,7 @@ void MemoryManager::syncSharedMemoryProcs(MemoryType_t const mem_type)
81+
umpire::get_communicator_for_allocator( alloc, base_comm_);
82+
83+
84+
- } catch (umpire::util::Exception &e) {
85+
+ } catch (LIP_Umpire_Exception &e) {
86+
// Just catch the exception. No way to handle this.
87+
// TODO: Throw exception instead?
88+
// throw e;
89+
@@ -740,7 +742,7 @@ bool MemoryManager::initializeUmpireIDMemory(MemoryType_t mem_type)
90+
91+
status = initializeUmpireIDMemory(alloc);
92+
93+
- } catch (umpire::util::Exception &e) {
94+
+ } catch (LIP_Umpire_Exception &e) {
95+
96+
status = false;
97+
// TODO: Throw exception instead?
98+
@@ -785,7 +787,7 @@ bool MemoryManager::initializeUmpireIDMemory(umpire::Allocator &alloc)
99+
}
100+
}
101+
102+
- } catch (umpire::util::Exception &e) {
103+
+ } catch (LIP_Umpire_Exception &e) {
104+
105+
status = false;
106+
// TODO: Throw exception instead?
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff -u -b -r a/cmake/TPL_Setup/SetupUmpire.cmake b/cmake/TPL_Setup/SetupUmpire.cmake
2+
--- a/cmake/TPL_Setup/SetupUmpire.cmake
3+
+++ b/cmake/TPL_Setup/SetupUmpire.cmake
4+
@@ -16,9 +16,14 @@ else()
5+
# Look for directory with umpire-config.cmake
6+
set ( BASE_UMPIRE_DIR ${UMPIRE_DIR} )
7+
8+
+ message(STATUS "Passed in UMPIRE_DIR: ${UMPIRE_DIR}")
9+
+ message(STATUS "Updated BASE_UMPIRE_DIR: ${BASE_UMPIRE_DIR}")
10+
+
11+
# Check for directory holding umpire-config.cmake
12+
if ( IS_DIRECTORY ${BASE_UMPIRE_DIR}/lib/cmake/umpire)
13+
set (UMPIRE_DIR ${BASE_UMPIRE_DIR}/lib/cmake/umpire)
14+
+ elseif ( IS_DIRECTORY ${BASE_UMPIRE_DIR}/lib64/cmake/umpire)
15+
+ set (UMPIRE_DIR ${BASE_UMPIRE_DIR}/lib64/cmake/umpire)
16+
elseif(IS_DIRECTORY ${BASE_UMPIRE_DIR}/share/umpire/cmake)
17+
set (UMPIRE_DIR ${BASE_UMPIRE_DIR}/share/umpire/cmake)
18+
elseif(NOT EXISTS ${UMPIRE_DIR}/umpire-config.cmake)
19+
@@ -26,6 +31,9 @@ else()
20+
endif()
21+
endif()
22+
23+
+message(STATUS "Modified UMPIRE_DIR: ${UMPIRE_DIR}")
24+
+
25+
+
26+
if ( DEFINED camp_DIR )
27+
28+
string(FIND ${camp_DIR} "lib/cmake/camp" NEW_CAMP_CONFIG_LOC)
29+
@@ -65,7 +73,11 @@ else()
30+
endif()
31+
32+
#set(UMPIRE_MIN_VERSION "5.0")
33+
-find_package(UMPIRE ${UMPIRE_MIN_VERSION} REQUIRED)
34+
+find_package(UMPIRE ${UMPIRE_MIN_VERSION} REQUIRED NO_DEFAULT_PATH
35+
+ PATHS ${UMPIRE_DIR}/share/umpire/cmake
36+
+ ${UMPIRE_DIR}/lib/cmake/umpire
37+
+ ${UMPIRE_DIR}/lib64/cmake/umpire
38+
+ ${UMPIRE_DIR})
39+
40+
if (UMPIRE_FOUND)
41+

scripts/spack/packages/spheral/package.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class Spheral(CachedCMakePackage, CudaPackage, ROCmPackage):
2323
version('develop', branch='develop', submodules=True)
2424
version('1.0', tag='FSISPH-v1.0', submodules=True)
2525

26+
# -------------------------------------------------------------------------
27+
# Is LEOS available in a standard place?
28+
# -------------------------------------------------------------------------
29+
from spack.pkg.spheral.leos import Leos
30+
LEOSpresent = os.path.exists(Leos.fileLoc)
31+
2632
# -------------------------------------------------------------------------
2733
# VARIANTS
2834
# -------------------------------------------------------------------------
@@ -35,6 +41,7 @@ class Spheral(CachedCMakePackage, CudaPackage, ROCmPackage):
3541
variant('opensubdiv', default=True, description='Enable use of opensubdiv to do refinement.')
3642
variant('network', default=True, description='Disable to build Spheral from a local buildcache.')
3743
variant('sundials', default=True, when="+mpi", description='Build Sundials package.')
44+
variant('leos', default=LEOSpresent, when="+mpi", description='Build LEOS package.')
3845

3946
# -------------------------------------------------------------------------
4047
# Depends
@@ -76,6 +83,8 @@ class Spheral(CachedCMakePackage, CudaPackage, ROCmPackage):
7683

7784
depends_on('sundials@7.0.0 ~shared cxxstd=17', type='build', when='+sundials')
7885

86+
depends_on("leos@8.4.2", type="build", when="+leos")
87+
7988
# Forward MPI Variants
8089
mpi_tpl_list = ["hdf5", "conduit", "axom", "adiak~shared"]
8190
for ctpl in mpi_tpl_list:
@@ -245,6 +254,10 @@ def initconfig_package_entries(self):
245254
entries.append(cmake_cache_path('sundials_DIR', spec['sundials'].prefix))
246255
entries.append(cmake_cache_option('ENABLE_SUNDIALS', True))
247256

257+
if spec.satisfies("+leos"):
258+
entries.append(cmake_cache_path('leos_DIR', spec['leos'].prefix))
259+
entries.append(cmake_cache_option('ENABLE_LEOS', True))
260+
248261
return entries
249262

250263
def cmake_args(self):

src/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ if (SPHERAL_ENABLE_SVPH)
6969
list(APPEND _packages SVPH)
7070
endif()
7171

72-
if (ENABLE_SUNDIALS AND ENABLE_MPI)
72+
if (ENABLE_SUNDIALS)
7373
list(APPEND _packages Solvers)
7474
endif()
7575

76+
if (ENABLE_LEOS)
77+
list(APPEND _packages LEOS)
78+
endif()
79+
7680
if(NOT ENABLE_CXXONLY)
7781
list(APPEND _packages
7882
SimulationControl

src/LEOS/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
include_directories(.)
2+
set(LEOS_inst
3+
LEOS
4+
)
5+
6+
set(LEOS_sources
7+
LEOS_bundle.cc
8+
)
9+
10+
instantiate(LEOS_inst LEOS_sources)
11+
12+
set(LEOS_headers
13+
LEOS.hh
14+
LEOS_bundle.hh
15+
)
16+
17+
spheral_add_obj_library(LEOS SPHERAL_OBJ_LIBS)

0 commit comments

Comments
 (0)