git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11521 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -108,4 +108,3 @@ if (test $1 = "USER-MISC") then
|
|||||||
depend GPU
|
depend GPU
|
||||||
depend USER-OMP
|
depend USER-OMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
77
src/accelerator_kokkos.h
Normal file
77
src/accelerator_kokkos.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifndef LMP_ACCELERATOR_KOKKOS_H
|
||||||
|
#define LMP_ACCELERATOR_KOKKOS_H
|
||||||
|
|
||||||
|
// true interface to KOKKOS
|
||||||
|
// used when KOKKOS is installed
|
||||||
|
|
||||||
|
#ifdef LMP_KOKKOS
|
||||||
|
|
||||||
|
#include "kokkos.h"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// dummy interface to KOKKOS
|
||||||
|
// needed for compiling when KOKKOS is not installed
|
||||||
|
|
||||||
|
//#include "comm.h"
|
||||||
|
//#include "modify.h"
|
||||||
|
//#include "verlet.h"
|
||||||
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
class KokkosLMP {
|
||||||
|
public:
|
||||||
|
int kokkos_exists;
|
||||||
|
|
||||||
|
KokkosLMP(class LAMMPS *, int, char **) {kokkos_exists = 0;}
|
||||||
|
~KokkosLMP() {}
|
||||||
|
void accelerator(int, char **) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CommKokkos : public Comm {
|
||||||
|
public:
|
||||||
|
CommKokkos(class LAMMPS *lmp) : Comm(lmp) {}
|
||||||
|
~CommKokkos() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class DomainKokkos : public Domain {
|
||||||
|
public:
|
||||||
|
DomainKokkos(class LAMMPS *lmp) : Domain(lmp) {}
|
||||||
|
~DomainKokkos() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class NeighborKokkos : public Neighbor {
|
||||||
|
public:
|
||||||
|
NeighborKokkos(class LAMMPS *lmp) : Neighbor(lmp) {}
|
||||||
|
~NeighborKokkos() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ModifyKokkos : public Modify {
|
||||||
|
public:
|
||||||
|
ModifyKokkos(class LAMMPS *lmp) : Modify(lmp) {}
|
||||||
|
~ModifyKokkos() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class VerletKokkos : public Verlet {
|
||||||
|
public:
|
||||||
|
VerletKokkos(class LAMMPS *lmp, int narg, char **arg) : Verlet(lmp,narg,arg) {}
|
||||||
|
~VerletKokkos() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@ -43,6 +43,7 @@
|
|||||||
#include "special.h"
|
#include "special.h"
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
#include "accelerator_cuda.h"
|
#include "accelerator_cuda.h"
|
||||||
|
#include "accelerator_kokkos.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
@ -1389,6 +1390,11 @@ void Input::package()
|
|||||||
delete [] fixarg;
|
delete [] fixarg;
|
||||||
force->newton_pair = 0;
|
force->newton_pair = 0;
|
||||||
|
|
||||||
|
} else if (strcmp(arg[0],"kokkos") == 0) {
|
||||||
|
if (!lmp->kokkos)
|
||||||
|
error->all(FLERR,"Package kokkos command without KOKKOS installed");
|
||||||
|
lmp->kokkos->accelerator(narg-1,&arg[1]);
|
||||||
|
|
||||||
} else if (strcmp(arg[0],"omp") == 0) {
|
} else if (strcmp(arg[0],"omp") == 0) {
|
||||||
char **fixarg = new char*[2+narg];
|
char **fixarg = new char*[2+narg];
|
||||||
fixarg[0] = (char *) "package_omp";
|
fixarg[0] = (char *) "package_omp";
|
||||||
|
|||||||
@ -42,6 +42,7 @@
|
|||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "citeme.h"
|
#include "citeme.h"
|
||||||
#include "accelerator_cuda.h"
|
#include "accelerator_cuda.h"
|
||||||
|
#include "accelerator_kokkos.h"
|
||||||
#include "accelerator_omp.h"
|
#include "accelerator_omp.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
@ -75,6 +76,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
|
|||||||
int partscreenflag = 0;
|
int partscreenflag = 0;
|
||||||
int partlogflag = 0;
|
int partlogflag = 0;
|
||||||
int cudaflag = -1;
|
int cudaflag = -1;
|
||||||
|
int kokkosflag = -1;
|
||||||
int restartflag = 0;
|
int restartflag = 0;
|
||||||
int citeflag = 1;
|
int citeflag = 1;
|
||||||
int helpflag = 0;
|
int helpflag = 0;
|
||||||
@ -84,6 +86,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
|
|||||||
char *rfile = NULL;
|
char *rfile = NULL;
|
||||||
char *dfile = NULL;
|
char *dfile = NULL;
|
||||||
int wdfirst,wdlast;
|
int wdfirst,wdlast;
|
||||||
|
int kkfirst,kklast;
|
||||||
|
|
||||||
int iarg = 1;
|
int iarg = 1;
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
@ -146,6 +149,18 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
|
|||||||
else if (strcmp(arg[iarg+1],"off") == 0) cudaflag = 0;
|
else if (strcmp(arg[iarg+1],"off") == 0) cudaflag = 0;
|
||||||
else error->universe_all(FLERR,"Invalid command-line argument");
|
else error->universe_all(FLERR,"Invalid command-line argument");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
} else if (strcmp(arg[iarg],"-kokkos") == 0 ||
|
||||||
|
strcmp(arg[iarg],"-k") == 0) {
|
||||||
|
if (iarg+2 > narg)
|
||||||
|
error->universe_all(FLERR,"Invalid command-line argument");
|
||||||
|
if (strcmp(arg[iarg+1],"on") == 0) kokkosflag = 1;
|
||||||
|
else if (strcmp(arg[iarg+1],"off") == 0) kokkosflag = 0;
|
||||||
|
else error->universe_all(FLERR,"Invalid command-line argument");
|
||||||
|
iarg += 2;
|
||||||
|
// delimit any extra args for the Kokkos instantiation
|
||||||
|
kkfirst = iarg;
|
||||||
|
while (iarg < narg && arg[iarg][0] != '-') iarg++;
|
||||||
|
kklast = iarg;
|
||||||
} else if (strcmp(arg[iarg],"-suffix") == 0 ||
|
} else if (strcmp(arg[iarg],"-suffix") == 0 ||
|
||||||
strcmp(arg[iarg],"-sf") == 0) {
|
strcmp(arg[iarg],"-sf") == 0) {
|
||||||
if (iarg+2 > narg)
|
if (iarg+2 > narg)
|
||||||
@ -403,8 +418,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
|
|||||||
error->all(FLERR,"Small to big integers are not sized correctly");
|
error->all(FLERR,"Small to big integers are not sized correctly");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// create CUDA class if USER-CUDA installed, unless explicitly switched off
|
// create Cuda class if USER-CUDA installed, unless explicitly switched off
|
||||||
// instantiation creates dummy CUDA class if USER-CUDA is not installed
|
// instantiation creates dummy Cuda class if USER-CUDA is not installed
|
||||||
|
|
||||||
if (cudaflag == 0) {
|
if (cudaflag == 0) {
|
||||||
cuda = NULL;
|
cuda = NULL;
|
||||||
@ -424,6 +439,27 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
|
|||||||
MPI_Comm_rank(world,&me);
|
MPI_Comm_rank(world,&me);
|
||||||
if (cuda && me == 0) error->message(FLERR,"USER-CUDA mode is enabled");
|
if (cuda && me == 0) error->message(FLERR,"USER-CUDA mode is enabled");
|
||||||
|
|
||||||
|
// create Kokkos class if KOKKOS installed, unless explicitly switched off
|
||||||
|
// instantiation creates dummy Kokkos class if KOKKOS is not installed
|
||||||
|
// add args between kkfirst and kklast to Kokkos instantiation
|
||||||
|
|
||||||
|
if (kokkosflag == 0) {
|
||||||
|
kokkos = NULL;
|
||||||
|
} else if (kokkosflag == 1) {
|
||||||
|
kokkos = new KokkosLMP(this,kklast-kkfirst,&arg[kkfirst]);
|
||||||
|
if (!kokkos->kokkos_exists)
|
||||||
|
error->all(FLERR,"Cannot use -kokkos on without KOKKOS installed");
|
||||||
|
} else {
|
||||||
|
kokkos = new KokkosLMP(this,kklast-kkfirst,&arg[kkfirst]);
|
||||||
|
if (!kokkos->kokkos_exists) {
|
||||||
|
delete kokkos;
|
||||||
|
kokkos = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MPI_Comm_rank(world,&me);
|
||||||
|
if (kokkos && me == 0) error->message(FLERR,"KOKKOS mode is enabled");
|
||||||
|
|
||||||
// allocate CiteMe class if enabled
|
// allocate CiteMe class if enabled
|
||||||
|
|
||||||
if (citeflag) citeme = new CiteMe(this);
|
if (citeflag) citeme = new CiteMe(this);
|
||||||
@ -445,8 +481,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
|
|||||||
error->done();
|
error->done();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if restartflag set, process 2 command and quit
|
// if restartflag set, invoke 2 commands and quit
|
||||||
// add args between wdfirst and wdlast to write_data
|
// add args between wdfirst and wdlast to write_data command
|
||||||
// also add "noinit" to prevent write_data from doing system init
|
// also add "noinit" to prevent write_data from doing system init
|
||||||
|
|
||||||
if (restartflag) {
|
if (restartflag) {
|
||||||
@ -487,6 +523,7 @@ LAMMPS::~LAMMPS()
|
|||||||
if (world != universe->uworld) MPI_Comm_free(&world);
|
if (world != universe->uworld) MPI_Comm_free(&world);
|
||||||
|
|
||||||
delete cuda;
|
delete cuda;
|
||||||
|
delete kokkos;
|
||||||
delete [] suffix;
|
delete [] suffix;
|
||||||
|
|
||||||
delete input;
|
delete input;
|
||||||
@ -556,6 +593,7 @@ void LAMMPS::post_create()
|
|||||||
void LAMMPS::init()
|
void LAMMPS::init()
|
||||||
{
|
{
|
||||||
if (cuda) cuda->accelerator(0,NULL);
|
if (cuda) cuda->accelerator(0,NULL);
|
||||||
|
if (kokkos) kokkos->accelerator(0,NULL);
|
||||||
|
|
||||||
update->init();
|
update->init();
|
||||||
force->init(); // pair must come after update due to minimizer
|
force->init(); // pair must come after update due to minimizer
|
||||||
@ -608,6 +646,7 @@ void LAMMPS::help()
|
|||||||
"-echo none/screen/log/both : echoing of input script (-e)\n"
|
"-echo none/screen/log/both : echoing of input script (-e)\n"
|
||||||
"-in filename : read input from file, not stdin (-i)\n"
|
"-in filename : read input from file, not stdin (-i)\n"
|
||||||
"-help : print this help message (-h)\n"
|
"-help : print this help message (-h)\n"
|
||||||
|
"-kokkos on/off ... : turn KOKKOS mode on or off (-k)\n"
|
||||||
"-log none/filename : where to send log output (-l)\n"
|
"-log none/filename : where to send log output (-l)\n"
|
||||||
"-nocite : disable writing log.cite file (-nc)\n"
|
"-nocite : disable writing log.cite file (-nc)\n"
|
||||||
"-partition size1 size2 ... : assign partition sizes (-p)\n"
|
"-partition size1 size2 ... : assign partition sizes (-p)\n"
|
||||||
|
|||||||
@ -45,7 +45,9 @@ class LAMMPS {
|
|||||||
char *suffix; // suffix to add to input script style names
|
char *suffix; // suffix to add to input script style names
|
||||||
int suffix_enable; // 1 if suffix enabled, 0 if disabled
|
int suffix_enable; // 1 if suffix enabled, 0 if disabled
|
||||||
int cite_enable; // 1 if generating log.cite, 0 if disabled
|
int cite_enable; // 1 if generating log.cite, 0 if disabled
|
||||||
|
|
||||||
class Cuda *cuda; // CUDA accelerator class
|
class Cuda *cuda; // CUDA accelerator class
|
||||||
|
class KokkosLMP *kokkos; // KOKKOS accelerator class
|
||||||
|
|
||||||
class CiteMe *citeme; // citation info
|
class CiteMe *citeme; // citation info
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user