Add warning

This commit is contained in:
Stan Gerald Moore
2021-06-30 12:08:33 -06:00
parent 4928bd8b3d
commit d7a24dee91
2 changed files with 23 additions and 3 deletions

View File

@ -69,6 +69,7 @@ GPU_AWARE_UNKNOWN
using namespace LAMMPS_NS;
Kokkos::InitArguments KokkosLMP::args{-1, -1, -1, false};
int KokkosLMP::is_finalized = 0;
/* ---------------------------------------------------------------------- */
@ -157,6 +158,10 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
} else if (strcmp(arg[iarg],"t") == 0 ||
strcmp(arg[iarg],"threads") == 0) {
nthreads = atoi(arg[iarg+1]);
if (nthreads <= 0)
error->all(FLERR,"Invalid number of threads requested for Kokkos: must be 1 or greater");
iarg += 2;
} else if (strcmp(arg[iarg],"n") == 0 ||
@ -184,7 +189,13 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
"than the OpenMP backend");
#endif
Kokkos::InitArguments args;
// cannot change Kokkos library parameters after first initalization
if (args.num_threads != -1)
if (args.num_threads != nthreads || args.num_numa != numa || args.device_id != device)
if (me == 0)
error->warning(FLERR,"Kokkos package already initalized, cannot reinitialize with different parameters");
args.num_threads = nthreads;
args.num_numa = numa;
args.device_id = device;

View File

@ -50,6 +50,7 @@ class KokkosLMP : protected Pointers {
double binsize;
static int is_finalized;
static Kokkos::InitArguments args;
KokkosLMP(class LAMMPS *, int, char **);
~KokkosLMP();
@ -88,13 +89,21 @@ because MPI library not recognized
The local MPI rank was not found in one of four supported environment variables.
E: Invalid number of threads requested for Kokkos: must be 1 or greater
Self-explanatory.
E: GPUs are requested but Kokkos has not been compiled for CUDA
Recompile Kokkos with CUDA support to use GPUs.
E: Kokkos has been compiled for CUDA but no GPUs are requested
E: Kokkos has been compiled for CUDA, HIP, or SYCL but no GPUs are requested
One or more GPUs must be used when Kokkos is compiled for CUDA.
One or more GPUs must be used when Kokkos is compiled for CUDA/HIP/SYCL.
W: Kokkos package already initalized, cannot reinitialize with different parameters
Self-explanatory.
E: Illegal ... command