Adding Kokkos output and error checks

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14525 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
stamoor
2016-01-29 17:24:04 +00:00
parent 7ae6db5a98
commit daaadcdd86
2 changed files with 17 additions and 4 deletions

View File

@ -31,8 +31,13 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
kokkos_exists = 1;
lmp->kokkos = this;
int me = 0;
MPI_Comm_rank(world,&me);
if (me == 0) error->message(FLERR,"KOKKOS mode is enabled");
// process any command-line args that invoke Kokkos settings
int ngpu = 0;
int device = 0;
num_threads = 1;
numa = 1;
@ -46,8 +51,11 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
} else if (strcmp(arg[iarg],"g") == 0 ||
strcmp(arg[iarg],"gpus") == 0) {
#ifndef KOKKOS_HAVE_CUDA
error->all(FLERR,"GPUs are requested but Kokkos has not been compiled for CUDA");
#endif
if (iarg+2 > narg) error->all(FLERR,"Invalid Kokkos command-line args");
int ngpu = atoi(arg[iarg+1]);
ngpu = atoi(arg[iarg+1]);
int skip_gpu = 9999;
if (iarg+2 < narg && isdigit(arg[iarg+2][0])) {
@ -88,7 +96,15 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
// initialize Kokkos
if (me == 0) {
if (screen) fprintf(screen," using %d GPU(s)\n",ngpu);
if (logfile) fprintf(logfile," using %d GPU(s)\n",ngpu);
}
#ifdef KOKKOS_HAVE_CUDA
if (ngpu <= 0)
error->all(FLERR,"Kokkos has been compiled for CUDA but no GPUs are requested");
Kokkos::HostSpace::execution_space::initialize(num_threads,numa);
Kokkos::Cuda::SelectDevice select_device(device);
Kokkos::Cuda::initialize(select_device);

View File

@ -500,9 +500,6 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
error->all(FLERR,"Cannot use -kokkos on without KOKKOS installed");
}
MPI_Comm_rank(world,&me);
if (kokkos && me == 0) error->message(FLERR,"KOKKOS mode is enabled");
// allocate CiteMe class if enabled
if (citeflag) citeme = new CiteMe(this);