diff --git a/src/comm.cpp b/src/comm.cpp index 73a1ac3d03..19281f98f8 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -66,6 +66,7 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp) MPI_Comm_size(world,&nprocs); user_procgrid[0] = user_procgrid[1] = user_procgrid[2] = 0; + coregrid[0] = coregrid[1] = coregrid[2] = 1; gridflag = ONELEVEL; mapflag = CART; customfile = NULL; @@ -153,10 +154,16 @@ void Comm::set_proc_grid() if (recv_from_partition >= 0) { MPI_Status status; - if (me == 0) MPI_Recv(other_procgrid,3,MPI_INT, - universe->root_proc[recv_from_partition],0, - universe->uworld,&status); + if (me == 0) { + MPI_Recv(other_procgrid,3,MPI_INT, + universe->root_proc[recv_from_partition],0, + universe->uworld,&status); + MPI_Recv(other_coregrid,3,MPI_INT, + universe->root_proc[recv_from_partition],0, + universe->uworld,&status); + } MPI_Bcast(other_procgrid,3,MPI_INT,0,world); + MPI_Bcast(other_coregrid,3,MPI_INT,0,world); } // create ProcMap class to create 3d grid and map procs to it @@ -168,12 +175,12 @@ void Comm::set_proc_grid() if (gridflag == ONELEVEL) { pmap->onelevel_grid(nprocs,user_procgrid,procgrid, - otherflag,other_style,other_procgrid); + otherflag,other_style,other_procgrid,other_coregrid); } else if (gridflag == TWOLEVEL) { pmap->twolevel_grid(nprocs,user_procgrid,procgrid, ncores,user_coregrid,coregrid, - otherflag,other_style,other_procgrid); + otherflag,other_style,other_procgrid,other_coregrid); } else if (gridflag == NUMA) { pmap->numa_grid(nprocs,user_procgrid,procgrid,coregrid); @@ -215,8 +222,6 @@ void Comm::set_proc_grid() else if (mapflag == XYZ) pmap->xyz_map(xyz,procgrid,ncores,coregrid,myloc,procneigh,grid2proc); - // printf("AAA %d: %d %d: %d %d: %d %d\n",); - } else if (gridflag == NUMA) { pmap->numa_map(0,coregrid,myloc,procneigh,grid2proc); @@ -258,9 +263,14 @@ void Comm::set_proc_grid() // send my 3d proc grid to another partition if requested if (send_to_partition >= 0) { - if (me == 0) MPI_Send(procgrid,3,MPI_INT, - universe->root_proc[send_to_partition],0, - universe->uworld); + if (me == 0) { + MPI_Send(procgrid,3,MPI_INT, + universe->root_proc[send_to_partition],0, + universe->uworld); + MPI_Send(coregrid,3,MPI_INT, + universe->root_proc[send_to_partition],0, + universe->uworld); + } } } diff --git a/src/comm.h b/src/comm.h index 55633db9b9..563ff48fbb 100644 --- a/src/comm.h +++ b/src/comm.h @@ -92,6 +92,7 @@ class Comm : protected Pointers { int otherflag; // 1 if this partition dependent on another int other_style; // style of dependency int other_procgrid[3]; // proc layout of another partition + int other_coregrid[3]; // core layout of another partition int ncores; // # of cores per node int coregrid[3]; // 3d grid of cores within a node int user_coregrid[3]; // user request for cores in each dim diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 7382ec084c..85f65a6523 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -120,8 +120,8 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) : format_default[0] = '\0'; for (int i = 0; i < size_one; i++) { - if (vtype[i] == INT) format_default = strcat(format_default,"%d "); - else if (vtype[i] == DOUBLE) format_default = strcat(format_default,"%g "); + if (vtype[i] == INT) strcat(format_default,"%d "); + else if (vtype[i] == DOUBLE) strcat(format_default,"%g "); else if (vtype[i] == STRING) strcat(format_default,"%s "); vformat[i] = NULL; } @@ -1306,14 +1306,16 @@ int DumpCustom::modify_param(int narg, char **arg) if (strcmp(arg[1],"none") == 0) iregion = -1; else { iregion = domain->find_region(arg[1]); - if (iregion == -1) error->all(FLERR,"Dump_modify region ID does not exist"); + if (iregion == -1) + error->all(FLERR,"Dump_modify region ID does not exist"); int n = strlen(arg[1]) + 1; idregion = new char[n]; strcpy(idregion,arg[1]); } return 2; - - } else if (strcmp(arg[0],"element") == 0) { + } + + if (strcmp(arg[0],"element") == 0) { if (narg < ntypes+1) error->all(FLERR,"Dump modify element names do not match atom types"); @@ -1330,8 +1332,9 @@ int DumpCustom::modify_param(int narg, char **arg) strcpy(typenames[itype],arg[itype]); } return ntypes+1; + } - } else if (strcmp(arg[0],"thresh") == 0) { + if (strcmp(arg[0],"thresh") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); if (strcmp(arg[1],"none") == 0) { if (nthresh) { @@ -1345,7 +1348,7 @@ int DumpCustom::modify_param(int narg, char **arg) nthresh = 0; return 2; } - + if (narg < 4) error->all(FLERR,"Illegal dump_modify command"); // grow threshhold arrays @@ -1462,13 +1465,16 @@ int DumpCustom::modify_param(int narg, char **arg) if (n < 0) error->all(FLERR,"Could not find dump modify compute ID"); if (modify->compute[n]->peratom_flag == 0) - error->all(FLERR,"Dump modify compute ID does not compute per-atom info"); + error->all(FLERR, + "Dump modify compute ID does not compute per-atom info"); if (argindex[nfield+nthresh] == 0 && modify->compute[n]->size_peratom_cols > 0) - error->all(FLERR,"Dump modify compute ID does not compute per-atom vector"); + error->all(FLERR, + "Dump modify compute ID does not compute per-atom vector"); if (argindex[nfield+nthresh] > 0 && modify->compute[n]->size_peratom_cols == 0) - error->all(FLERR,"Dump modify compute ID does not compute per-atom array"); + error->all(FLERR, + "Dump modify compute ID does not compute per-atom array"); if (argindex[nfield+nthresh] > 0 && argindex[nfield+nthresh] > modify->compute[n]->size_peratom_cols) error->all(FLERR,"Dump modify compute ID vector is not large enough"); diff --git a/src/input.cpp b/src/input.cpp index f04717e523..b409f916d4 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1327,7 +1327,9 @@ void Input::suffix() void Input::thermo() { if (narg != 1) error->all(FLERR,"Illegal thermo command"); - output->thermo_every = atoi(arg[0]); + int n = atoi(arg[0]); + if (n < 0) error->all(FLERR,"Illegal thermo command"); + output->thermo_every = n; } /* ---------------------------------------------------------------------- */ diff --git a/src/output.cpp b/src/output.cpp index 50a7cc008b..e2921e4871 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -38,9 +38,6 @@ using namespace LAMMPS_NS; #define DELTA 1 -#define MYMIN(a,b) ((a) < (b) ? (a) : (b)) -#define MYMAX(a,b) ((a) > (b) ? (a) : (b)) - /* ---------------------------------------------------------------------- initialize all output ------------------------------------------------------------------------- */ @@ -187,7 +184,7 @@ void Output::setup(int flag) if (writeflag) modify->addstep_compute(next_dump[idump]); else modify->addstep_compute_all(next_dump[idump]); } - if (idump) next_dump_any = MYMIN(next_dump_any,next_dump[idump]); + if (idump) next_dump_any = MIN(next_dump_any,next_dump[idump]); else next_dump_any = next_dump[0]; } } else next_dump_any = update->laststep + 1; @@ -218,7 +215,7 @@ void Output::setup(int flag) if (thermo_every) { next_thermo = (ntimestep/thermo_every)*thermo_every + thermo_every; - next_thermo = MYMIN(next_thermo,update->laststep); + next_thermo = MIN(next_thermo,update->laststep); } else if (var_thermo) { next_thermo = static_cast (input->variable->compute_equal(ivar_thermo)); @@ -230,8 +227,8 @@ void Output::setup(int flag) // next = next timestep any output will be done - next = MYMIN(next_dump_any,next_restart); - next = MYMIN(next,next_thermo); + next = MIN(next_dump_any,next_restart); + next = MIN(next,next_thermo); } /* ---------------------------------------------------------------------- @@ -265,7 +262,7 @@ void Output::write(bigint ntimestep) } if (dump[idump]->clearstep) modify->addstep_compute(next_dump[idump]); } - if (idump) next_dump_any = MYMIN(next_dump_any,next_dump[idump]); + if (idump) next_dump_any = MIN(next_dump_any,next_dump[idump]); else next_dump_any = next_dump[0]; } } @@ -311,14 +308,14 @@ void Output::write(bigint ntimestep) if (next_thermo <= ntimestep) error->all(FLERR,"Thermo every variable returned a bad timestep"); } else next_thermo = update->laststep; - next_thermo = MYMIN(next_thermo,update->laststep); + next_thermo = MIN(next_thermo,update->laststep); modify->addstep_compute(next_thermo); } // next = next timestep any output will be done - next = MYMIN(next_dump_any,next_restart); - next = MYMIN(next,next_thermo); + next = MIN(next_dump_any,next_restart); + next = MIN(next,next_thermo); } /* ---------------------------------------------------------------------- @@ -369,7 +366,8 @@ void Output::add_dump(int narg, char **arg) // error checks for (int idump = 0; idump < ndump; idump++) - if (strcmp(arg[0],dump[idump]->id) == 0) error->all(FLERR,"Reuse of dump ID"); + if (strcmp(arg[0],dump[idump]->id) == 0) + error->all(FLERR,"Reuse of dump ID"); int igroup = group->find(arg[1]); if (igroup == -1) error->all(FLERR,"Could not find dump group ID"); if (atoi(arg[3]) <= 0) error->all(FLERR,"Invalid dump frequency"); diff --git a/src/procmap.cpp b/src/procmap.cpp index 8fa1bd8f1b..18e740673c 100644 --- a/src/procmap.cpp +++ b/src/procmap.cpp @@ -41,7 +41,7 @@ ProcMap::ProcMap(LAMMPS *lmp) : Pointers(lmp) {} void ProcMap::onelevel_grid(int nprocs, int *user_procgrid, int *procgrid, int otherflag, int other_style, - int *other_procgrid) + int *other_procgrid, int *other_coregrid) { int **factors; @@ -56,7 +56,8 @@ void ProcMap::onelevel_grid(int nprocs, int *user_procgrid, int *procgrid, if (domain->dimension == 2) npossible = cull_2d(npossible,factors,3); npossible = cull_user(npossible,factors,3,user_procgrid); if (otherflag) npossible = cull_other(npossible,factors,3, - other_style,other_procgrid); + other_style,other_procgrid, + other_coregrid); // user/other constraints make failure possible @@ -79,7 +80,7 @@ void ProcMap::onelevel_grid(int nprocs, int *user_procgrid, int *procgrid, void ProcMap::twolevel_grid(int nprocs, int *user_procgrid, int *procgrid, int ncores, int *user_coregrid, int *coregrid, int otherflag, int other_style, - int *other_procgrid) + int *other_procgrid, int *other_coregrid) { int **nfactors,**cfactors,**factors; @@ -116,7 +117,8 @@ void ProcMap::twolevel_grid(int nprocs, int *user_procgrid, int *procgrid, npossible = cull_user(npossible,factors,4,user_procgrid); if (otherflag) npossible = cull_other(npossible,factors,4, - other_style,other_procgrid); + other_style,other_procgrid, + other_coregrid); // user/other constraints make failure possible @@ -796,19 +798,21 @@ int ProcMap::cull_user(int n, int **factors, int m, int *user_factors) /* ---------------------------------------------------------------------- remove any factors that do not match settings from other partition - MULTIPLE = other Px,Py,Pz must be multiple of my Px,Py,Pz + MULTIPLE = other Nx,Ny,Nz must be multiple of my Px,Py,Pz + where Nx,Ny,Nz = node grid = procgrid/coregrid ------------------------------------------------------------------------- */ int ProcMap::cull_other(int n, int **factors, int m, - int other_style, int *other_grid) + int other_style, int *other_procgrid, + int *other_coregrid) { int i = 0; while (i < n) { if (other_style == MULTIPLE) { int flag = 0; - if (other_grid[0] % factors[i][0]) flag = 1; - if (other_grid[1] % factors[i][1]) flag = 1; - if (other_grid[2] % factors[i][2]) flag = 1; + if ((other_procgrid[0]/other_coregrid[0]) % factors[i][0]) flag = 1; + if ((other_procgrid[1]/other_coregrid[1]) % factors[i][1]) flag = 1; + if ((other_procgrid[2]/other_coregrid[2]) % factors[i][2]) flag = 1; if (flag) { for (int j = 0; j < m; j++) factors[i][j] = factors[n-1][j]; n--; diff --git a/src/procmap.h b/src/procmap.h index f4f98f43d0..1a4159e09a 100644 --- a/src/procmap.h +++ b/src/procmap.h @@ -22,8 +22,9 @@ class ProcMap : protected Pointers { public: ProcMap(class LAMMPS *); ~ProcMap() {} - void onelevel_grid(int, int *, int *, int, int, int *); - void twolevel_grid(int, int *, int *, int, int *, int *, int, int, int *); + void onelevel_grid(int, int *, int *, int, int, int *, int *); + void twolevel_grid(int, int *, int *, int, int *, int *, int, int, + int *, int *); void numa_grid(int, int *, int *, int *); void custom_grid(char *, int, int *, int *); void cart_map(int, int *, int *, int [3][2], int ***); @@ -46,7 +47,7 @@ class ProcMap : protected Pointers { int combine_factors(int, int **, int, int **, int **); int cull_2d(int, int **, int); int cull_user(int, int **, int, int *); - int cull_other(int, int **, int, int, int *); + int cull_other(int, int **, int, int, int *, int *); int best_factors(int, int **, int *, int, int, int); void grid_shift(int, int, int &, int &); };