alternate implementation of pair/only option (for KOKKOS and GPU)
This commit is contained in:
@ -120,6 +120,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
double binsize = 0.0;
|
double binsize = 0.0;
|
||||||
char *opencl_flags = nullptr;
|
char *opencl_flags = nullptr;
|
||||||
int block_pair = -1;
|
int block_pair = -1;
|
||||||
|
int pair_only_flag = 0;
|
||||||
|
|
||||||
int iarg = 4;
|
int iarg = 4;
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
@ -169,6 +170,12 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
|
||||||
block_pair = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
block_pair = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
} else if (strcmp(arg[iarg],"pair/only") == 0) {
|
||||||
|
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
|
||||||
|
if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0;
|
||||||
|
else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1;
|
||||||
|
else error->all(FLERR,"Illegal package gpu command");
|
||||||
|
iarg += 2;
|
||||||
} else error->all(FLERR,"Illegal package gpu command");
|
} else error->all(FLERR,"Illegal package gpu command");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +193,11 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (force->newton_pair || force->newton_bond) force->newton = 1;
|
if (force->newton_pair || force->newton_bond) force->newton = 1;
|
||||||
else force->newton = 0;
|
else force->newton = 0;
|
||||||
|
|
||||||
|
if (pair_only_flag) {
|
||||||
|
lmp->suffixp = lmp->suffix;
|
||||||
|
lmp->suffix = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// pass params to GPU library
|
// pass params to GPU library
|
||||||
// change binsize default (0.0) to -1.0 used by GPU lib
|
// change binsize default (0.0) to -1.0 used by GPU lib
|
||||||
|
|
||||||
|
|||||||
@ -301,6 +301,7 @@ KokkosLMP::~KokkosLMP()
|
|||||||
|
|
||||||
void KokkosLMP::accelerator(int narg, char **arg)
|
void KokkosLMP::accelerator(int narg, char **arg)
|
||||||
{
|
{
|
||||||
|
int pair_only_flag = 0;
|
||||||
int iarg = 0;
|
int iarg = 0;
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg],"neigh") == 0) {
|
if (strcmp(arg[iarg],"neigh") == 0) {
|
||||||
@ -390,6 +391,12 @@ void KokkosLMP::accelerator(int narg, char **arg)
|
|||||||
else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1;
|
else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1;
|
||||||
else error->all(FLERR,"Illegal package kokkos command");
|
else error->all(FLERR,"Illegal package kokkos command");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
} else if (strcmp(arg[iarg],"pair/only") == 0) {
|
||||||
|
if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command");
|
||||||
|
if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0;
|
||||||
|
else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1;
|
||||||
|
else error->all(FLERR,"Illegal package kokkos command");
|
||||||
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"neigh/thread") == 0) {
|
} else if (strcmp(arg[iarg],"neigh/thread") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command");
|
||||||
if (strcmp(arg[iarg+1],"off") == 0) neigh_thread = 0;
|
if (strcmp(arg[iarg+1],"off") == 0) neigh_thread = 0;
|
||||||
@ -452,6 +459,15 @@ void KokkosLMP::accelerator(int narg, char **arg)
|
|||||||
neighbor->binsize_user = binsize;
|
neighbor->binsize_user = binsize;
|
||||||
if (binsize <= 0.0) neighbor->binsizeflag = 0;
|
if (binsize <= 0.0) neighbor->binsizeflag = 0;
|
||||||
else neighbor->binsizeflag = 1;
|
else neighbor->binsizeflag = 1;
|
||||||
|
|
||||||
|
if (pair_only_flag) {
|
||||||
|
lmp->suffixp = lmp->suffix;
|
||||||
|
lmp->suffix = new char[7];
|
||||||
|
strcpy(lmp->suffix,"kk/host");
|
||||||
|
|
||||||
|
exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1;
|
||||||
|
exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -245,13 +245,22 @@ void Force::create_pair(const std::string &style, int trysuffix)
|
|||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
generate a pair class
|
generate a pair class
|
||||||
if trysuffix = 1, try first with suffix1/2 appended
|
if trysuffix = 1, try first with suffix1/2 appended
|
||||||
return sflag = 0 for no suffix added, 1 or 2 for suffix1/2 added
|
return sflag = 0 for no suffix added, 1 or 2 or 3 for suffix1/2/p added
|
||||||
|
special case: if suffixp exists only try suffixp, not suffix
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag)
|
Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag)
|
||||||
{
|
{
|
||||||
if (trysuffix && lmp->suffix_enable) {
|
if (trysuffix && lmp->suffix_enable) {
|
||||||
if (lmp->suffix) {
|
if (lmp->suffixp) {
|
||||||
|
sflag = 3;
|
||||||
|
std::string estyle = style + "/" + lmp->suffixp;
|
||||||
|
if (pair_map->find(estyle) != pair_map->end()) {
|
||||||
|
PairCreator &pair_creator = (*pair_map)[estyle];
|
||||||
|
return pair_creator(lmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lmp->suffix && !lmp->suffixp) {
|
||||||
sflag = 1;
|
sflag = 1;
|
||||||
std::string estyle = style + "/" + lmp->suffix;
|
std::string estyle = style + "/" + lmp->suffix;
|
||||||
if (pair_map->find(estyle) != pair_map->end()) {
|
if (pair_map->find(estyle) != pair_map->end()) {
|
||||||
@ -727,7 +736,7 @@ KSpace *Force::kspace_match(const std::string &word, int exact)
|
|||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
store style name in str allocated here
|
store style name in str allocated here
|
||||||
if sflag = 0, no suffix
|
if sflag = 0, no suffix
|
||||||
if sflag = 1/2, append suffix or suffix2 to style
|
if sflag = 1/2/3, append suffix or suffix2 or suffixp to style
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Force::store_style(char *&str, const std::string &style, int sflag)
|
void Force::store_style(char *&str, const std::string &style, int sflag)
|
||||||
@ -736,6 +745,7 @@ void Force::store_style(char *&str, const std::string &style, int sflag)
|
|||||||
|
|
||||||
if (sflag == 1) estyle += std::string("/") + lmp->suffix;
|
if (sflag == 1) estyle += std::string("/") + lmp->suffix;
|
||||||
else if (sflag == 2) estyle += std::string("/") + lmp->suffix2;
|
else if (sflag == 2) estyle += std::string("/") + lmp->suffix2;
|
||||||
|
else if (sflag == 3) estyle += std::string("/") + lmp->suffixp;
|
||||||
|
|
||||||
str = new char[estyle.size()+1];
|
str = new char[estyle.size()+1];
|
||||||
strcpy(str,estyle.c_str());
|
strcpy(str,estyle.c_str());
|
||||||
|
|||||||
@ -1715,7 +1715,10 @@ void Input::pair_style()
|
|||||||
int match = 0;
|
int match = 0;
|
||||||
if (style == force->pair_style) match = 1;
|
if (style == force->pair_style) match = 1;
|
||||||
if (!match && lmp->suffix_enable) {
|
if (!match && lmp->suffix_enable) {
|
||||||
if (lmp->suffix)
|
if (lmp->suffixp)
|
||||||
|
if (style + "/" + lmp->suffixp == force->pair_style) match = 1;
|
||||||
|
|
||||||
|
if (lmp->suffix && !lmp->suffixp)
|
||||||
if (style + "/" + lmp->suffix == force->pair_style) match = 1;
|
if (style + "/" + lmp->suffix == force->pair_style) match = 1;
|
||||||
|
|
||||||
if (lmp->suffix2)
|
if (lmp->suffix2)
|
||||||
|
|||||||
@ -173,7 +173,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
|
|||||||
int citeflag = 1;
|
int citeflag = 1;
|
||||||
int helpflag = 0;
|
int helpflag = 0;
|
||||||
|
|
||||||
suffix = suffix2 = nullptr;
|
suffix = suffix2 = suffixp = nullptr;
|
||||||
suffix_enable = 0;
|
suffix_enable = 0;
|
||||||
if (arg) exename = arg[0];
|
if (arg) exename = arg[0];
|
||||||
else exename = nullptr;
|
else exename = nullptr;
|
||||||
@ -714,6 +714,7 @@ LAMMPS::~LAMMPS()
|
|||||||
delete kokkos;
|
delete kokkos;
|
||||||
delete [] suffix;
|
delete [] suffix;
|
||||||
delete [] suffix2;
|
delete [] suffix2;
|
||||||
|
delete [] suffixp;
|
||||||
|
|
||||||
// free the MPI comm created by -mpi command-line arg processed in constructor
|
// free the MPI comm created by -mpi command-line arg processed in constructor
|
||||||
// it was passed to universe as if original universe world
|
// it was passed to universe as if original universe world
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class LAMMPS {
|
|||||||
|
|
||||||
double initclock; // wall clock at instantiation
|
double initclock; // wall clock at instantiation
|
||||||
|
|
||||||
char *suffix,*suffix2; // suffixes to add to input script style names
|
char *suffix,*suffix2,*suffixp;// suffixes to add to input script style names
|
||||||
int suffix_enable; // 1 if suffixes are enabled, 0 if disabled
|
int suffix_enable; // 1 if suffixes are enabled, 0 if disabled
|
||||||
char *exename; // pointer to argv[0]
|
char *exename; // pointer to argv[0]
|
||||||
char ***packargs; // arguments for cmdline package commands
|
char ***packargs; // arguments for cmdline package commands
|
||||||
|
|||||||
Reference in New Issue
Block a user