Skip to content

Commit

Permalink
add versioning to sp5 files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahm-LANL committed Nov 20, 2024
1 parent fcbef9d commit 66f6fd7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@ if(SINGULARITY_BUILD_SESAME2SPINER)
add_subdirectory(sesame2spiner)
endif()

# Define the full version as a string macro
target_compile_definitions(singularity-eos_Interface INTERFACE
SINGULARITY_VERSION=\"${PROJECT_VERSION}\"
)

# Optionally, define major, minor, and patch versions separately
target_compile_definitions(singularity-eos_Interface INTERFACE
SINGULARITY_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
SINGULARITY_VERSION_MINOR=${PROJECT_VERSION_MINOR}
SINGULARITY_VERSION_PATCH=${PROJECT_VERSION_PATCH}
)

# defines
if (SINGULARITY_USE_TRUE_LOG_GRIDDING)
target_compile_definitions(singularity-eos_Interface
Expand Down
6 changes: 6 additions & 0 deletions sesame2spiner/generate_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ herr_t saveAllMaterials(const std::string &savename,
std::cout << "Saving to file " << savename << std::endl;
file = H5Fcreate(savename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

// singularity version
H5LTset_attribute_string(file, "/", "singularity_version", SINGULARITY_VERSION);
// log type. 0 for true, 1 for NQT1, 2 for NQT2, -1 for single precision true
int log_type = singularity::FastMath::Settings::log_type;
H5LTset_attribute_int(file, "/", SP5::LogType, &log_type, 1);

std::cout << "Processing " << matids.size() << " materials..." << std::endl;

for (size_t i = 0; i < matids.size(); i++) {
Expand Down
5 changes: 5 additions & 0 deletions singularity-eos/base/fast-math/logs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace singularity {
namespace FastMath {

// TODO(JMM): switch from preprocessor macros to CMake generated C++
enum LogType { SINGLE = -1, TRUE = 0, NQT1 = 1, NQT2 = 2 };
namespace Settings {
#ifdef SINGULARITY_USE_TRUE_LOG_GRIDDING
constexpr bool TRUE_LOGS = true;
Expand All @@ -89,6 +90,10 @@ constexpr bool NQT_O1 = true;
#else
constexpr bool NQT_O1 = false;
#endif // SINGULARITY_NQT_O1
constexpr LogType log_type = (TRUE_LOGS && FP32) ? LogType::SINGLE
: (TRUE_LOGS && FP64) ? LogType::TRUE
: NQT_O1 ? LogType::NQT1
: LogType::NQT2;
} // namespace Settings

template <typename T>
Expand Down
1 change: 1 addition & 0 deletions singularity-eos/base/sp5/singularity_eos_sp5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace SP5 {

constexpr char defaultSesFileName[] = "sesame_table.sp5";
constexpr char logType[] = "log_type";

namespace Depends {
constexpr char logRhoLogSie[] = "dependsLogRhoLogSie";
Expand Down
8 changes: 8 additions & 0 deletions singularity-eos/eos/eos_spiner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,14 @@ inline SpinerEOSDependsRhoT::SpinerEOSDependsRhoT(const std::string &filename, i
herr_t status = H5_SUCCESS;

file = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
int log_type = FastMath::LogType::NQT1;
if (H5LTfind_attribute(file, SP5::logType)) {
H5LTget_attribute_int(file, "/", SP5::logType, &log_type);
}
PORTABLE_ALWAYS_REQUIRE(
log_type == FastMath::Settings::log_type,
"Log mode used at runtime must be identical to the one used to generate the file!");

matGroup = H5Gopen(file, matid_str.c_str(), H5P_DEFAULT);
lTGroup = H5Gopen(matGroup, SP5::Depends::logRhoLogT, H5P_DEFAULT);
coldGroup = H5Gopen(matGroup, SP5::Depends::coldCurve, H5P_DEFAULT);
Expand Down

0 comments on commit 66f6fd7

Please sign in to comment.