run KOKKOS force style unit tests with serial when OpenMP is not available

This commit is contained in:
Axel Kohlmeyer
2025-06-22 18:12:52 -04:00
parent 12dcaa2d03
commit b3c403f464
7 changed files with 59 additions and 15 deletions

View File

@ -569,7 +569,10 @@ TEST(DihedralStyle, kokkos_omp)
{
if (!LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP();
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP();
// test either OpenMP or Serial
if (!Info::has_accelerator_feature("KOKKOS", "api", "serial") &&
!Info::has_accelerator_feature("KOKKOS", "api", "openmp"))
GTEST_SKIP();
// if KOKKOS has GPU support enabled, it *must* be used. We cannot test OpenMP only.
if (Info::has_accelerator_feature("KOKKOS", "api", "cuda") ||
Info::has_accelerator_feature("KOKKOS", "api", "hip") ||
@ -579,6 +582,8 @@ TEST(DihedralStyle, kokkos_omp)
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen",
"-nocite", "-k", "on", "t", "4",
"-sf", "kk"};
// fall back to serial if openmp is not available
if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) args[9] = "1";
::testing::internal::CaptureStdout();
LAMMPS *lmp = nullptr;
@ -773,8 +778,8 @@ TEST(DihedralStyle, extract)
}
auto *dihedral = lmp->force->dihedral;
void *ptr = nullptr;
int dim = 0;
void *ptr = nullptr;
int dim = 0;
for (auto extract : test_config.extract) {
ptr = dihedral->extract(extract.first.c_str(), dim);
EXPECT_NE(ptr, nullptr);