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

@ -650,7 +650,10 @@ TEST(PairStyle, 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") ||
@ -660,6 +663,8 @@ TEST(PairStyle, kokkos_omp)
LAMMPS::argv args = {"PairStyle", "-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";
// cannot run dpd styles in plain or hybrid with more than 1 thread due to using multiple pRNGs
if (utils::strmatch(test_config.pair_style, "^dpd") ||
@ -854,8 +859,8 @@ TEST(PairStyle, gpu)
epsilon *= 5.0e8;
else
epsilon *= 1.0e10;
// relax test precision when using pppm and single precision FFTs, but only when also
// running with double precision
// relax test precision when using pppm and single precision FFTs, but only when also
// running with double precision
#if defined(FFT_SINGLE)
if (lmp->force->kspace && lmp->force->kspace->compute_flag &&
Info::has_accelerator_feature("GPU", "precision", "double"))