gmx::ArrayRef<const gmx::RVec> 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);
}
int sh;
comm = dd->comm;
- nc = dd->nc[ddpme->dim];
+ nc = dd->numCells[ddpme->dim];
ns = ddpme->nslab;
if (!ddpme->dim_match)
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);
}
}
{
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;
}
}
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]++;
}
* 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];
"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)
{
comm = dd->comm;
- const int ncd = dd->nc[dim];
+ const int ncd = dd->numCells[dim];
const bool dimHasPbc = (dim < ddbox->npbcdim);
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;
}
/* 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);
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];
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)
/* 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];
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++)
}
/* 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);
}
{ 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]);
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];
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;
}
}
else
{
- int ddindex = dd_index(cr->dd->nc, coords);
+ int ddindex = dd_index(cr->dd->numCells, coords);
if (cartSetup.bCartesianPP)
{
nodeid = cartSetup.ddindex2simnodeid[ddindex];
ivec coords;
MPI_Cart_coords(cr->mpi_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);
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])
{
}
else
{
- (*dim_f)[i] = static_cast<real>(i) / static_cast<real>(dd->nc[dim]);
+ (*dim_f)[i] = static_cast<real>(i) / static_cast<real>(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)
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.
*/
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 */
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
{
}
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);
}
}
}
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);
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);
{
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)
{
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];
}
}
}
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;
{
/* 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++)
periods[i] = TRUE;
}
MPI_Comm comm_cart;
- MPI_Cart_create(cr->mpi_comm_mygroup, DIM, dd->nc, periods, static_cast<int>(reorder), &comm_cart);
+ MPI_Cart_create(cr->mpi_comm_mygroup, DIM, dd->numCells, periods, static_cast<int>(reorder),
+ &comm_cart);
/* We overwrite the old communicator with the new cartesian one */
cr->mpi_comm_mygroup = comm_cart;
}
* 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.
std::vector<int> 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,
{
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);
}
}
{
/* 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);
std::vector<int> 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,
/* We can not use DDMASTER(dd), because dd->masterrank is set later */
if (MASTER(cr))
{
- dd->ma = std::make_unique<AtomDistribution>(dd->nc, numAtomsInSystem, numAtomsInSystem);
+ dd->ma = std::make_unique<AtomDistribution>(dd->numCells, numAtomsInSystem, numAtomsInSystem);
}
}
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]);
}
/* 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 */
* 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))
{
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);
}
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]);
}
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)
dim = dd->dim[d];
npulse_d = static_cast<int>(
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);
}
}
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;
}
* 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 */
}
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<double>(dd->nnodes);
}
if (debug)
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 =
{
dim = dd->dim[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;
/*! 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
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];
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];
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)
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());
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);
{
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.
/* 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;
}
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;
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;
}
//! The j-atom range
gmx::Range<int> 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
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 */
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;
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 } };
/* 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;
{
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
{
}
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];
}
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
{
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),
*/
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;
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])
{
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]);
}
if (isDlbOn(comm) && rowMaster->dlbIsLimited)
{
- load->sum_m *= dd->nc[dim];
+ load->sum_m *= dd->numCells[dim];
load->flags |= (1 << d);
}
}
{
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<real>(nc);
flag |= DD_FLAG_BW(d);
if (firstMoveDimValue == -1)
{
- if (dd.nc[dim] > 2)
+ if (dd.numCells[dim] > 2)
{
firstMoveDimValue = d * 2 + 1;
}
/* 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 */
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)
/* 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];
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]);
}
{
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;
}
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 */
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.
* 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 */
* 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);
}
}
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;
}
* 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
{
/* 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,
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));
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];
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;
/* 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.
*/
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
{
/* 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
{
minimumIlistCountForGpuBalancing);
auto pairSearch = std::make_unique<PairSearch>(
- 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);