Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nqt o2 #433

Merged
merged 20 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies if there's code I'm not seeing that addresses this, but do we check if the precision of the typedef Real is double before including this? Is there equivalent 'float' procedures?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are not equivalent float procedures at this time. Nor are there little endians. However all functions in this code are explicitly doubles.

You're worried about building for single-precision I assume. Yes, we should be worried about that. Let's extend that in a later PR, though. Getting this working was enough of a lift.

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(
pdmullen marked this conversation as resolved.
Show resolved Hide resolved
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
Loading