From b939ea55f6cadeff2f2814c30b41031bc1c6bfc8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 24 Oct 2022 05:05:49 -0400 Subject: [PATCH] allow `-kokkos on g 0` without GPU support, report GPUs only if ngpu > 0 --- src/KOKKOS/kokkos.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 7e637788ec..53cb1fa590 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -121,11 +121,12 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) } else if (strcmp(arg[iarg],"g") == 0 || strcmp(arg[iarg],"gpus") == 0) { -#ifndef LMP_KOKKOS_GPU - error->all(FLERR,"GPUs are requested but Kokkos has not been compiled using a GPU-enabled backend"); -#endif if (iarg+2 > narg) error->all(FLERR,"Invalid Kokkos command-line args"); ngpus = utils::inumeric(FLERR, arg[iarg+1], false, lmp); +#ifndef LMP_KOKKOS_GPU + if (ngpus > 0) + error->all(FLERR,"GPUs are requested but Kokkos has not been compiled using a GPU-enabled backend"); +#endif int skip_gpu = 9999; if (iarg+2 < narg && isdigit(arg[iarg+2][0])) { @@ -207,7 +208,8 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) init_ngpus = ngpus; } - if (me == 0) utils::logmesg(lmp, " will use up to {} GPU(s) per node\n", ngpus); + if ((me == 0) && (ngpus > 0)) + utils::logmesg(lmp, " will use up to {} GPU(s) per node\n", ngpus); #ifdef LMP_KOKKOS_GPU if (ngpus <= 0)