remove cached copy of "layout" since this was not always initialized when used

This commit is contained in:
Axel Kohlmeyer
2023-12-22 11:31:31 -05:00
parent c4124c0995
commit efa37fff7f
5 changed files with 20 additions and 34 deletions

View File

@ -640,7 +640,7 @@ void Grid3dKokkos<DeviceType>::forward_comm(int caller, void *ptr, int which, in
MPI_Datatype datatype) MPI_Datatype datatype)
{ {
if (caller == KSPACE) { if (caller == KSPACE) {
if (layout != Comm::LAYOUT_TILED) if (comm->layout != Comm::LAYOUT_TILED)
forward_comm_kspace_brick((KSpace *) ptr,which,nper,k_buf1,k_buf2,datatype); forward_comm_kspace_brick((KSpace *) ptr,which,nper,k_buf1,k_buf2,datatype);
else else
forward_comm_kspace_tiled((KSpace *) ptr,which,nper,k_buf1,k_buf2,datatype); forward_comm_kspace_tiled((KSpace *) ptr,which,nper,k_buf1,k_buf2,datatype);
@ -780,7 +780,7 @@ void Grid3dKokkos<DeviceType>::reverse_comm(int caller, void *ptr, int which, in
MPI_Datatype datatype) MPI_Datatype datatype)
{ {
if (caller == KSPACE) { if (caller == KSPACE) {
if (layout != Comm::LAYOUT_TILED) if (comm->layout != Comm::LAYOUT_TILED)
reverse_comm_kspace_brick((KSpace *) ptr,which,nper,k_buf1,k_buf2,datatype); reverse_comm_kspace_brick((KSpace *) ptr,which,nper,k_buf1,k_buf2,datatype);
else else
reverse_comm_kspace_tiled((KSpace *) ptr,which,nper,k_buf1,k_buf2,datatype); reverse_comm_kspace_tiled((KSpace *) ptr,which,nper,k_buf1,k_buf2,datatype);

View File

@ -114,7 +114,7 @@ Grid2d::Grid2d(LAMMPS *lmp, MPI_Comm gcomm, int gnx, int gny, int ixlo, int ixhi
// additional intialization // additional intialization
// other constructor invokes this from setup_grid() // other constructor invokes this from setup_grid()
initialize(); Grid2d::initialize();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -522,7 +522,7 @@ void Grid2d::ghost_grid()
// also ensure no other procs use ghost cells beyond +y limit // also ensure no other procs use ghost cells beyond +y limit
if (yextra) { if (yextra) {
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
if (comm->myloc[1] == comm->procgrid[1]-1) inyhi = outyhi = ny - 1; if (comm->myloc[1] == comm->procgrid[1]-1) inyhi = outyhi = ny - 1;
} else { } else {
if (comm->mysplit[1][1] == 1.0) inyhi = outyhi = ny - 1; if (comm->mysplit[1][1] == 1.0) inyhi = outyhi = ny - 1;
@ -553,15 +553,13 @@ void Grid2d::ghost_grid()
void Grid2d::extract_comm_info() void Grid2d::extract_comm_info()
{ {
layout = comm->layout;
// for non TILED layout: // for non TILED layout:
// proc xyz lohi = my 4 neighbor procs in this MPI_Comm // proc xyz lohi = my 4 neighbor procs in this MPI_Comm
// these proc IDs can be overridden by caller using set_proc_neighs() // these proc IDs can be overridden by caller using set_proc_neighs()
// xyz split = copy of 1d vectors in Comm // xyz split = copy of 1d vectors in Comm
// grid2proc = copy of 3d array in Comm // grid2proc = copy of 3d array in Comm
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
procxlo = comm->procneigh[0][0]; procxlo = comm->procneigh[0][0];
procxhi = comm->procneigh[0][1]; procxhi = comm->procneigh[0][1];
procylo = comm->procneigh[1][0]; procylo = comm->procneigh[1][0];
@ -585,7 +583,7 @@ void Grid2d::extract_comm_info()
// RCBinfo.cut = this proc's inlo in that dim // RCBinfo.cut = this proc's inlo in that dim
// Allgather creates the tree of dims and cuts // Allgather creates the tree of dims and cuts
if (layout == Comm::LAYOUT_TILED) { if (comm->layout == Comm::LAYOUT_TILED) {
rcbinfo = (RCBinfo *) rcbinfo = (RCBinfo *)
memory->smalloc(nprocs*sizeof(RCBinfo),"grid3d:rcbinfo"); memory->smalloc(nprocs*sizeof(RCBinfo),"grid3d:rcbinfo");
RCBinfo rcbone; RCBinfo rcbone;
@ -615,7 +613,7 @@ void Grid2d::extract_comm_info()
void Grid2d::setup_comm(int &nbuf1, int &nbuf2) void Grid2d::setup_comm(int &nbuf1, int &nbuf2)
{ {
if (layout != Comm::LAYOUT_TILED) setup_comm_brick(nbuf1,nbuf2); if (comm->layout != Comm::LAYOUT_TILED) setup_comm_brick(nbuf1,nbuf2);
else setup_comm_tiled(nbuf1,nbuf2); else setup_comm_tiled(nbuf1,nbuf2);
} }
@ -1039,7 +1037,7 @@ void Grid2d::setup_comm_tiled(int &nbuf1, int &nbuf2)
int Grid2d::ghost_adjacent() int Grid2d::ghost_adjacent()
{ {
if (layout != Comm::LAYOUT_TILED) return ghost_adjacent_brick(); if (comm->layout != Comm::LAYOUT_TILED) return ghost_adjacent_brick();
return ghost_adjacent_tiled(); return ghost_adjacent_tiled();
} }
@ -1085,7 +1083,7 @@ int Grid2d::ghost_adjacent_tiled()
void Grid2d::forward_comm(int caller, void *ptr, int which, int nper, int nbyte, void Grid2d::forward_comm(int caller, void *ptr, int which, int nper, int nbyte,
void *buf1, void *buf2, MPI_Datatype datatype) void *buf1, void *buf2, MPI_Datatype datatype)
{ {
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
if (caller == KSPACE) if (caller == KSPACE)
forward_comm_brick<KSpace>((KSpace *) ptr,which,nper,nbyte, forward_comm_brick<KSpace>((KSpace *) ptr,which,nper,nbyte,
buf1,buf2,datatype); buf1,buf2,datatype);
@ -1190,7 +1188,7 @@ forward_comm_tiled(T *ptr, int which, int nper, int nbyte,
void Grid2d::reverse_comm(int caller, void *ptr, int which, int nper, int nbyte, void Grid2d::reverse_comm(int caller, void *ptr, int which, int nper, int nbyte,
void *buf1, void *buf2, MPI_Datatype datatype) void *buf1, void *buf2, MPI_Datatype datatype)
{ {
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
if (caller == KSPACE) if (caller == KSPACE)
reverse_comm_brick<KSpace>((KSpace *) ptr,which,nper,nbyte, reverse_comm_brick<KSpace>((KSpace *) ptr,which,nper,nbyte,
buf1,buf2,datatype); buf1,buf2,datatype);
@ -1314,10 +1312,6 @@ void Grid2d::setup_remap(Grid2d *old, int &nremap_buf1, int &nremap_buf2)
deallocate_remap(); deallocate_remap();
// set layout to current Comm layout
layout = comm->layout;
// overlaps of my old decomp owned box with all owned boxes in new decomp // overlaps of my old decomp owned box with all owned boxes in new decomp
// noverlap_old = # of overlaps, including self // noverlap_old = # of overlaps, including self
// overlap_old = vector of overlap info in Overlap data struct // overlap_old = vector of overlap info in Overlap data struct
@ -1654,7 +1648,7 @@ int Grid2d::compute_overlap(int ghostflag, int *box, int *pbc, Overlap *&overlap
// test obox against appropriate layout // test obox against appropriate layout
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
// find comm->procgrid indices in each dim for box bounds // find comm->procgrid indices in each dim for box bounds

View File

@ -55,7 +55,6 @@ class Grid2d : protected Pointers {
protected: protected:
int me, nprocs; int me, nprocs;
int layout; // not TILED or TILED, same as Comm class
MPI_Comm gridcomm; // communicator for this class MPI_Comm gridcomm; // communicator for this class
// usually world, but MSM calls with subset // usually world, but MSM calls with subset

View File

@ -123,7 +123,7 @@ Grid3d::Grid3d(LAMMPS *lmp, MPI_Comm gcomm, int gnx, int gny, int gnz,
// additional intialization // additional intialization
// other constructor invokes this from setup_grid() // other constructor invokes this from setup_grid()
initialize(); Grid3d::initialize();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -577,7 +577,7 @@ void Grid3d::ghost_grid()
// also ensure no other procs use ghost cells beyond +z limit // also ensure no other procs use ghost cells beyond +z limit
if (zextra) { if (zextra) {
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
if (comm->myloc[2] == comm->procgrid[2]-1) inzhi = outzhi = nz - 1; if (comm->myloc[2] == comm->procgrid[2]-1) inzhi = outzhi = nz - 1;
} else { } else {
if (comm->mysplit[2][1] == 1.0) inzhi = outzhi = nz - 1; if (comm->mysplit[2][1] == 1.0) inzhi = outzhi = nz - 1;
@ -613,15 +613,13 @@ void Grid3d::ghost_grid()
void Grid3d::extract_comm_info() void Grid3d::extract_comm_info()
{ {
layout = comm->layout;
// for non TILED layout: // for non TILED layout:
// proc xyz lohi = my 6 neighbor procs in this MPI_Comm // proc xyz lohi = my 6 neighbor procs in this MPI_Comm
// these proc IDs can be overridden by caller using set_proc_neighs() // these proc IDs can be overridden by caller using set_proc_neighs()
// xyz split = copy of 1d vectors in Comm // xyz split = copy of 1d vectors in Comm
// grid2proc = copy of 3d array in Comm // grid2proc = copy of 3d array in Comm
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
procxlo = comm->procneigh[0][0]; procxlo = comm->procneigh[0][0];
procxhi = comm->procneigh[0][1]; procxhi = comm->procneigh[0][1];
procylo = comm->procneigh[1][0]; procylo = comm->procneigh[1][0];
@ -649,7 +647,7 @@ void Grid3d::extract_comm_info()
// RCBinfo.cut = this proc's inlo in that dim // RCBinfo.cut = this proc's inlo in that dim
// Allgather creates the tree of dims and cuts // Allgather creates the tree of dims and cuts
if (layout == Comm::LAYOUT_TILED) { if (comm->layout == Comm::LAYOUT_TILED) {
rcbinfo = (RCBinfo *) rcbinfo = (RCBinfo *)
memory->smalloc(nprocs*sizeof(RCBinfo),"grid3d:rcbinfo"); memory->smalloc(nprocs*sizeof(RCBinfo),"grid3d:rcbinfo");
RCBinfo rcbone; RCBinfo rcbone;
@ -680,7 +678,7 @@ void Grid3d::extract_comm_info()
void Grid3d::setup_comm(int &nbuf1, int &nbuf2) void Grid3d::setup_comm(int &nbuf1, int &nbuf2)
{ {
if (layout != Comm::LAYOUT_TILED) setup_comm_brick(nbuf1,nbuf2); if (comm->layout != Comm::LAYOUT_TILED) setup_comm_brick(nbuf1,nbuf2);
else setup_comm_tiled(nbuf1,nbuf2); else setup_comm_tiled(nbuf1,nbuf2);
} }
@ -1207,7 +1205,7 @@ void Grid3d::setup_comm_tiled(int &nbuf1, int &nbuf2)
int Grid3d::ghost_adjacent() int Grid3d::ghost_adjacent()
{ {
if (layout != Comm::LAYOUT_TILED) return ghost_adjacent_brick(); if (comm->layout != Comm::LAYOUT_TILED) return ghost_adjacent_brick();
return ghost_adjacent_tiled(); return ghost_adjacent_tiled();
} }
@ -1255,7 +1253,7 @@ int Grid3d::ghost_adjacent_tiled()
void Grid3d::forward_comm(int caller, void *ptr, int which, int nper, int nbyte, void Grid3d::forward_comm(int caller, void *ptr, int which, int nper, int nbyte,
void *buf1, void *buf2, MPI_Datatype datatype) void *buf1, void *buf2, MPI_Datatype datatype)
{ {
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
if (caller == KSPACE) if (caller == KSPACE)
forward_comm_brick<KSpace>((KSpace *) ptr,which,nper,nbyte, forward_comm_brick<KSpace>((KSpace *) ptr,which,nper,nbyte,
buf1,buf2,datatype); buf1,buf2,datatype);
@ -1360,7 +1358,7 @@ forward_comm_tiled(T *ptr, int which, int nper, int nbyte,
void Grid3d::reverse_comm(int caller, void *ptr, int which, int nper, int nbyte, void Grid3d::reverse_comm(int caller, void *ptr, int which, int nper, int nbyte,
void *buf1, void *buf2, MPI_Datatype datatype) void *buf1, void *buf2, MPI_Datatype datatype)
{ {
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
if (caller == KSPACE) if (caller == KSPACE)
reverse_comm_brick<KSpace>((KSpace *) ptr,which,nper,nbyte, reverse_comm_brick<KSpace>((KSpace *) ptr,which,nper,nbyte,
buf1,buf2,datatype); buf1,buf2,datatype);
@ -1484,10 +1482,6 @@ void Grid3d::setup_remap(Grid3d *old, int &nremap_buf1, int &nremap_buf2)
deallocate_remap(); deallocate_remap();
// set layout to current Comm layout
layout = comm->layout;
// overlaps of my old decomp owned box with all owned boxes in new decomp // overlaps of my old decomp owned box with all owned boxes in new decomp
// noverlap_old = # of overlaps, including self // noverlap_old = # of overlaps, including self
// overlap_old = vector of overlap info in Overlap data struct // overlap_old = vector of overlap info in Overlap data struct
@ -1829,7 +1823,7 @@ int Grid3d::compute_overlap(int ghostflag, int *box, int *pbc, Overlap *&overlap
return noverlap_list; return noverlap_list;
} }
if (layout != Comm::LAYOUT_TILED) { if (comm->layout != Comm::LAYOUT_TILED) {
// find comm->procgrid indices in each dim for box bounds // find comm->procgrid indices in each dim for box bounds

View File

@ -57,7 +57,6 @@ class Grid3d : protected Pointers {
protected: protected:
int me, nprocs; int me, nprocs;
int layout; // not TILED or TILED, same as Comm class
MPI_Comm gridcomm; // communicator for this class MPI_Comm gridcomm; // communicator for this class
// usually world, but MSM calls with subset // usually world, but MSM calls with subset