Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [[PR575]](https://github.com/lanl/singularity-eos/pull/575) Pin variant submodule to the same commit as the spackage

### Infrastructure (changes irrelevant to downstream codes)
- [[PR594]](https://github.com/lanl/singularity-eos/pull/594) clean up tests in preparation for ports-of-call variant transition
- [[PR588]](https://github.com/lanl/singularity-eos/pull/588) Add DensityEnergyFromPressureTemperature in unit system test
- [[PR576]](https://github.com/lanl/singularity-eos/pull/576) Clean up some header includes to use the C++ versions
- [[PR559]](https://github.com/lanl/singularity-eos/pull/559) Document the intent of the virtual keyword in solvers
Expand Down
18 changes: 13 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,19 @@ if(SINGULARITY_BUILD_CLOSURE)
catch_discover_tests(closure_unit_tests PROPERTIES TIMEOUT 120)

if(SINGULARITY_USE_SPINER)
add_executable(test_pte test_pte.cpp)
target_link_libraries(test_pte PRIVATE Catch2::Catch2
singularity-eos::singularity-eos)
target_include_directories(test_pte PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_test(pte test_pte)
if(SINGULARITY_USE_KOKKOS AND Kokkos_ENABLE_HIP
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0.0")
message(WARNING
"Test PTE appears to encounter a compiler bug for LLVM builds targeting AMD GPUs "
"for compiler versions ${CMAKE_CXX_COMPILER_VERSION} < 19, and the test is disabled. "
"Note this corresponds to rocm versions less than 6.4.")
else()
add_executable(test_pte test_pte.cpp)
target_link_libraries(test_pte PRIVATE Catch2::Catch2
singularity-eos::singularity-eos)
target_include_directories(test_pte PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_test(pte test_pte)
endif()

add_executable(test_pte_2phase test_pte_2phaseVinetSn.cpp)
target_link_libraries(test_pte_2phase PRIVATE Catch2::Catch2
Expand Down
55 changes: 30 additions & 25 deletions test/test_pte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ using atomic_view = Kokkos::MemoryTraits<Kokkos::Atomic>;
#endif

template <template <typename... Types> class Method_t>
auto TestPTE(const std::string name, const std::size_t nscratch_vars,
std::size_t &nsuccess) {
void TestPTE(const std::string name, const std::size_t nscratch_vars,
std::size_t &nsuccess, std::vector<Real> &host_vals) {
constexpr Real EPS = 1e-5;
Real time;
nsuccess = 0;
Expand Down Expand Up @@ -236,15 +236,20 @@ auto TestPTE(const std::string name, const std::size_t nscratch_vars,
std::cout << "\n\tTotal = " << tot << "\n" << std::endl;

#ifdef PORTABILITY_STRATEGY_KOKKOS
return rho_v;
#else
Kokkos::deep_copy(rho_vh, rho_v);
#endif // PORTABILITY_STRATEGY_KOKKOS
host_vals.resize(NPTS);
for (int i = 0; i < NPTS; ++i) {
host_vals[i] = rho_hm(i);
}
#ifndef PORTABILITY_STRATEGY_KOKKOS
free(rho_d);
free(vfrac_d);
free(sie_d);
free(temp_d);
free(press_d);
free(scratch_d);
return rho_d;
#endif // PORTABILITY_STRATEGY_KOKKOS
#endif // NOT PORTABILITY_STRATEGY_KOKKOS
}

int main(int argc, char *argv[]) {
Expand All @@ -257,34 +262,34 @@ int main(int argc, char *argv[]) {

// scratch required for PTE solver
std::size_t ns_rt;
std::vector<Real> rho_rt;
auto nscratch_vars_rt = PTESolverRhoTRequiredScratch(NMAT);
auto rho_rt = TestPTE<PTESolverRhoT>("PTESolverRhoT", nscratch_vars_rt, ns_rt);
TestPTE<PTESolverRhoT>("PTESolverRhoT", nscratch_vars_rt, ns_rt, rho_rt);
nsuccess += ns_rt;

// // scratch required for PTE solver
std::size_t ns_pt;
std::vector<Real> rho_pt;
auto nscratch_vars_pt = PTESolverPTRequiredScratch(NMAT);
auto rho_pt = TestPTE<PTESolverPT>("PTESolverPT", nscratch_vars_pt, ns_pt);
TestPTE<PTESolverPT>("PTESolverPT", nscratch_vars_pt, ns_pt, rho_pt);
nsuccess += ns_pt;

int nmatch = 0;
portableReduce(
"Check rho match", 0, NMAT,
PORTABLE_LAMBDA(const int i, int &nm) {
bool they_match = isClose(rho_rt(i), rho_pt(i));
if (!they_match) {
printf("Densities don't match for %d: %.14e %.14e %.14e\n", i, rho_rt(i),
rho_pt(i), rho_rt(i) - rho_pt(i));
}
nm += they_match;
},
nmatch);
printf("Nmatch = %d / %d\n", nmatch, NMAT);

#ifndef PORTABILITY_STRATEGY_KOKKOS
free(rho_rt);
free(rho_pt);
#endif // PORTABILITY_STRATEGY_KOKKOS
int i = 0; // flat index
std::vector<bool> matmatch(NMAT, true);
for (int t = 0; t < NTRIAL; ++t) {
for (int m = 0; m < NMAT; ++m) {
bool they_match = isClose(rho_rt[i], rho_pt[i]);
if (!they_match && matmatch[m]) { // only print once per material
printf("Densities don't match for %d %d: %.14e %.14e %.14e\n", t, m, rho_rt[i],
rho_pt[i], rho_rt[i] - rho_pt[i]);
}
matmatch[m] = matmatch[m] && they_match;
nmatch += they_match;
i++;
}
}
printf("Nmatch = %d / %d\n", nmatch, i);
}
#ifdef PORTABILITY_STRATEGY_KOKKOS
Kokkos::finalize();
Expand Down
19 changes: 9 additions & 10 deletions test/test_spiner_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,23 @@
#include <cstdlib>
#include <iostream> // debug

#include <ports-of-call/portability.hpp>
#include <singularity-eos/base/indexable_types.hpp>
#include <singularity-eos/eos/eos_spiner_common.hpp>
#include <singularity-eos/eos/eos_spiner_sie_transforms.hpp>

#ifndef CATCH_CONFIG_FAST_COMPILE
#define CATCH_CONFIG_FAST_COMPILE
#include <catch2/catch_test_macros.hpp>
#endif

#include <test/eos_unit_test_helpers.hpp>
#ifdef SINGULARITY_USE_SPINER_WITH_HDF5
#ifdef SINGULARITY_USE_SPINER

#include <ports-of-call/portability.hpp>
#include <singularity-eos/base/indexable_types.hpp>
#include <singularity-eos/eos/eos_spiner_common.hpp>
#include <singularity-eos/eos/eos_spiner_sie_transforms.hpp>

#ifdef SPINER_USE_HDF5
#include <singularity-eos/base/spiner_table_utils.hpp>
#include <spiner/databox.hpp>
#include <spiner/interpolation.hpp>
#endif

#ifdef SINGULARITY_USE_SPINER
#include <test/eos_unit_test_helpers.hpp>

using namespace singularity;
using namespace transformations;
Expand Down Expand Up @@ -278,3 +276,4 @@ SCENARIO("AllTransform behaves correctly", "[TransformTest]") {
}

#endif // SINGULARITY_USE_SPINER
#endif // SINGULARITY_USE_SPINER_WITH_HDF5