Fixing comm and renaming bytype

This commit is contained in:
Joel Clemmer
2020-11-09 16:32:11 -07:00
parent 557ef57526
commit 12288630f5
30 changed files with 98 additions and 63 deletions

View File

@ -76,7 +76,7 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp)
grid2proc = nullptr; grid2proc = nullptr;
xsplit = ysplit = zsplit = nullptr; xsplit = ysplit = zsplit = nullptr;
rcbnew = 0; rcbnew = 0;
multi_bytype = 0; multi_tiered = 0;
// use of OpenMP threads // use of OpenMP threads
// query OpenMP for number of threads/process set by user at run-time // query OpenMP for number of threads/process set by user at run-time
@ -241,6 +241,10 @@ void Comm::init()
maxexchange_fix_dynamic = 0; maxexchange_fix_dynamic = 0;
for (int i = 0; i < nfix; i++) for (int i = 0; i < nfix; i++)
if (fix[i]->maxexchange_dynamic) maxexchange_fix_dynamic = 1; if (fix[i]->maxexchange_dynamic) maxexchange_fix_dynamic = 1;
// Can't used multi/tiered communication with Newton off
if (force->newton == 0 && multi_tiered)
error->all(FLERR,"Cannot use multi/tiered communication with Newton off");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -327,10 +331,10 @@ void Comm::modify_params(int narg, char **arg)
for (i=nlo; i<=nhi; ++i) for (i=nlo; i<=nhi; ++i)
cutusermulti[i] = cut; cutusermulti[i] = cut;
iarg += 3; iarg += 3;
} else if (strcmp(arg[iarg],"cutoff/bytype") == 0) { } else if (strcmp(arg[iarg],"cutoff/tiered") == 0) {
if (mode == Comm::SINGLE) if (mode == Comm::SINGLE)
error->all(FLERR,"Use cutoff/bytype in mode multi only"); error->all(FLERR,"Use cutoff/tiered in mode multi only");
multi_bytype = 1; multi_tiered = 1;
iarg += 1; iarg += 1;
} else if (strcmp(arg[iarg],"vel") == 0) { } else if (strcmp(arg[iarg],"vel") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command"); if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command");

View File

@ -161,7 +161,7 @@ class Comm : protected Pointers {
int (*)(int, char *, int &, int *&, char *&, void *), int (*)(int, char *, int &, int *&, char *&, void *),
int, char *&, int, void *, int); int, char *&, int, void *, int);
void rendezvous_stats(int, int, int, int, int, int, bigint); void rendezvous_stats(int, int, int, int, int, int, bigint);
int multi_bytype; // 1 if multi cutoff is intra-type cutoff int multi_tiered; // 1 if multi cutoff is intra-type cutoff
public: public:
enum{MULTIPLE}; enum{MULTIPLE};
@ -247,6 +247,10 @@ E: Processor count in z must be 1 for 2d simulation
Self-explanatory. Self-explanatory.
E: Cannot use multi/tiered communication with Newton off
Self-explanatory.
E: Cannot put data on ring from nullptr pointer E: Cannot put data on ring from nullptr pointer
W: Communication cutoff is 0.0. No ghost atoms will be generated. Atoms may get lost. W: Communication cutoff is 0.0. No ghost atoms will be generated. Atoms may get lost.

View File

@ -174,18 +174,25 @@ void CommBrick::setup()
cutghost[0] = cutghost[1] = cutghost[2] = cut; cutghost[0] = cutghost[1] = cutghost[2] = cut;
if (mode == Comm::MULTI) { if (mode == Comm::MULTI) {
double *cuttype = neighbor->cuttype; if (multi_tiered) {
for (i = 1; i <= ntypes; i++) { // If using tiered binlists, use the itype-itype interaction distance for communication
cut = 0.0; double **cutneighsq = neighbor->cutneighsq;
if (cutusermulti) cut = cutusermulti[i]; for (i = 1; i <= ntypes; i++) {
cutghostmulti[i][0] = MAX(cut,cuttype[i]); cut = 0.0;
cutghostmulti[i][1] = MAX(cut,cuttype[i]); if (cutusermulti) cut = cutusermulti[i];
cutghostmulti[i][2] = MAX(cut,cuttype[i]); cutghostmulti[i][0] = MAX(cut,sqrt(cutneighsq[i][i]));
if (multi_bytype == 1) { cutghostmulti[i][1] = MAX(cut,sqrt(cutneighsq[i][i]));
// Set the BYTYPE cutoff cutghostmulti[i][2] = MAX(cut,sqrt(cutneighsq[i][i]));
cutghostmulti[i][0] = sqrt(neighbor->cutneighsq[i][i]); }
cutghostmulti[i][1] = sqrt(neighbor->cutneighsq[i][i]); } else {
cutghostmulti[i][2] = sqrt(neighbor->cutneighsq[i][i]); // If using a single binlist, use the max itype-jtype interaction distance for communication
double *cuttype = neighbor->cuttype;
for (i = 1; i <= ntypes; i++) {
cut = 0.0;
if (cutusermulti) cut = cutusermulti[i];
cutghostmulti[i][0] = MAX(cut,cuttype[i]);
cutghostmulti[i][1] = MAX(cut,cuttype[i]);
cutghostmulti[i][2] = MAX(cut,cuttype[i]);
} }
} }
} }
@ -204,13 +211,26 @@ void CommBrick::setup()
cutghost[2] = cut * length2; cutghost[2] = cut * length2;
if (mode == Comm::MULTI) { if (mode == Comm::MULTI) {
double *cuttype = neighbor->cuttype; if (multi_tiered) {
for (i = 1; i <= ntypes; i++) { // If using tiered binlists, use the itype-itype interaction distance for communication
cut = 0.0; double **cutneighsq = neighbor->cutneighsq;
if (cutusermulti) cut = cutusermulti[i]; for (i = 1; i <= ntypes; i++) {
cutghostmulti[i][0] = length0 * MAX(cut,cuttype[i]); cut = 0.0;
cutghostmulti[i][1] = length1 * MAX(cut,cuttype[i]); if (cutusermulti) cut = cutusermulti[i];
cutghostmulti[i][2] = length2 * MAX(cut,cuttype[i]); cutghostmulti[i][0] = length0 * MAX(cut,sqrt(cutneighsq[i][i]));
cutghostmulti[i][1] = length1 * MAX(cut,sqrt(cutneighsq[i][i]));
cutghostmulti[i][2] = length2 * MAX(cut,sqrt(cutneighsq[i][i]));
}
} else {
// If using a single binlist, use the max itype-jtype interaction distance for communication
double *cuttype = neighbor->cuttype;
for (i = 1; i <= ntypes; i++) {
cut = 0.0;
if (cutusermulti) cut = cutusermulti[i];
cutghostmulti[i][0] = length0 * MAX(cut,cuttype[i]);
cutghostmulti[i][1] = length1 * MAX(cut,cuttype[i]);
cutghostmulti[i][2] = length2 * MAX(cut,cuttype[i]);
}
} }
} }
} }

View File

@ -175,19 +175,26 @@ void CommTiled::setup()
// check that cutoff < any periodic box length // check that cutoff < any periodic box length
if (mode == Comm::MULTI) { if (mode == Comm::MULTI) {
double *cuttype = neighbor->cuttype;
double cut; double cut;
for (i = 1; i <= ntypes; i++) { if (multi_tiered) {
cut = 0.0; // If using tiered binlists, use the itype-itype interaction distance for communication
if (cutusermulti) cut = cutusermulti[i]; double **cutneighsq = neighbor->cutneighsq;
cutghostmulti[i][0] = MAX(cut,cuttype[i]); for (i = 1; i <= ntypes; i++) {
cutghostmulti[i][1] = MAX(cut,cuttype[i]); cut = 0.0;
cutghostmulti[i][2] = MAX(cut,cuttype[i]); if (cutusermulti) cut = cutusermulti[i];
if (multi_bytype == 1) { cutghostmulti[i][0] = MAX(cut,sqrt(cutneighsq[i][i]));
// Set the BYTYPE cutoff cutghostmulti[i][1] = MAX(cut,sqrt(cutneighsq[i][i]));
cutghostmulti[i][0] = sqrt(neighbor->cutneighsq[i][i]); cutghostmulti[i][2] = MAX(cut,sqrt(cutneighsq[i][i]));
cutghostmulti[i][1] = sqrt(neighbor->cutneighsq[i][i]); }
cutghostmulti[i][2] = sqrt(neighbor->cutneighsq[i][i]); } else {
// If using a single binlist, use the max itype-jtype interaction distance for communication
double *cuttype = neighbor->cuttype;
for (i = 1; i <= ntypes; i++) {
cut = 0.0;
if (cutusermulti) cut = cutusermulti[i];
cutghostmulti[i][0] = MAX(cut,cuttype[i]);
cutghostmulti[i][1] = MAX(cut,cuttype[i]);
cutghostmulti[i][2] = MAX(cut,cuttype[i]);
} }
} }
} }

View File

@ -1620,12 +1620,12 @@ int Neighbor::choose_bin(NeighRequest *rq)
if (!rq->kokkos_device != !(mask & NB_KOKKOS_DEVICE)) continue; if (!rq->kokkos_device != !(mask & NB_KOKKOS_DEVICE)) continue;
if (!rq->kokkos_host != !(mask & NB_KOKKOS_HOST)) continue; if (!rq->kokkos_host != !(mask & NB_KOKKOS_HOST)) continue;
// neighbor style is BIN or MULTI or BYTYPE and must match // neighbor style is BIN or MULTI or MULTI/TIERED and must match
if (style == Neighbor::BIN || style == Neighbor::MULTI) { if (style == Neighbor::BIN || style == Neighbor::MULTI) {
if (!(mask & NB_STANDARD)) continue; if (!(mask & NB_STANDARD)) continue;
} else if (style == Neighbor::BYTYPE) { } else if (style == Neighbor::MULTI_TIERED) {
if (!(mask & NB_BYTYPE)) continue; if (!(mask & NB_MULTI_TIERED)) continue;
} }
return i+1; return i+1;
@ -1698,14 +1698,14 @@ int Neighbor::choose_stencil(NeighRequest *rq)
if (!rq->ghost != !(mask & NS_GHOST)) continue; if (!rq->ghost != !(mask & NS_GHOST)) continue;
if (!rq->ssa != !(mask & NS_SSA)) continue; if (!rq->ssa != !(mask & NS_SSA)) continue;
// neighbor style is one of BIN, MULTI or BYTYPE and must match // neighbor style is one of BIN, MULTI, or MULT/TIERED and must match
if (style == Neighbor::BIN) { if (style == Neighbor::BIN) {
if (!(mask & NS_BIN)) continue; if (!(mask & NS_BIN)) continue;
} else if (style == Neighbor::MULTI) { } else if (style == Neighbor::MULTI) {
if (!(mask & NS_MULTI)) continue; if (!(mask & NS_MULTI)) continue;
} else if (style == Neighbor::BYTYPE) { } else if (style == Neighbor::MULT_TIERED) {
if (!(mask & NS_BYTYPE)) continue; if (!(mask & NS_MULT_TIERED)) continue;
} }
// dimension is 2 or 3 and must match // dimension is 2 or 3 and must match
@ -1835,7 +1835,7 @@ int Neighbor::choose_pair(NeighRequest *rq)
if (!rq->halffull != !(mask & NP_HALF_FULL)) continue; if (!rq->halffull != !(mask & NP_HALF_FULL)) continue;
if (!rq->off2on != !(mask & NP_OFF2ON)) continue; if (!rq->off2on != !(mask & NP_OFF2ON)) continue;
// neighbor style is one of NSQ,BIN,MULTI or BYTYPE and must match // neighbor style is one of NSQ, BIN, MULTI, or MULTI/TIERED and must match
if (style == Neighbor::NSQ) { if (style == Neighbor::NSQ) {
if (!(mask & NP_NSQ)) continue; if (!(mask & NP_NSQ)) continue;
@ -1843,8 +1843,8 @@ int Neighbor::choose_pair(NeighRequest *rq)
if (!(mask & NP_BIN)) continue; if (!(mask & NP_BIN)) continue;
} else if (style == Neighbor::MULTI) { } else if (style == Neighbor::MULTI) {
if (!(mask & NP_MULTI)) continue; if (!(mask & NP_MULTI)) continue;
} else if (style == Neighbor::BYTYPE) { } else if (style == Neighbor::MULT_TIERED) {
if (!(mask & NP_BYTYPE)) continue; if (!(mask & NP_MULT_TIERED)) continue;
} }
// domain triclinic flag is on or off and must match // domain triclinic flag is on or off and must match
@ -2211,7 +2211,7 @@ void Neighbor::set(int narg, char **arg)
if (strcmp(arg[1],"nsq") == 0) style = Neighbor::NSQ; if (strcmp(arg[1],"nsq") == 0) style = Neighbor::NSQ;
else if (strcmp(arg[1],"bin") == 0) style = Neighbor::BIN; else if (strcmp(arg[1],"bin") == 0) style = Neighbor::BIN;
else if (strcmp(arg[1],"multi") == 0) style = Neighbor::MULTI; else if (strcmp(arg[1],"multi") == 0) style = Neighbor::MULTI;
else if (strcmp(arg[1],"bytype") == 0) style = Neighbor::BYTYPE; else if (strcmp(arg[1],"multi/tiered") == 0) style = Neighbor::MULT_TIERED;
else error->all(FLERR,"Illegal neighbor command"); else error->all(FLERR,"Illegal neighbor command");
if (style == Neighbor::MULTI && lmp->citeme) lmp->citeme->add(cite_neigh_multi); if (style == Neighbor::MULTI && lmp->citeme) lmp->citeme->add(cite_neigh_multi);

View File

@ -20,7 +20,7 @@ namespace LAMMPS_NS {
class Neighbor : protected Pointers { class Neighbor : protected Pointers {
public: public:
enum{NSQ,BIN,MULTI,BYTYPE}; enum{NSQ,BIN,MULTI,MULTI_TIERED};
int style; // 0,1,2 = nsq, bin, multi int style; // 0,1,2 = nsq, bin, multi
int every; // build every this many steps int every; // build every this many steps
int delay; // delay build for this many steps int delay; // delay build for this many steps
@ -239,22 +239,22 @@ namespace NeighConst {
static const int NB_KOKKOS_DEVICE = 1<<1; static const int NB_KOKKOS_DEVICE = 1<<1;
static const int NB_KOKKOS_HOST = 1<<2; static const int NB_KOKKOS_HOST = 1<<2;
static const int NB_SSA = 1<<3; static const int NB_SSA = 1<<3;
static const int NB_BYTYPE = 1<<4; static const int NB_MULTI_TIERED = 1<<4;
static const int NB_STANDARD = 1<<5; static const int NB_STANDARD = 1<<5;
static const int NS_BIN = 1<<0; static const int NS_BIN = 1<<0;
static const int NS_MULTI = 1<<1; static const int NS_MULTI = 1<<1;
static const int NS_HALF = 1<<2; static const int NS_HALF = 1<<2;
static const int NS_FULL = 1<<3; static const int NS_FULL = 1<<3;
static const int NS_2D = 1<<4; static const int NS_2D = 1<<4;
static const int NS_3D = 1<<5; static const int NS_3D = 1<<5;
static const int NS_NEWTON = 1<<6; static const int NS_NEWTON = 1<<6;
static const int NS_NEWTOFF = 1<<7; static const int NS_NEWTOFF = 1<<7;
static const int NS_ORTHO = 1<<8; static const int NS_ORTHO = 1<<8;
static const int NS_TRI = 1<<9; static const int NS_TRI = 1<<9;
static const int NS_GHOST = 1<<10; static const int NS_GHOST = 1<<10;
static const int NS_SSA = 1<<11; static const int NS_SSA = 1<<11;
static const int NS_BYTYPE = 1<<12; static const int NS_MULTI_TIERED = 1<<12;
static const int NP_NSQ = 1<<0; static const int NP_NSQ = 1<<0;
static const int NP_BIN = 1<<1; static const int NP_BIN = 1<<1;
@ -281,7 +281,7 @@ namespace NeighConst {
static const int NP_SKIP = 1<<22; static const int NP_SKIP = 1<<22;
static const int NP_HALF_FULL = 1<<23; static const int NP_HALF_FULL = 1<<23;
static const int NP_OFF2ON = 1<<24; static const int NP_OFF2ON = 1<<24;
static const int NP_BYTYPE = 1<<25; static const int NP_MULTI_TIERED = 1<<25;
} }
} }