From: ejjordan Date: Thu, 12 Dec 2019 17:59:56 +0000 (+0100) Subject: Change some domdec data members to RVec or IVec X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=28628e7fdb63f86b10c0f0adec45dfcc51b0725e;p=alexxy%2Fgromacs.git Change some domdec data members to RVec or IVec Where a trivial change from rvec/ivec to RVec/IVec is possible, that change has been made. The data member gmx_domdec_t.nc is renamed to numCells to facilitate completing the todo about changing this member to IVec. Some dead code is also removed from the domdec module. Change-Id: I1ef78c5ec198c60a1dd40a57ee5f87feb48bf490 --- diff --git a/src/gromacs/domdec/box.cpp b/src/gromacs/domdec/box.cpp index 0e9f4e611b..80c7797bf6 100644 --- a/src/gromacs/domdec/box.cpp +++ b/src/gromacs/domdec/box.cpp @@ -288,8 +288,8 @@ void set_ddbox(const gmx_domdec_t& dd, gmx::ArrayRef xRef = constArrayRefFromArray( x.data(), masterRankHasTheSystemState ? x.size() : dd.comm->atomRanges.numHomeAtoms()); - low_set_ddbox(dd.unitCellInfo.npbcdim, dd.unitCellInfo.numBoundedDimensions, &dd.nc, box, - calculateUnboundedSize, xRef, + low_set_ddbox(dd.unitCellInfo.npbcdim, dd.unitCellInfo.numBoundedDimensions, &dd.numCells, + box, calculateUnboundedSize, xRef, needToReduceCoordinateData ? &dd.mpi_comm_all : nullptr, ddbox); } diff --git a/src/gromacs/domdec/cellsizes.cpp b/src/gromacs/domdec/cellsizes.cpp index 28078ffc54..4867f64330 100644 --- a/src/gromacs/domdec/cellsizes.cpp +++ b/src/gromacs/domdec/cellsizes.cpp @@ -70,7 +70,7 @@ static void set_pme_maxshift(gmx_domdec_t* dd, int sh; comm = dd->comm; - nc = dd->nc[ddpme->dim]; + nc = dd->numCells[ddpme->dim]; ns = ddpme->nslab; if (!ddpme->dim_match) @@ -137,13 +137,13 @@ static void check_box_size(const gmx_domdec_t* dd, const gmx_ddbox_t* ddbox) dim = dd->dim[d]; if (dim < ddbox->nboundeddim && ddbox->box_size[dim] * ddbox->skew_fac[dim] - < dd->nc[dim] * dd->comm->cellsize_limit * DD_CELL_MARGIN) + < dd->numCells[dim] * dd->comm->cellsize_limit * DD_CELL_MARGIN) { gmx_fatal( FARGS, "The %c-size of the box (%f) times the triclinic skew factor (%f) is smaller " "than the number of DD cells (%d) times the smallest allowed cell size (%f)\n", - dim2char(dim), ddbox->box_size[dim], ddbox->skew_fac[dim], dd->nc[dim], + dim2char(dim), ddbox->box_size[dim], ddbox->skew_fac[dim], dd->numCells[dim], dd->comm->cellsize_limit); } } @@ -221,14 +221,14 @@ set_dd_cell_sizes_slb(gmx_domdec_t* dd, const gmx_ddbox_t* ddbox, int setmode, i { cellsize_min[d] = ddbox->box_size[d] * ddbox->skew_fac[d]; npulse[d] = 1; - if (dd->nc[d] == 1 || comm->slb_frac[d] == nullptr) + if (dd->numCells[d] == 1 || comm->slb_frac[d] == nullptr) { /* Uniform grid */ - real cell_dx = ddbox->box_size[d] / dd->nc[d]; + real cell_dx = ddbox->box_size[d] / dd->numCells[d]; switch (setmode) { case setcellsizeslbMASTER: - for (int j = 0; j < dd->nc[d] + 1; j++) + for (int j = 0; j < dd->numCells[d] + 1; j++) { cell_x_master[d][j] = ddbox->box0[d] + j * cell_dx; } @@ -261,16 +261,16 @@ set_dd_cell_sizes_slb(gmx_domdec_t* dd, const gmx_ddbox_t* ddbox, int setmode, i } else { - cell_x_buffer.resize(dd->nc[d] + 1); + cell_x_buffer.resize(dd->numCells[d] + 1); cell_x = cell_x_buffer; } cell_x[0] = ddbox->box0[d]; - for (int j = 0; j < dd->nc[d]; j++) + for (int j = 0; j < dd->numCells[d]; j++) { real cell_dx = ddbox->box_size[d] * comm->slb_frac[d][j]; cell_x[j + 1] = cell_x[j] + cell_dx; real cellsize = cell_dx * ddbox->skew_fac[d]; - while (cellsize * npulse[d] < comm->systemInfo.cutoff && npulse[d] < dd->nc[d] - 1) + while (cellsize * npulse[d] < comm->systemInfo.cutoff && npulse[d] < dd->numCells[d] - 1) { npulse[d]++; } @@ -286,7 +286,7 @@ set_dd_cell_sizes_slb(gmx_domdec_t* dd, const gmx_ddbox_t* ddbox, int setmode, i * some of its own home charge groups back over the periodic boundary. * Double charge groups cause trouble with the global indices. */ - if (d < ddbox->npbcdim && dd->nc[d] > 1 && npulse[d] >= dd->nc[d]) + if (d < ddbox->npbcdim && dd->numCells[d] > 1 && npulse[d] >= dd->numCells[d]) { char error_string[STRLEN]; @@ -295,7 +295,7 @@ set_dd_cell_sizes_slb(gmx_domdec_t* dd, const gmx_ddbox_t* ddbox, int setmode, i "small for a cut-off of %f with %d domain decomposition cells, use 1 or more " "than %d %s or increase the box size in this direction", dim2char(d), ddbox->box_size[d], ddbox->skew_fac[d], comm->systemInfo.cutoff, - dd->nc[d], dd->nc[d], dd->nnodes > dd->nc[d] ? "cells" : "ranks"); + dd->numCells[d], dd->numCells[d], dd->nnodes > dd->numCells[d] ? "cells" : "ranks"); if (setmode == setcellsizeslbLOCAL) { @@ -346,7 +346,7 @@ static void dd_cell_sizes_dlb_root_enforce_limits(gmx_domdec_t* dd, comm = dd->comm; - const int ncd = dd->nc[dim]; + const int ncd = dd->numCells[dim]; const bool dimHasPbc = (dim < ddbox->npbcdim); @@ -391,7 +391,7 @@ static void dd_cell_sizes_dlb_root_enforce_limits(gmx_domdec_t* dd, if (!rowMaster->isCellMin[i]) { cell_size[i] *= fac; - if (!dimHasPbc && (i == 0 || i == dd->nc[dim] - 1)) + if (!dimHasPbc && (i == 0 || i == dd->numCells[dim] - 1)) { cellsize_limit_f_i = 0; } @@ -572,7 +572,7 @@ static void set_dd_cell_sizes_dlb_root(gmx_domdec_t* dd, /* Convert the maximum change from the input percentage to a fraction */ const real change_limit = comm->ddSettings.dlb_scale_lim * 0.01; - const int ncd = dd->nc[dim]; + const int ncd = dd->numCells[dim]; const bool bPBC = (dim < ddbox->npbcdim); @@ -688,7 +688,7 @@ static void set_dd_cell_sizes_dlb_root(gmx_domdec_t* dd, rowMaster->cellFrac[i], rowMaster->cellFrac[i + 1]); } - if ((bPBC || (i != 0 && i != dd->nc[dim] - 1)) + if ((bPBC || (i != 0 && i != dd->numCells[dim] - 1)) && rowMaster->cellFrac[i + 1] - rowMaster->cellFrac[i] < cellsize_limit_f / DD_CELL_MARGIN) { char buf[22]; @@ -757,7 +757,7 @@ static void distribute_dd_cell_sizes_dlb(gmx_domdec_t* dd, comm.cellsizesWithDlb[d].fracLower = cellFracRow[dd->ci[dim]]; comm.cellsizesWithDlb[d].fracUpper = cellFracRow[dd->ci[dim] + 1]; /* The whole array was communicated, so set the buffer position */ - int pos = dd->nc[dim] + 1; + int pos = dd->numCells[dim] + 1; for (int d1 = 0; d1 <= d; d1++) { if (d1 < d) @@ -860,7 +860,7 @@ static void set_dd_cell_sizes_dlb(gmx_domdec_t* dd, /* Set the dimensions for which no DD is used */ for (dim = 0; dim < DIM; dim++) { - if (dd->nc[dim] == 1) + if (dd->numCells[dim] == 1) { comm->cell_x0[dim] = 0; comm->cell_x1[dim] = ddbox->box_size[dim]; diff --git a/src/gromacs/domdec/distribute.cpp b/src/gromacs/domdec/distribute.cpp index 50b17507ce..a681378a05 100644 --- a/src/gromacs/domdec/distribute.cpp +++ b/src/gromacs/domdec/distribute.cpp @@ -310,7 +310,7 @@ static inline int computeAtomGroupDomainIndex(const gmx_domdec_t& dd, if (d < dd.unitCellInfo.npbcdim) { bool bScrew = (dd.unitCellInfo.haveScrewPBC && d == XX); - if (ddbox.tric_dir[d] && dd.nc[d] > 1) + if (ddbox.tric_dir[d] && dd.numCells[d] > 1) { /* Use triclinic coordinates for this dimension */ for (int j = d + 1; j < DIM; j++) @@ -359,13 +359,13 @@ static inline int computeAtomGroupDomainIndex(const gmx_domdec_t& dd, } /* This could be done more efficiently */ ind[d] = 0; - while (ind[d] + 1 < dd.nc[d] && pos_d >= cellBoundaries[d][ind[d] + 1]) + while (ind[d] + 1 < dd.numCells[d] && pos_d >= cellBoundaries[d][ind[d] + 1]) { ind[d]++; } } - return dd_index(dd.nc, ind); + return dd_index(dd.numCells, ind); } diff --git a/src/gromacs/domdec/domdec.cpp b/src/gromacs/domdec/domdec.cpp index 83bdef4803..3f93013309 100644 --- a/src/gromacs/domdec/domdec.cpp +++ b/src/gromacs/domdec/domdec.cpp @@ -143,18 +143,6 @@ static const int ddNonbondedZonePairRanges[DD_MAXIZONE][3] = { { 0, 0, 8 }, { 2, 5, 6 }, { 3, 5, 7 } }; - -/* - #define dd_index(n,i) ((((i)[ZZ]*(n)[YY] + (i)[YY])*(n)[XX]) + (i)[XX]) - - static void index2xyz(ivec nc,int ind,ivec xyz) - { - xyz[XX] = ind % nc[XX]; - xyz[YY] = (ind / nc[XX]) % nc[YY]; - xyz[ZZ] = ind / (nc[YY]*nc[XX]); - } - */ - static void ddindex2xyz(const ivec nc, int ind, ivec xyz) { xyz[XX] = ind / (nc[YY] * nc[ZZ]); @@ -167,7 +155,7 @@ static int ddcoord2ddnodeid(gmx_domdec_t* dd, ivec c) int ddnodeid = -1; const CartesianRankSetup& cartSetup = dd->comm->cartesianRankSetup; - const int ddindex = dd_index(dd->nc, c); + const int ddindex = dd_index(dd->numCells, c); if (cartSetup.bCartesianPP_PME) { ddnodeid = cartSetup.ddindex2ddnodeid[ddindex]; @@ -701,24 +689,11 @@ static int gmx_ddcoord2pmeindex(const t_commrec* cr, int x, int y, int z) ivec coords; int slab; - dd = cr->dd; - /* - if (dd->comm->bCartesian) { - gmx_ddindex2xyz(dd->nc,ddindex,coords); - dd_coords2pmecoords(dd,coords,coords_pme); - copy_ivec(dd->ntot,nc); - nc[dd->cartpmedim] -= dd->nc[dd->cartpmedim]; - coords_pme[dd->cartpmedim] -= dd->nc[dd->cartpmedim]; - - slab = (coords_pme[XX]*nc[YY] + coords_pme[YY])*nc[ZZ] + coords_pme[ZZ]; - } else { - slab = (ddindex*cr->npmenodes + cr->npmenodes/2)/dd->nnodes; - } - */ + dd = cr->dd; coords[XX] = x; coords[YY] = y; coords[ZZ] = z; - slab = ddindex2pmeindex(dd->comm->ddRankSetup, dd_index(dd->nc, coords)); + slab = ddindex2pmeindex(dd->comm->ddRankSetup, dd_index(dd->numCells, coords)); return slab; } @@ -737,7 +712,7 @@ static int ddcoord2simnodeid(const t_commrec* cr, int x, int y, int z) } else { - int ddindex = dd_index(cr->dd->nc, coords); + int ddindex = dd_index(cr->dd->numCells, coords); if (cartSetup.bCartesianPP) { nodeid = cartSetup.ddindex2simnodeid[ddindex]; @@ -884,7 +859,7 @@ static gmx_bool receive_vir_ener(const gmx_domdec_t* dd, gmx::ArrayRefmpi_comm_mysim, cr->sim_nodeid, DIM, coords); coords[cartSetup.cartpmedim]++; - if (coords[cartSetup.cartpmedim] < dd->nc[cartSetup.cartpmedim]) + if (coords[cartSetup.cartpmedim] < dd->numCells[cartSetup.cartpmedim]) { int rank; MPI_Cart_rank(cr->mpi_comm_mysim, coords, &rank); @@ -922,9 +897,9 @@ static void set_slb_pme_dim_f(gmx_domdec_t* dd, int dim, real** dim_f) comm = dd->comm; - snew(*dim_f, dd->nc[dim] + 1); + snew(*dim_f, dd->numCells[dim] + 1); (*dim_f)[0] = 0; - for (i = 1; i < dd->nc[dim]; i++) + for (i = 1; i < dd->numCells[dim]; i++) { if (comm->slb_frac[dim]) { @@ -932,10 +907,10 @@ static void set_slb_pme_dim_f(gmx_domdec_t* dd, int dim, real** dim_f) } else { - (*dim_f)[i] = static_cast(i) / static_cast(dd->nc[dim]); + (*dim_f)[i] = static_cast(i) / static_cast(dd->numCells[dim]); } } - (*dim_f)[dd->nc[dim]] = 1; + (*dim_f)[dd->numCells[dim]] = 1; } static void init_ddpme(gmx_domdec_t* dd, gmx_ddpme_t* ddpme, int dimind) @@ -965,13 +940,13 @@ static void init_ddpme(gmx_domdec_t* dd, gmx_ddpme_t* ddpme, int dimind) snew(ddpme->pp_max, ddpme->nslab); for (int slab = 0; slab < ddpme->nslab; slab++) { - ddpme->pp_min[slab] = dd->nc[dd->dim[dimind]] - 1; + ddpme->pp_min[slab] = dd->numCells[dd->dim[dimind]] - 1; ddpme->pp_max[slab] = 0; } for (int i = 0; i < dd->nnodes; i++) { ivec xyz; - ddindex2xyz(dd->nc, i, xyz); + ddindex2xyz(dd->numCells, i, xyz); /* For y only use our y/z slab. * This assumes that the PME x grid size matches the DD grid size. */ @@ -1062,10 +1037,10 @@ static void make_load_communicator(gmx_domdec_t* dd, int dim_ind, ivec loc) dim = dd->dim[dim_ind]; copy_ivec(loc, loc_c); - for (i = 0; i < dd->nc[dim]; i++) + for (i = 0; i < dd->numCells[dim]; i++) { loc_c[dim] = i; - rank = dd_index(dd->nc, loc_c); + rank = dd_index(dd->numCells, loc_c); if (rank == dd->rank) { /* This process is part of the group */ @@ -1087,13 +1062,13 @@ static void make_load_communicator(gmx_domdec_t* dd, int dim_ind, ivec loc) RowMaster& rowMaster = *cellsizes.rowMaster; rowMaster.cellFrac.resize(ddCellFractionBufferSize(dd, dim_ind)); - rowMaster.oldCellFrac.resize(dd->nc[dim] + 1); - rowMaster.isCellMin.resize(dd->nc[dim]); + rowMaster.oldCellFrac.resize(dd->numCells[dim] + 1); + rowMaster.isCellMin.resize(dd->numCells[dim]); if (dim_ind > 0) { - rowMaster.bounds.resize(dd->nc[dim]); + rowMaster.bounds.resize(dd->numCells[dim]); } - rowMaster.buf_ncd.resize(dd->nc[dim]); + rowMaster.buf_ncd.resize(dd->numCells[dim]); } else { @@ -1103,7 +1078,7 @@ static void make_load_communicator(gmx_domdec_t* dd, int dim_ind, ivec loc) } if (dd->ci[dim] == dd->master_ci[dim]) { - snew(dd->comm->load[dim_ind].load, dd->nc[dim] * DD_NLOAD_MAX); + snew(dd->comm->load[dim_ind].load, dd->numCells[dim] * DD_NLOAD_MAX); } } } @@ -1186,7 +1161,7 @@ static void make_load_communicators(gmx_domdec_t gmx_unused* dd) if (dd->ndim > 1) { dim0 = dd->dim[0]; - for (i = 0; i < dd->nc[dim0]; i++) + for (i = 0; i < dd->numCells[dim0]; i++) { loc[dim0] = i; make_load_communicator(dd, 1, loc); @@ -1195,11 +1170,11 @@ static void make_load_communicators(gmx_domdec_t gmx_unused* dd) if (dd->ndim > 2) { dim0 = dd->dim[0]; - for (i = 0; i < dd->nc[dim0]; i++) + for (i = 0; i < dd->numCells[dim0]; i++) { loc[dim0] = i; dim1 = dd->dim[1]; - for (j = 0; j < dd->nc[dim1]; j++) + for (j = 0; j < dd->numCells[dim1]; j++) { loc[dim1] = j; make_load_communicator(dd, 2, loc); @@ -1226,10 +1201,10 @@ static void setup_neighbor_relations(gmx_domdec_t* dd) { dim = dd->dim[d]; copy_ivec(dd->ci, tmp); - tmp[dim] = (tmp[dim] + 1) % dd->nc[dim]; + tmp[dim] = (tmp[dim] + 1) % dd->numCells[dim]; dd->neighbor[d][0] = ddcoord2ddnodeid(dd, tmp); copy_ivec(dd->ci, tmp); - tmp[dim] = (tmp[dim] - 1 + dd->nc[dim]) % dd->nc[dim]; + tmp[dim] = (tmp[dim] - 1 + dd->numCells[dim]) % dd->numCells[dim]; dd->neighbor[d][1] = ddcoord2ddnodeid(dd, tmp); if (debug) { @@ -1262,11 +1237,11 @@ static void setup_neighbor_relations(gmx_domdec_t* dd) s[d] = dd->ci[d] - zones->shift[i][d]; if (s[d] < 0) { - s[d] += dd->nc[d]; + s[d] += dd->numCells[d]; } - else if (s[d] >= dd->nc[d]) + else if (s[d] >= dd->numCells[d]) { - s[d] -= dd->nc[d]; + s[d] -= dd->numCells[d]; } } } @@ -1285,7 +1260,7 @@ static void setup_neighbor_relations(gmx_domdec_t* dd) std::min(ddNonbondedZonePairRanges[iZoneIndex][2], nzone)); for (dim = 0; dim < DIM; dim++) { - if (dd->nc[dim] == 1) + if (dd->numCells[dim] == 1) { /* All shifts should be allowed */ iZone.shift0[dim] = -1; @@ -1338,8 +1313,8 @@ static void make_pp_communicator(const gmx::MDLogger& mdlog, { /* Set up cartesian communication for the particle-particle part */ GMX_LOG(mdlog.info) - .appendTextFormatted("Will use a Cartesian communicator: %d x %d x %d", dd->nc[XX], - dd->nc[YY], dd->nc[ZZ]); + .appendTextFormatted("Will use a Cartesian communicator: %d x %d x %d", + dd->numCells[XX], dd->numCells[YY], dd->numCells[ZZ]); ivec periods; for (int i = 0; i < DIM; i++) @@ -1347,7 +1322,8 @@ static void make_pp_communicator(const gmx::MDLogger& mdlog, periods[i] = TRUE; } MPI_Comm comm_cart; - MPI_Cart_create(cr->mpi_comm_mygroup, DIM, dd->nc, periods, static_cast(reorder), &comm_cart); + MPI_Cart_create(cr->mpi_comm_mygroup, DIM, dd->numCells, periods, static_cast(reorder), + &comm_cart); /* We overwrite the old communicator with the new cartesian one */ cr->mpi_comm_mygroup = comm_cart; } @@ -1361,7 +1337,7 @@ static void make_pp_communicator(const gmx::MDLogger& mdlog, * and not the one after split, we need to make an index. */ cartSetup.ddindex2ddnodeid.resize(dd->nnodes); - cartSetup.ddindex2ddnodeid[dd_index(dd->nc, dd->ci)] = dd->rank; + cartSetup.ddindex2ddnodeid[dd_index(dd->numCells, dd->ci)] = dd->rank; gmx_sumi(dd->nnodes, cartSetup.ddindex2ddnodeid.data(), cr); /* Get the rank of the DD master, * above we made sure that the master node is a PP node. @@ -1397,7 +1373,7 @@ static void make_pp_communicator(const gmx::MDLogger& mdlog, std::vector buf(dd->nnodes); if (thisRankHasDuty(cr, DUTY_PP)) { - buf[dd_index(dd->nc, dd->ci)] = cr->sim_nodeid; + buf[dd_index(dd->numCells, dd->ci)] = cr->sim_nodeid; } /* Communicate the ddindex to simulation nodeid index */ MPI_Allreduce(buf.data(), cartSetup.ddindex2simnodeid.data(), dd->nnodes, MPI_INT, MPI_SUM, @@ -1410,7 +1386,7 @@ static void make_pp_communicator(const gmx::MDLogger& mdlog, { if (cartSetup.ddindex2simnodeid[i] == 0) { - ddindex2xyz(dd->nc, i, dd->master_ci); + ddindex2xyz(dd->numCells, i, dd->master_ci); MPI_Cart_rank(dd->mpi_comm_all, dd->master_ci, &dd->masterrank); } } @@ -1423,7 +1399,7 @@ static void make_pp_communicator(const gmx::MDLogger& mdlog, { /* No Cartesian communicators */ /* We use the rank in dd->comm->all as DD index */ - ddindex2xyz(dd->nc, dd->rank, dd->ci); + ddindex2xyz(dd->numCells, dd->rank, dd->ci); /* The simulation master nodeid is 0, so the DD master rank is also 0 */ dd->masterrank = 0; clear_ivec(dd->master_ci); @@ -1451,7 +1427,7 @@ static void receive_ddindex2simnodeid(gmx_domdec_t* dd, t_commrec* cr) std::vector buf(dd->nnodes); if (thisRankHasDuty(cr, DUTY_PP)) { - buf[dd_index(dd->nc, dd->ci)] = cr->sim_nodeid; + buf[dd_index(dd->numCells, dd->ci)] = cr->sim_nodeid; } /* Communicate the ddindex to simulation nodeid index */ MPI_Allreduce(buf.data(), cartSetup.ddindex2simnodeid.data(), dd->nnodes, MPI_INT, MPI_SUM, @@ -1699,7 +1675,7 @@ static void setupGroupCommunication(const gmx::MDLogger& mdlog, /* We can not use DDMASTER(dd), because dd->masterrank is set later */ if (MASTER(cr)) { - dd->ma = std::make_unique(dd->nc, numAtomsInSystem, numAtomsInSystem); + dd->ma = std::make_unique(dd->numCells, numAtomsInSystem, numAtomsInSystem); } } @@ -1782,7 +1758,7 @@ static int dd_getenv(const gmx::MDLogger& mdlog, const char* env_var, int def) static void check_dd_restrictions(const gmx_domdec_t* dd, const t_inputrec* ir, const gmx::MDLogger& mdlog) { - if (ir->ePBC == epbcSCREW && (dd->nc[XX] == 1 || dd->nc[YY] > 1 || dd->nc[ZZ] > 1)) + if (ir->ePBC == epbcSCREW && (dd->numCells[XX] == 1 || dd->numCells[YY] > 1 || dd->numCells[ZZ] > 1)) { gmx_fatal(FARGS, "With pbc=%s can only do domain decomposition in the x-direction", epbc_names[ir->ePBC]); @@ -2436,18 +2412,18 @@ static void set_dd_limits(const gmx::MDLogger& mdlog, } /* Set the DD setup given by ddGridSetup */ - copy_ivec(ddGridSetup.numDomains, dd->nc); + copy_ivec(ddGridSetup.numDomains, dd->numCells); dd->ndim = ddGridSetup.numDDDimensions; copy_ivec(ddGridSetup.ddDimensions, dd->dim); - dd->nnodes = dd->nc[XX] * dd->nc[YY] * dd->nc[ZZ]; + dd->nnodes = dd->numCells[XX] * dd->numCells[YY] * dd->numCells[ZZ]; snew(comm->slb_frac, DIM); if (isDlbDisabled(comm)) { - comm->slb_frac[XX] = get_slb_frac(mdlog, "x", dd->nc[XX], options.cellSizeX); - comm->slb_frac[YY] = get_slb_frac(mdlog, "y", dd->nc[YY], options.cellSizeY); - comm->slb_frac[ZZ] = get_slb_frac(mdlog, "z", dd->nc[ZZ], options.cellSizeZ); + comm->slb_frac[XX] = get_slb_frac(mdlog, "x", dd->numCells[XX], options.cellSizeX); + comm->slb_frac[YY] = get_slb_frac(mdlog, "y", dd->numCells[YY], options.cellSizeY); + comm->slb_frac[ZZ] = get_slb_frac(mdlog, "z", dd->numCells[ZZ], options.cellSizeZ); } /* Set the multi-body cut-off and cellsize limit for DLB */ @@ -2461,7 +2437,7 @@ static void set_dd_limits(const gmx::MDLogger& mdlog, * the minimum and the maximum, * since the extra communication cost is nearly zero. */ - real acs = average_cellsize_min(ddbox, dd->nc); + real acs = average_cellsize_min(ddbox, dd->numCells); comm->cutoff_mbody = 0.5 * (systemInfo.minCutoffForMultiBody + acs); if (!isDlbDisabled(comm)) { @@ -2562,16 +2538,16 @@ static void writeSettings(gmx::TextWriter* log, log->writeString("The allowed shrink of domain decomposition cells is:"); for (d = 0; d < DIM; d++) { - if (dd->nc[d] > 1) + if (dd->numCells[d] > 1) { - if (d >= ddbox->npbcdim && dd->nc[d] == 2) + if (d >= ddbox->npbcdim && dd->numCells[d] == 2) { shrink = 0; } else { shrink = comm->cellsize_min_dlb[d] - / (ddbox->box_size[d] * ddbox->skew_fac[d] / dd->nc[d]); + / (ddbox->box_size[d] * ddbox->skew_fac[d] / dd->numCells[d]); } log->writeStringFormatted(" %c %.2f", dim2char(d), shrink); } @@ -2590,7 +2566,7 @@ static void writeSettings(gmx::TextWriter* log, log->writeString("The initial domain decomposition cell size is:"); for (d = 0; d < DIM; d++) { - if (dd->nc[d] > 1) + if (dd->numCells[d] > 1) { log->writeStringFormatted(" %c %.2f nm", dim2char(d), dd->comm->cellsize_min[d]); } @@ -2722,7 +2698,7 @@ static void set_cell_limits_dlb(const gmx::MDLogger& mdlog, else { /* There is no cell size limit */ - npulse = std::max(dd->nc[XX] - 1, std::max(dd->nc[YY] - 1, dd->nc[ZZ] - 1)); + npulse = std::max(dd->numCells[XX] - 1, std::max(dd->numCells[YY] - 1, dd->numCells[ZZ] - 1)); } if (!bNoCutOff && npulse > 1) @@ -2734,7 +2710,7 @@ static void set_cell_limits_dlb(const gmx::MDLogger& mdlog, dim = dd->dim[d]; npulse_d = static_cast( 1 - + dd->nc[dim] * comm->systemInfo.cutoff + + dd->numCells[dim] * comm->systemInfo.cutoff / (ddbox->box_size[dim] * ddbox->skew_fac[dim] * dlb_scale)); npulse_d_max = std::max(npulse_d_max, npulse_d); } @@ -2758,10 +2734,10 @@ static void set_cell_limits_dlb(const gmx::MDLogger& mdlog, } else { - comm->cd[d].np_dlb = std::min(npulse, dd->nc[dd->dim[d]] - 1); + comm->cd[d].np_dlb = std::min(npulse, dd->numCells[dd->dim[d]] - 1); comm->maxpulse = std::max(comm->maxpulse, comm->cd[d].np_dlb); } - if (comm->cd[d].np_dlb < dd->nc[dd->dim[d]] - 1) + if (comm->cd[d].np_dlb < dd->numCells[dd->dim[d]] - 1) { comm->bVacDLBNoLimit = FALSE; } @@ -2807,7 +2783,7 @@ gmx_bool dd_bonded_molpbc(const gmx_domdec_t* dd, int ePBC) * we do not need to take pbc into account for the bonded interactions. */ return (ePBC != epbcNONE && dd->comm->systemInfo.haveInterDomainBondeds - && !(dd->nc[XX] > 1 && dd->nc[YY] > 1 && (dd->nc[ZZ] > 1 || ePBC == epbcXY))); + && !(dd->numCells[XX] > 1 && dd->numCells[YY] > 1 && (dd->numCells[ZZ] > 1 || ePBC == epbcXY))); } /*! \brief Sets grid size limits and PP-PME setup, prints settings to log */ @@ -2857,7 +2833,7 @@ static void set_ddgrid_parameters(const gmx::MDLogger& mdlog, } else { - vol_frac = (1 + comm_box_frac(dd->nc, comm->systemInfo.cutoff, *ddbox)) + vol_frac = (1 + comm_box_frac(dd->numCells, comm->systemInfo.cutoff, *ddbox)) / static_cast(dd->nnodes); } if (debug) @@ -2966,8 +2942,8 @@ static bool canMake1DAnd1PulseDomainDecomposition(const DDSettings& bool is1DAnd1PulseDD(const gmx_domdec_t& dd) { - const int maxDimensionSize = std::max(dd.nc[XX], std::max(dd.nc[YY], dd.nc[ZZ])); - const int productOfDimensionSizes = dd.nc[XX] * dd.nc[YY] * dd.nc[ZZ]; + const int maxDimensionSize = std::max(dd.numCells[XX], std::max(dd.numCells[YY], dd.numCells[ZZ])); + const int productOfDimensionSizes = dd.numCells[XX] * dd.numCells[YY] * dd.numCells[ZZ]; const bool decompositionHasOneDimension = (maxDimensionSize == productOfDimensionSizes); const bool hasMax1Pulse = @@ -3162,7 +3138,7 @@ static gmx_bool test_dd_cutoff(t_commrec* cr, const matrix box, gmx::ArrayRefdim[d]; - inv_cell_size = DD_CELL_MARGIN * dd->nc[dim] / ddbox.box_size[dim]; + inv_cell_size = DD_CELL_MARGIN * dd->numCells[dim] / ddbox.box_size[dim]; if (dd->unitCellInfo.ddBoxIsDynamic) { inv_cell_size *= DD_PRES_SCALE_MARGIN; diff --git a/src/gromacs/domdec/domdec_internal.h b/src/gromacs/domdec/domdec_internal.h index 1b62f894b0..354f94352c 100644 --- a/src/gromacs/domdec/domdec_internal.h +++ b/src/gromacs/domdec/domdec_internal.h @@ -778,7 +778,7 @@ static inline int dd_index(const ivec numDomains, const ivec domainCoordinates) /*! Returns the size of the buffer to hold fractional cell boundaries for DD dimension index dimIndex */ static inline int ddCellFractionBufferSize(const gmx_domdec_t* dd, int dimIndex) { - return dd->nc[dd->dim[dimIndex]] + 1 + dimIndex * 2 + 1 + dimIndex; + return dd->numCells[dd->dim[dimIndex]] + 1 + dimIndex * 2 + 1 + dimIndex; } /*! \brief Maximum number of ranks for using send/recv for state scattering and gathering diff --git a/src/gromacs/domdec/domdec_specatomcomm.cpp b/src/gromacs/domdec/domdec_specatomcomm.cpp index 04faddad43..7c15e8ab33 100644 --- a/src/gromacs/domdec/domdec_specatomcomm.cpp +++ b/src/gromacs/domdec/domdec_specatomcomm.cpp @@ -76,7 +76,7 @@ void dd_move_f_specat(gmx_domdec_t* dd, gmx_domdec_specat_comm_t* spac, rvec* f, for (int d = dd->ndim - 1; d >= 0; d--) { dim = dd->dim[d]; - if (dd->nc[dim] > 2) + if (dd->numCells[dim] > 2) { /* Pulse the grid forward and backward */ spas = spac->spas[d]; @@ -89,7 +89,8 @@ void dd_move_f_specat(gmx_domdec_t* dd, gmx_domdec_specat_comm_t* spac, rvec* f, vbuf + spas[0].a.size(), spas[1].a.size()); for (dir = 0; dir < 2; dir++) { - bPBC = ((dir == 0 && dd->ci[dim] == 0) || (dir == 1 && dd->ci[dim] == dd->nc[dim] - 1)); + bPBC = ((dir == 0 && dd->ci[dim] == 0) + || (dir == 1 && dd->ci[dim] == dd->numCells[dim] - 1)); bScrew = (bPBC && dd->unitCellInfo.haveScrewPBC && dim == XX); spas = &spac->spas[d][dir]; @@ -145,7 +146,7 @@ void dd_move_f_specat(gmx_domdec_t* dd, gmx_domdec_specat_comm_t* spac, rvec* f, spas->a.size()); /* Sum the buffer into the required forces */ if (dd->unitCellInfo.haveScrewPBC && dim == XX - && (dd->ci[dim] == 0 || dd->ci[dim] == dd->nc[dim] - 1)) + && (dd->ci[dim] == 0 || dd->ci[dim] == dd->numCells[dim] - 1)) { int i = 0; for (int a : spas->a) @@ -187,7 +188,7 @@ void dd_move_x_specat(gmx_domdec_t* dd, gmx_domdec_specat_comm_t* spac, const ma for (d = 0; d < dd->ndim; d++) { dim = dd->dim[d]; - if (dd->nc[dim] > 2) + if (dd->numCells[dim] > 2) { /* Pulse the grid forward and backward */ rvec* vbuf = as_rvec_array(spac->vbuf.data()); @@ -199,7 +200,7 @@ void dd_move_x_specat(gmx_domdec_t* dd, gmx_domdec_specat_comm_t* spac, const ma bScrew = (dd->unitCellInfo.haveScrewPBC && dim == XX); copy_rvec(box[dim], shift); } - else if (dir == 1 && dd->ci[dim] == dd->nc[dim] - 1) + else if (dir == 1 && dd->ci[dim] == dd->numCells[dim] - 1) { bPBC = TRUE; bScrew = (dd->unitCellInfo.haveScrewPBC && dim == XX); @@ -295,7 +296,7 @@ void dd_move_x_specat(gmx_domdec_t* dd, gmx_domdec_specat_comm_t* spac, const ma { rvec* x = (v == 0 ? x0 : x1); if (dd->unitCellInfo.haveScrewPBC && dim == XX - && (dd->ci[XX] == 0 || dd->ci[XX] == dd->nc[XX] - 1)) + && (dd->ci[XX] == 0 || dd->ci[XX] == dd->numCells[XX] - 1)) { /* Here we only perform the rotation, the rest of the pbc * is handled in the constraint or viste routines. @@ -379,7 +380,7 @@ int setup_specat_communication(gmx_domdec_t* dd, /* Pulse the grid forward and backward */ dim = dd->dim[d]; bPBC = (dim < dd->unitCellInfo.npbcdim); - if (dd->nc[dim] == 2) + if (dd->numCells[dim] == 2) { /* Only 2 cells, so we only need to communicate once */ ndir = 1; @@ -390,8 +391,8 @@ int setup_specat_communication(gmx_domdec_t* dd, } for (int dir = 0; dir < ndir; dir++) { - if (!bPBC && dd->nc[dim] > 2 - && ((dir == 0 && dd->ci[dim] == dd->nc[dim] - 1) || (dir == 1 && dd->ci[dim] == 0))) + if (!bPBC && dd->numCells[dim] > 2 + && ((dir == 0 && dd->ci[dim] == dd->numCells[dim] - 1) || (dir == 1 && dd->ci[dim] == 0))) { /* No pbc: the fist/last cell should not request atoms */ nsend_ptr = nsend_zero; @@ -423,7 +424,7 @@ int setup_specat_communication(gmx_domdec_t* dd, for (int d = 0; d < dd->ndim; d++) { /* Pulse the grid forward and backward */ - if (dd->dim[d] >= dd->unitCellInfo.npbcdim || dd->nc[dd->dim[d]] > 2) + if (dd->dim[d] >= dd->unitCellInfo.npbcdim || dd->numCells[dd->dim[d]] > 2) { ndir = 2; } diff --git a/src/gromacs/domdec/domdec_struct.h b/src/gromacs/domdec/domdec_struct.h index 55a6a3e969..12a134c96c 100644 --- a/src/gromacs/domdec/domdec_struct.h +++ b/src/gromacs/domdec/domdec_struct.h @@ -94,21 +94,21 @@ struct DDPairInteractionRanges //! The j-atom range gmx::Range jAtomRange; //! Minimum shifts to consider - ivec shift0 = {}; + gmx::IVec shift0 = { 0, 0, 0 }; //! Maximum shifts to consider - ivec shift1 = {}; + gmx::IVec shift1 = { 0, 0, 0 }; }; typedef struct { /* Zone lower corner in triclinic coordinates */ - rvec x0 = {}; + gmx::RVec x0 = { 0, 0, 0 }; /* Zone upper corner in triclinic coordinates */ - rvec x1 = {}; + gmx::RVec x1 = { 0, 0, 0 }; /* Zone bounding box lower corner in Cartesian coords */ - rvec bb_x0 = {}; + gmx::RVec bb_x0 = { 0, 0, 0 }; /* Zone bounding box upper corner in Cartesian coords */ - rvec bb_x1 = {}; + gmx::RVec bb_x1 = { 0, 0, 0 }; } gmx_domdec_zone_size_t; struct gmx_domdec_zones_t @@ -129,13 +129,13 @@ struct gmx_domdec_zones_t struct gmx_ddbox_t { - int npbcdim; - int nboundeddim; - rvec box0; - rvec box_size; + int npbcdim; + int nboundeddim; + gmx::RVec box0 = { 0, 0, 0 }; + gmx::RVec box_size = { 0, 0, 0 }; /* Tells if the box is skewed for each of the three cartesian directions */ - ivec tric_dir; - rvec skew_fac; + gmx::IVec tric_dir = { 0, 0, 0 }; + gmx::RVec skew_fac = { 0, 0, 0 }; /* Orthogonal vectors for triclinic cells, Cartesian index */ rvec v[DIM][DIM]; /* Normal vectors for the cells walls */ @@ -170,10 +170,10 @@ struct gmx_domdec_t int nnodes = 0; MPI_Comm mpi_comm_all = MPI_COMM_NULL; /* The local DD cell index and rank */ - ivec ci = { 0, 0, 0 }; - int rank = 0; - ivec master_ci = { 0, 0, 0 }; - int masterrank = 0; + gmx::IVec ci = { 0, 0, 0 }; + int rank = 0; + gmx::IVec master_ci = { 0, 0, 0 }; + int masterrank = 0; /* Communication with the PME only nodes */ int pme_nodeid = 0; gmx_bool pme_receive_vir_ener = false; @@ -185,9 +185,10 @@ struct gmx_domdec_t UnitCellInfo unitCellInfo; /* The communication setup, identical for each cell, cartesian index */ - ivec nc = { 0, 0, 0 }; - int ndim = 0; - ivec dim = { 0, 0, 0 }; /* indexed by 0 to ndim */ + //! Todo: refactor nbnxm to not rely on this sometimes being a nullptr so this can be IVec + ivec numCells = { 0, 0, 0 }; + int ndim = 0; + gmx::IVec dim = { 0, 0, 0 }; /* indexed by 0 to ndim */ /* Forward and backward neighboring cells, indexed by 0 to ndim */ int neighbor[DIM][2] = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; diff --git a/src/gromacs/domdec/domdec_topology.cpp b/src/gromacs/domdec/domdec_topology.cpp index 502ae91eed..a8424c8a6c 100644 --- a/src/gromacs/domdec/domdec_topology.cpp +++ b/src/gromacs/domdec/domdec_topology.cpp @@ -1640,9 +1640,10 @@ void dd_make_local_top(gmx_domdec_t* dd, /* Only need to check for dimensions where the part of the box * that is not communicated is smaller than the cut-off. */ - if (d < npbcdim && dd->nc[d] > 1 && (dd->nc[d] - npulse[d]) * cellsize_min[d] < 2 * rc) + if (d < npbcdim && dd->numCells[d] > 1 + && (dd->numCells[d] - npulse[d]) * cellsize_min[d] < 2 * rc) { - if (dd->nc[d] == 2) + if (dd->numCells[d] == 2) { rcheck[d] = TRUE; bRCheckMB = TRUE; @@ -1663,7 +1664,7 @@ void dd_make_local_top(gmx_domdec_t* dd, { if (fr->bMolPBC) { - pbc_null = set_pbc_dd(&pbc, fr->ePBC, dd->nc, TRUE, box); + pbc_null = set_pbc_dd(&pbc, fr->ePBC, dd->numCells, TRUE, box); } else { diff --git a/src/gromacs/domdec/dump.cpp b/src/gromacs/domdec/dump.cpp index 28db18d212..e0e1a549e7 100644 --- a/src/gromacs/domdec/dump.cpp +++ b/src/gromacs/domdec/dump.cpp @@ -87,7 +87,7 @@ void write_dd_grid_pdb(const char* fn, int64_t step, gmx_domdec_t* dd, matrix bo } else { - if (d < ddbox->npbcdim && dd->nc[d] > 1) + if (d < ddbox->npbcdim && dd->numCells[d] > 1) { tric[d][i] = box[i][d] / box[i][i]; } diff --git a/src/gromacs/domdec/partition.cpp b/src/gromacs/domdec/partition.cpp index 2ff39b3a90..487514edae 100644 --- a/src/gromacs/domdec/partition.cpp +++ b/src/gromacs/domdec/partition.cpp @@ -209,7 +209,7 @@ static void dd_move_cellx(gmx_domdec_t* dd, const gmx_ddbox_t* ddbox, rvec cell_ if (applyPbc) { /* Take the minimum to avoid double communication */ - numPulsesMin = std::min(numPulses, dd->nc[dim] - 1 - numPulses); + numPulsesMin = std::min(numPulses, dd->numCells[dim] - 1 - numPulses); } else { @@ -243,7 +243,7 @@ static void dd_move_cellx(gmx_domdec_t* dd, const gmx_ddbox_t* ddbox, rvec cell_ for (int pulse = 0; pulse < numPulses; pulse++) { /* Communicate all the zone information backward */ - bool receiveValidData = (applyPbc || dd->ci[dim] < dd->nc[dim] - 1); + bool receiveValidData = (applyPbc || dd->ci[dim] < dd->numCells[dim] - 1); static_assert( sizeof(gmx_ddzone_t) == c_ddzoneNumReals * sizeof(real), @@ -325,8 +325,8 @@ static void dd_move_cellx(gmx_domdec_t* dd, const gmx_ddbox_t* ddbox, rvec cell_ */ buf_s[i] = buf_r[i]; } - if (((applyPbc || dd->ci[dim] + numPulses < dd->nc[dim]) && pulse == numPulses - 1) - || (!applyPbc && dd->ci[dim] + 1 + pulse == dd->nc[dim] - 1)) + if (((applyPbc || dd->ci[dim] + numPulses < dd->numCells[dim]) && pulse == numPulses - 1) + || (!applyPbc && dd->ci[dim] + 1 + pulse == dd->numCells[dim] - 1)) { /* Store the extremes */ int pos = 0; @@ -732,7 +732,7 @@ static void comm_dd_ns_cell_sizes(gmx_domdec_t* dd, gmx_ddbox_t* ddbox, rvec cel dim = dd->dim[dim_ind]; /* Without PBC we don't have restrictions on the outer cells */ - if (!(dim >= ddbox->npbcdim && (dd->ci[dim] == 0 || dd->ci[dim] == dd->nc[dim] - 1)) + if (!(dim >= ddbox->npbcdim && (dd->ci[dim] == 0 || dd->ci[dim] == dd->numCells[dim] - 1)) && isDlbOn(comm) && (comm->cell_x1[dim] - comm->cell_x0[dim]) * ddbox->skew_fac[dim] < comm->cellsize_min[dim]) { @@ -863,7 +863,7 @@ static void get_load_distribution(gmx_domdec_t* dd, gmx_wallcycle_t wcycle) load->mdf = 0; load->pme = 0; int pos = 0; - for (int i = 0; i < dd->nc[dim]; i++) + for (int i = 0; i < dd->numCells[dim]; i++) { load->sum += load->load[pos++]; load->max = std::max(load->max, load->load[pos]); @@ -904,7 +904,7 @@ static void get_load_distribution(gmx_domdec_t* dd, gmx_wallcycle_t wcycle) } if (isDlbOn(comm) && rowMaster->dlbIsLimited) { - load->sum_m *= dd->nc[dim]; + load->sum_m *= dd->numCells[dim]; load->flags |= (1 << d); } } @@ -1258,7 +1258,7 @@ static void turn_on_dlb(const gmx::MDLogger& mdlog, gmx_domdec_t* dd, int64_t st { comm->load[d].sum_m = comm->load[d].sum; - int nc = dd->nc[dd->dim[d]]; + int nc = dd->numCells[dd->dim[d]]; for (int i = 0; i < nc; i++) { rowMaster->cellFrac[i] = i / static_cast(nc); diff --git a/src/gromacs/domdec/redistribute.cpp b/src/gromacs/domdec/redistribute.cpp index a747a26a1c..ba86477b59 100644 --- a/src/gromacs/domdec/redistribute.cpp +++ b/src/gromacs/domdec/redistribute.cpp @@ -299,7 +299,7 @@ static int computeMoveFlag(const gmx_domdec_t& dd, const ivec& dev) flag |= DD_FLAG_BW(d); if (firstMoveDimValue == -1) { - if (dd.nc[dim] > 2) + if (dd.numCells[dim] > 2) { firstMoveDimValue = d * 2 + 1; } @@ -344,7 +344,7 @@ static void calc_cg_move(FILE* fplog, /* Do pbc and check DD cell boundary crossings */ for (int d = DIM - 1; d >= 0; d--) { - if (dd->nc[d] > 1) + if (dd->numCells[d] > 1) { bool bScrew = (dd->unitCellInfo.haveScrewPBC && d == XX); /* Determine the location of this cg in lattice coordinates */ @@ -365,7 +365,7 @@ static void calc_cg_move(FILE* fplog, cm_new, cm_new, pos_d); } dev[d] = 1; - if (dd->ci[d] == dd->nc[d] - 1) + if (dd->ci[d] == dd->numCells[d] - 1) { rvec_dec(cm_new, state->box[d]); if (bScrew) @@ -468,7 +468,7 @@ static void calcGroupMove(FILE* fplog, /* Do pbc and check DD cell boundary crossings */ for (int d = DIM - 1; d >= 0; d--) { - if (dd->nc[d] > 1) + if (dd->numCells[d] > 1) { /* Determine the location of this COG in lattice coordinates */ real pos_d = cog[d]; @@ -488,7 +488,7 @@ static void calcGroupMove(FILE* fplog, cogOld, cog, pos_d); } dev[d] = 1; - if (dd->ci[d] == dd->nc[d] - 1) + if (dd->ci[d] == dd->numCells[d] - 1) { rvec_dec(cog, state->box[d]); } @@ -584,7 +584,7 @@ void dd_redistribute_cg(FILE* fplog, { cell_x0[d] = comm->cell_x0[d]; } - if (d >= npbcdim && dd->ci[d] == dd->nc[d] - 1) + if (d >= npbcdim && dd->ci[d] == dd->numCells[d] - 1) { cell_x1[d] = GMX_FLOAT_MAX; } @@ -748,7 +748,7 @@ void dd_redistribute_cg(FILE* fplog, const int dim = dd->dim[d]; int ncg_recv = 0; int nvr = 0; - for (int dir = 0; dir < (dd->nc[dim] == 2 ? 1 : 2); dir++) + for (int dir = 0; dir < (dd->numCells[dim] == 2 ? 1 : 2); dir++) { const int cdd = d * 2 + dir; /* Communicate the cg and atom counts */ @@ -787,7 +787,7 @@ void dd_redistribute_cg(FILE* fplog, int flag = flagBuffer.buffer[cg * DD_CGIBS + 1]; const gmx::RVec& cog = rvecBuffer.buffer[buf_pos]; - if (dim >= npbcdim && dd->nc[dim] > 2) + if (dim >= npbcdim && dd->numCells[dim] > 2) { /* No pbc in this dim and more than one domain boundary. * We do a separate check if a charge group didn't move too far. @@ -819,7 +819,7 @@ void dd_redistribute_cg(FILE* fplog, * so we do not need to handle boundary crossings. * This also means we do not have to handle PBC here. */ - if (!((dd->ci[dim2] == dd->nc[dim2] - 1 && (flag & DD_FLAG_FW(d2))) + if (!((dd->ci[dim2] == dd->numCells[dim2] - 1 && (flag & DD_FLAG_FW(d2))) || (dd->ci[dim2] == 0 && (flag & DD_FLAG_BW(d2))))) { /* Clear the two flags for this dimension */ @@ -842,7 +842,7 @@ void dd_redistribute_cg(FILE* fplog, * to an adjacent cell because of the * staggering. */ - if (pos_d >= cell_x1[dim2] && dd->ci[dim2] != dd->nc[dim2] - 1) + if (pos_d >= cell_x1[dim2] && dd->ci[dim2] != dd->numCells[dim2] - 1) { flag |= DD_FLAG_FW(d2); } @@ -861,7 +861,7 @@ void dd_redistribute_cg(FILE* fplog, } else if (flag & DD_FLAG_BW(d2)) { - if (dd->nc[dd->dim[d2]] > 2) + if (dd->numCells[dd->dim[d2]] > 2) { mc = d2 * 2 + 1; } diff --git a/src/gromacs/mdlib/constr.cpp b/src/gromacs/mdlib/constr.cpp index eccc21f1f0..984c901e62 100644 --- a/src/gromacs/mdlib/constr.cpp +++ b/src/gromacs/mdlib/constr.cpp @@ -431,7 +431,7 @@ bool Constraints::Impl::apply(bool bLog, * by the constraint coordinate communication routine, * so that here we can use normal pbc. */ - pbc_null = set_pbc_dd(&pbc, ir.ePBC, DOMAINDECOMP(cr) ? cr->dd->nc : nullptr, FALSE, box); + pbc_null = set_pbc_dd(&pbc, ir.ePBC, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, FALSE, box); } else { diff --git a/src/gromacs/mdlib/force.cpp b/src/gromacs/mdlib/force.cpp index 8b36c27e8c..3e7c359e03 100644 --- a/src/gromacs/mdlib/force.cpp +++ b/src/gromacs/mdlib/force.cpp @@ -177,7 +177,7 @@ void do_force_lowlevel(t_forcerec* fr, /* Since all atoms are in the rectangular or triclinic unit-cell, * only single box vector shifts (2 in x) are required. */ - set_pbc_dd(&pbc, fr->ePBC, DOMAINDECOMP(cr) ? cr->dd->nc : nullptr, TRUE, box); + set_pbc_dd(&pbc, fr->ePBC, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, TRUE, box); } do_force_listed(wcycle, box, ir->fepvals, cr, ms, idef, x, hist, forceOutputs, fr, &pbc, diff --git a/src/gromacs/mdlib/mdoutf.cpp b/src/gromacs/mdlib/mdoutf.cpp index 24215b1b33..085f30201c 100644 --- a/src/gromacs/mdlib/mdoutf.cpp +++ b/src/gromacs/mdlib/mdoutf.cpp @@ -297,7 +297,7 @@ void mdoutf_write_to_trajectory_files(FILE* fplog, fflush_tng(of->tng_low_prec); ivec one_ivec = { 1, 1, 1 }; write_checkpoint(of->fn_cpt, of->bKeepAndNumCPT, fplog, cr, - DOMAINDECOMP(cr) ? cr->dd->nc : one_ivec, + DOMAINDECOMP(cr) ? cr->dd->numCells : one_ivec, DOMAINDECOMP(cr) ? cr->dd->nnodes : cr->nnodes, of->eIntegrator, of->simulation_part, of->bExpanded, of->elamstats, step, t, state_global, observablesHistory, *(of->mdModulesNotifier)); diff --git a/src/gromacs/mdlib/nsgrid.cpp b/src/gromacs/mdlib/nsgrid.cpp index db14315e70..461a4984ab 100644 --- a/src/gromacs/mdlib/nsgrid.cpp +++ b/src/gromacs/mdlib/nsgrid.cpp @@ -179,7 +179,7 @@ void get_nsgrid_boundaries(int nboundeddim, bdens0 = (*gr0)[d]; } /* Check for a DD cell not at a higher edge */ - if (dd != nullptr && gr1 != nullptr && dd->ci[d] < dd->nc[d] - 1) + if (dd != nullptr && gr1 != nullptr && dd->ci[d] < dd->numCells[d] - 1) { grid_x1[d] = (*gr1)[d]; bdens1 = (*gr1)[d]; @@ -238,7 +238,7 @@ static void set_grid_sizes(matrix box, grid->cell_offset[i] = izones_x0[i]; size = izones_size[i]; - bDD = (dd != nullptr) && (dd->nc[i] > 1); + bDD = (dd != nullptr) && (dd->numCells[i] > 1); if (!bDD) { bDDRect = FALSE; diff --git a/src/gromacs/mdlib/qmmm.cpp b/src/gromacs/mdlib/qmmm.cpp index 24b3c75d2a..078afe88cf 100644 --- a/src/gromacs/mdlib/qmmm.cpp +++ b/src/gromacs/mdlib/qmmm.cpp @@ -614,7 +614,7 @@ void update_QMMMrec(const t_commrec* cr, const t_forcerec* fr, const rvec* x, co /* init_pbc(box); needs to be called first, see pbc.h */ ivec null_ivec; clear_ivec(null_ivec); - set_pbc_dd(&pbc, fr->ePBC, DOMAINDECOMP(cr) ? cr->dd->nc : null_ivec, FALSE, box); + set_pbc_dd(&pbc, fr->ePBC, DOMAINDECOMP(cr) ? cr->dd->numCells : null_ivec, FALSE, box); /* only in standard (normal) QMMM we need the neighbouring MM * particles to provide a electric field of point charges for the QM * atoms. diff --git a/src/gromacs/mdlib/vsite.cpp b/src/gromacs/mdlib/vsite.cpp index 4a0fe17a00..152567de68 100644 --- a/src/gromacs/mdlib/vsite.cpp +++ b/src/gromacs/mdlib/vsite.cpp @@ -641,7 +641,7 @@ void construct_vsites(const gmx_vsite_t* vsite, */ ivec null_ivec; clear_ivec(null_ivec); - pbc_null = set_pbc_dd(&pbc, ePBC, useDomdec ? cr->dd->nc : null_ivec, FALSE, box); + pbc_null = set_pbc_dd(&pbc, ePBC, useDomdec ? cr->dd->numCells : null_ivec, FALSE, box); } else { @@ -1748,7 +1748,7 @@ void spread_vsite_f(const gmx_vsite_t* vsite, /* This is wasting some CPU time as we now do this multiple times * per MD step. */ - pbc_null = set_pbc_dd(&pbc, ePBC, useDomdec ? cr->dd->nc : nullptr, FALSE, box); + pbc_null = set_pbc_dd(&pbc, ePBC, useDomdec ? cr->dd->numCells : nullptr, FALSE, box); } else { diff --git a/src/gromacs/nbnxm/nbnxm_setup.cpp b/src/gromacs/nbnxm/nbnxm_setup.cpp index 89a3477639..686179accd 100644 --- a/src/gromacs/nbnxm/nbnxm_setup.cpp +++ b/src/gromacs/nbnxm/nbnxm_setup.cpp @@ -456,7 +456,7 @@ std::unique_ptr init_nb_verlet(const gmx::MDLogger& mdlo minimumIlistCountForGpuBalancing); auto pairSearch = std::make_unique( - ir->ePBC, EI_TPI(ir->eI), DOMAINDECOMP(cr) ? &cr->dd->nc : nullptr, + ir->ePBC, EI_TPI(ir->eI), DOMAINDECOMP(cr) ? &cr->dd->numCells : nullptr, DOMAINDECOMP(cr) ? domdec_zones(cr->dd) : nullptr, pairlistParams.pairlistType, bFEP_NonBonded, gmx_omp_nthreads_get(emntPairsearch), pinPolicy);