From 918d137db200e302e2fcbe251e6b1a18ee9312ae Mon Sep 17 00:00:00 2001 From: Jonah Miller Date: Wed, 20 Nov 2024 16:08:26 -0700 Subject: [PATCH] it builds --- cmake/SetupOptions.cmake | 2 +- .../neutrinos/spiner_opac_neutrinos.hpp | 25 +++++++++---------- utils/fast-math/logs.hpp | 6 ++++- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/cmake/SetupOptions.cmake b/cmake/SetupOptions.cmake index 9c9e53d..b96668a 100644 --- a/cmake/SetupOptions.cmake +++ b/cmake/SetupOptions.cmake @@ -11,7 +11,7 @@ option (SINGULARITY_HIDE_MORE_WARNINGS "hide more warnings" OFF) option (SINGULARITY_BUILD_TESTS "Compile tests" OFF) option (SINGULARITY_BETTER_DEBUG_FLAGS "Better debug flags for singularity" ON) -option (SINGULARITY_USE_FMATH "Enable fast-math logarithms" ON) +option (SINGULARITY_USE_FMATH "Enable fast-math logarithms" OFF) #======================================= # Dependency options diff --git a/singularity-opac/neutrinos/spiner_opac_neutrinos.hpp b/singularity-opac/neutrinos/spiner_opac_neutrinos.hpp index 039125f..03f8aca 100644 --- a/singularity-opac/neutrinos/spiner_opac_neutrinos.hpp +++ b/singularity-opac/neutrinos/spiner_opac_neutrinos.hpp @@ -19,8 +19,8 @@ #include #include #include -#include #include +#include #include #include @@ -399,9 +399,9 @@ class SpinerOpacity { auto [rho_min, rho_max] = ReadBounds_(file, "rho_points", NR); auto [T_min, T_max] = ReadBounds_(file, "temp_points", NT); - auto [Ye_min, Ye_max] = ReadBounds_(file, "ye_points", NY); auto [emin, emax] = ReadBounds_(file, "neutrino_energies", NE); + auto [YeMin, YeMax] = ReadBounds_(file, "ye_points", NY); const Real lRhoMin = std::log10(rho_min); // g/cm^3 const Real lRhoMax = std::log10(rho_max); const Real lTMin = std::log10(T_min); // MeV internally. Converted from K @@ -445,7 +445,7 @@ class SpinerOpacity { // Fill lalphanu and lJnu for (int iR = 0; iR < NR; ++iR) { for (int iT = 0; iT < NT; ++iT) { - for (int iY = 0; iY < NY, ++iY) { + for (int iY = 0; iY < NY; ++iY) { for (int idx = 0; idx < NTYPE; ++idx) { for (int ie = 0; ie < NE; ++ie) { Real kappa = kappa_file(ie, idx, iY, iT, iR); @@ -462,7 +462,7 @@ class SpinerOpacity { } } } - ComputeIntegrals(ljnu_, lJ_, lJYe_); + ComputeIntegrals(ljnu_, lJ_, lJYe_, NTYPE); } static int ReadInt_(const hid_t &file_id, const std::string &name) { @@ -487,8 +487,8 @@ class SpinerOpacity { return std::make_pair(lo, hi); } - static void ComputeIntegrals(const DataBox &ljnu, DataBox &lJ, - DataBox &lJYe) { + static void ComputeIntegrals(const DataBox &ljnu, DataBox &lJ, DataBox &lJYe, + int RAD_NUM_TYPES) { auto rhoGrid = ljnu.range(4); auto TGrid = ljnu.range(3); auto YeGrid = ljnu.range(2); @@ -516,8 +516,8 @@ class SpinerOpacity { lJYe(iRho, iT, iYe, itp) += integrand / (MEV * e); } // multiply by log spacing and take the log - lJ(iRho, iT, iYe, itp) = ToLog(lJ(iRho, iT, iYe, itp) * dle); - lJYe(iRho, iT, iYe, itp) = ToLog(lJYe(iRho, iT, iYe, itp) * dle); + lJ(iRho, iT, iYe, itp) = toLog_(lJ(iRho, iT, iYe, itp) * dle); + lJYe(iRho, iT, iYe, itp) = toLog_(lJYe(iRho, iT, iYe, itp) * dle); } } } @@ -526,17 +526,16 @@ class SpinerOpacity { #endif // SPINER_USE_HDF // TODO(JMM): Offsets probably not necessary - PORTABLE_INLINE_FUNCTION Real toLog_(const Real x, const Real offset) const { + PORTABLE_INLINE_FUNCTION static Real toLog_(const Real x, const Real offset) { return std::log10(std::abs(std::max(x, -offset) + offset) + EPS); } - PORTABLE_INLINE_FUNCTION Real toLog_(const Real x) const { + PORTABLE_INLINE_FUNCTION static Real toLog_(const Real x) { return toLog_(x, 0); } - PORTABLE_INLINE_FUNCTION Real fromLog_(const Real lx, - const Real offset) const { + PORTABLE_INLINE_FUNCTION static fromLog_(const Real lx, const Real offset) { return std::pow(10., lx) - offset; } - PORTABLE_INLINE_FUNCTION Real fromLog_(const Real lx) const { + PORTABLE_INLINE_FUNCTION static fromLog_(const Real lx) { return fromLog_(lx, 0); } PORTABLE_INLINE_FUNCTION void toLogs_(const Real rho, const Real temp, diff --git a/utils/fast-math/logs.hpp b/utils/fast-math/logs.hpp index 4264b95..5a4af94 100644 --- a/utils/fast-math/logs.hpp +++ b/utils/fast-math/logs.hpp @@ -22,15 +22,19 @@ #include #include +// TODO(JMM): This has got to go. Replace with sane math. + +#ifdef SINGULARITY_USE_FMATH // herumi-fmath does not work on device // On CPUS it provides another 10% or so speedup // for negligible cost in accuracy #define BD_USE_FMATH -#if defined(PORTABILITY_STRATEGY_KOKKOS) || defined(SINGULARITY_USE_FMATH) +#if defined(PORTABILITY_STRATEGY_KOKKOS) #undef BD_USE_FMATH #else #include #endif +#endif // SINGULARITY_USE_FMATH namespace BDMath {