allow to check if Kokkos is active and retrieve number of threads and gpus
This commit is contained in:
@ -983,7 +983,7 @@ be called without a valid LAMMPS object handle (it is ignored).
|
|||||||
**Image masks**
|
**Image masks**
|
||||||
|
|
||||||
These settings are related to how LAMMPS stores and interprets periodic images. The values are used
|
These settings are related to how LAMMPS stores and interprets periodic images. The values are used
|
||||||
internally by the Fortran interface and are not likely to be useful to users.
|
internally by the :doc:`Fortran interface <Fortran>` and are not likely to be useful to users.
|
||||||
|
|
||||||
.. list-table::
|
.. list-table::
|
||||||
:header-rows: 1
|
:header-rows: 1
|
||||||
@ -1015,8 +1015,17 @@ internally by the Fortran interface and are not likely to be useful to users.
|
|||||||
* - box_exist
|
* - box_exist
|
||||||
- 1 if the simulation box is defined, 0 if not.
|
- 1 if the simulation box is defined, 0 if not.
|
||||||
See :doc:`create_box`.
|
See :doc:`create_box`.
|
||||||
|
* - kokkos_active
|
||||||
|
- 1 if the KOKKOS package is compiled in **and** activated, 0 if not.
|
||||||
|
See :doc:`<Speed_kokkos>`.
|
||||||
|
* - kokkos_nthreads
|
||||||
|
- Number of Kokkos threads per MPI process, 0 if Kokkos is not active.
|
||||||
|
See :doc:`<Speed_kokkos>`.
|
||||||
|
* - kokkos_ngpus
|
||||||
|
- Number of Kokkos gpus per MPI process, 0 if Kokkos is not active or no GPU support.
|
||||||
|
See :doc:`<Speed_kokkos>`.
|
||||||
* - nthreads
|
* - nthreads
|
||||||
- Number of requested OpenMP threads for LAMMPS' execution
|
- Number of requested OpenMP threads per MPI process for LAMMPS' execution
|
||||||
* - newton_bond
|
* - newton_bond
|
||||||
- 1 if Newton's 3rd law is applied to bonded interactions, 0 if not.
|
- 1 if Newton's 3rd law is applied to bonded interactions, 0 if not.
|
||||||
* - newton_pair
|
* - newton_pair
|
||||||
@ -1126,6 +1135,9 @@ int lammps_extract_setting(void *handle, const char *keyword)
|
|||||||
|
|
||||||
if (strcmp(keyword,"dimension") == 0) return lmp->domain->dimension;
|
if (strcmp(keyword,"dimension") == 0) return lmp->domain->dimension;
|
||||||
if (strcmp(keyword,"box_exist") == 0) return lmp->domain->box_exist;
|
if (strcmp(keyword,"box_exist") == 0) return lmp->domain->box_exist;
|
||||||
|
if (strcmp(keyword,"kokkos_active") == 0) return (lmp->kokkos) ? 1 : 0;
|
||||||
|
if (strcmp(keyword,"kokkos_nthreads") == 0) return (lmp->kokkos) ? lmp->kokkos->nthreads : 0;
|
||||||
|
if (strcmp(keyword,"kokkos_ngpus") == 0) return (lmp->kokkos) ? lmp->kokkos->ngpus : 0;
|
||||||
if (strcmp(keyword,"newton_bond") == 0) return lmp->force->newton_bond;
|
if (strcmp(keyword,"newton_bond") == 0) return lmp->force->newton_bond;
|
||||||
if (strcmp(keyword,"newton_pair") == 0) return lmp->force->newton_pair;
|
if (strcmp(keyword,"newton_pair") == 0) return lmp->force->newton_pair;
|
||||||
if (strcmp(keyword,"triclinic") == 0) return lmp->domain->triclinic;
|
if (strcmp(keyword,"triclinic") == 0) return lmp->domain->triclinic;
|
||||||
|
|||||||
@ -209,6 +209,10 @@ TEST_F(LibraryProperties, setting)
|
|||||||
lammps_command(lmp, "dimension 3");
|
lammps_command(lmp, "dimension 3");
|
||||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
|
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_active"), 0);
|
||||||
|
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_nthreads"), 0);
|
||||||
|
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_ngpus"), 0);
|
||||||
|
|
||||||
EXPECT_EQ(lammps_extract_setting(lmp, "world_size"), 1);
|
EXPECT_EQ(lammps_extract_setting(lmp, "world_size"), 1);
|
||||||
EXPECT_EQ(lammps_extract_setting(lmp, "world_rank"), 0);
|
EXPECT_EQ(lammps_extract_setting(lmp, "world_rank"), 0);
|
||||||
EXPECT_EQ(lammps_extract_setting(lmp, "universe_size"), 1);
|
EXPECT_EQ(lammps_extract_setting(lmp, "universe_size"), 1);
|
||||||
@ -545,3 +549,27 @@ TEST_F(AtomProperties, position)
|
|||||||
EXPECT_DOUBLE_EQ(x[1][1], 0.1);
|
EXPECT_DOUBLE_EQ(x[1][1], 0.1);
|
||||||
EXPECT_DOUBLE_EQ(x[1][2], 0.1);
|
EXPECT_DOUBLE_EQ(x[1][2], 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SystemSettings, kokkos)
|
||||||
|
{
|
||||||
|
if (!lammps_config_has_package("KOKKOS")) GTEST_SKIP();
|
||||||
|
if (!lammps_config_accelerator("KOKKOS", "api", "openmp")) GTEST_SKIP();
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
const char *args[] = {"SystemSettings", "-log", "none", "-echo", "screen", "-nocite",
|
||||||
|
"-k", "on", "t", "4", "-sf", "kk"};
|
||||||
|
// clang-format on
|
||||||
|
char **argv = (char **)args;
|
||||||
|
int argc = sizeof(args) / sizeof(char *);
|
||||||
|
|
||||||
|
::testing::internal::CaptureStdout();
|
||||||
|
void *lmp = lammps_open_no_mpi(argc, argv, nullptr);
|
||||||
|
std::string output = ::testing::internal::GetCapturedStdout();
|
||||||
|
if (verbose) std::cout << output;
|
||||||
|
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||||
|
|
||||||
|
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_active"), 1);
|
||||||
|
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_nthreads"), 4);
|
||||||
|
EXPECT_EQ(lammps_extract_setting(lmp, "kokkos_ngpus"), 0);
|
||||||
|
lammps_close(lmp);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user