VirtualSitesHandler* vsite,
gmx_shellfc_t* shellfc)
{
- bool usingDomDec = DOMAINDECOMP(cr);
+ bool usingDomDec = haveDDAtomOrdering(*cr);
int numAtomIndex;
int numHomeAtoms;
{
forcesRef = pme->atc[d + 1].f;
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_pmeredist_f(pme, &pme->atc[d], forcesRef, d == pme->ndecompdim - 1 && pme->bPPnode);
}
pme_lb->cycles_n = 0;
pme_lb->cycles_c = 0;
// only master ranks do timing
- if (!PAR(cr) || (DOMAINDECOMP(cr) && DDMASTER(cr->dd)))
+ if (!PAR(cr) || (haveDDAtomOrdering(*cr) && DDMASTER(cr->dd)))
{
pme_lb->startTime = gmx_gettime();
}
pme_lb->step_rel_stop = PMETunePeriod * ir.nstlist;
/* Delay DD load balancing when GPUs are used */
- if (pme_lb->bActive && DOMAINDECOMP(cr) && cr->dd->nnodes > 1 && bUseGPU)
+ if (pme_lb->bActive && haveDDAtomOrdering(*cr) && cr->dd->nnodes > 1 && bUseGPU)
{
/* Lock DLB=auto to off (does nothing when DLB=yes/no.
* With GPUs and separate PME nodes, we want to first
{
pme_lb->fastest = pme_lb->cur;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
/* We found a new fastest setting, ensure that with subsequent
* shorter cut-off's the dynamic load balancing does not make
{
pme_lb->cur++;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
OK = change_dd_cutoff(cr, box, x, pme_lb->setup[pme_lb->cur].rlistOuter);
if (!OK)
}
}
- if (DOMAINDECOMP(cr) && pme_lb->stage > 0)
+ if (haveDDAtomOrdering(*cr) && pme_lb->stage > 0)
{
OK = change_dd_cutoff(cr, box, x, pme_lb->setup[pme_lb->cur].rlistOuter);
if (!OK)
* We also want to skip a number of steps and seconds while
* the CPU and GPU, when used, performance stabilizes.
*/
- if (!PAR(cr) || (DOMAINDECOMP(cr) && DDMASTER(cr->dd)))
+ if (!PAR(cr) || (haveDDAtomOrdering(*cr) && DDMASTER(cr->dd)))
{
pme_lb->startupTimeDelayElapsed = (gmx_gettime() - pme_lb->startTime < c_startupTimeDelay);
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_bcast(cr->dd, sizeof(bool), &pme_lb->startupTimeDelayElapsed);
}
*/
else if (step_rel >= c_numFirstTuningIntervalSkipWithSepPme * ir.nstlist)
{
- GMX_ASSERT(DOMAINDECOMP(cr), "Domain decomposition should be active here");
+ GMX_ASSERT(haveDDAtomOrdering(*cr), "Domain decomposition should be active here");
if (DDMASTER(cr->dd))
{
/* If PME rank load is too high, start tuning. If
{
pme_lb->bBalance = FALSE;
- if (DOMAINDECOMP(cr) && dd_dlb_is_locked(cr->dd))
+ if (haveDDAtomOrdering(*cr) && dd_dlb_is_locked(cr->dd))
{
/* Unlock the DLB=auto, DLB is allowed to activate */
dd_dlb_unlock(cr->dd);
pme_lb->bActive = FALSE;
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
/* Set the cut-off limit to the final selected cut-off,
* so we don't have artificial DLB limits.
pme_lb->bActive = FALSE;
}
- if (!(pme_lb->bActive) && DOMAINDECOMP(cr) && dd_dlb_is_locked(cr->dd))
+ if (!(pme_lb->bActive) && haveDDAtomOrdering(*cr) && dd_dlb_is_locked(cr->dd))
{
/* Make sure DLB is allowed when we deactivate PME tuning */
dd_dlb_unlock(cr->dd);
atc.pd.resize(xRef.size());
pme_calc_pidx_wrapper(xRef, pme->recipbox, &atc);
/* Redistribute x (only once) and qA/c6A or qB/c6B */
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_pmeredist_pos_coeffs(pme, bFirst, xRef, param_d, &atc);
}
}
}
- if (!DOMAINDECOMP(cr))
+ if (!haveDDAtomOrdering(*cr))
{
nat_loc = nat;
ind_loc = ind;
}
/* NOTE: Rt_6 and Rtav_6 are stored consecutively in memory */
- if (cr && DOMAINDECOMP(cr))
+ if (cr && haveDDAtomOrdering(*cr))
{
gmx_sum(2 * dd->nres, dd->Rt_6, cr);
}
GMX_ASSERT(cr != nullptr && ms != nullptr, "We need multisim with nsystems>1");
gmx_sum_sim(2 * dd->nres, dd->Rt_6, ms);
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
gmx_bcast(2 * dd->nres, dd->Rt_6, cr->mpi_comm_mygroup);
}
const char * anm, *resnm;
dd = nullptr;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd = cr->dd;
dd_get_constraint_range(*dd, &dd_ac0, &dd_ac1);
* by the constraint coordinate communication routine,
* so that here we can use normal pbc.
*/
- pbc_null = set_pbc_dd(&pbc, ir.pbcType, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, FALSE, box);
+ pbc_null = set_pbc_dd(
+ &pbc, ir.pbcType, haveDDAtomOrdering(*cr) ? cr->dd->numCells : nullptr, FALSE, box);
}
else
{
// When there are multiple PP domains and update groups are
// not in use, the constraints might be split across the
// domains, needing particular handling.
- const bool mayHaveSplitConstraints = DOMAINDECOMP(cr) && !useUpdateGroups;
+ const bool mayHaveSplitConstraints = haveDDAtomOrdering(*cr) && !useUpdateGroups;
if (ir.eConstrAlg == ConstraintAlgorithm::Lincs)
{
const std::vector<bool>& randomize,
gmx::ArrayRef<const real> boltzfac)
{
- const int* gatindex = (DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr);
- int i;
- int gc = 0;
- gmx::ThreeFry2x64<0> rng(ir->andersen_seed, gmx::RandomDomain::Thermostat);
- gmx::UniformRealDistribution<real> uniformDist;
+ const int* gatindex = (haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr);
+ int i;
+ int gc = 0;
+ gmx::ThreeFry2x64<0> rng(ir->andersen_seed, gmx::RandomDomain::Thermostat);
+ gmx::UniformRealDistribution<real> uniformDist;
gmx::TabulatedNormalDistribution<real, 14> normalDist;
/* randomize the velocities of the selected particles */
sigmaB_,
box,
commrec,
- DOMAINDECOMP(commrec) ? dd_pme_maxshift_x(*commrec->dd) : 0,
- DOMAINDECOMP(commrec) ? dd_pme_maxshift_y(*commrec->dd) : 0,
+ haveDDAtomOrdering(*commrec) ? dd_pme_maxshift_x(*commrec->dd) : 0,
+ haveDDAtomOrdering(*commrec) ? dd_pme_maxshift_y(*commrec->dd) : 0,
nrnb_,
wcycle_,
ewaldOutput.vir_q,
}
else
{
- forcerec->bMolPBC = (!DOMAINDECOMP(commrec) || dd_bonded_molpbc(*commrec->dd, forcerec->pbcType));
+ forcerec->bMolPBC =
+ (!haveDDAtomOrdering(*commrec) || dd_bonded_molpbc(*commrec->dd, forcerec->pbcType));
// Check and set up PBC for Ewald surface corrections or orientation restraints
const bool useEwaldSurfaceCorrection =
(EEL_PME_EWALD(inputrec.coulombtype) && inputrec.epsilon_surface != 0);
const bool haveOrientationRestraints = (gmx_mtop_ftype_count(mtop, F_ORIRES) > 0);
const bool moleculesAreAlwaysWhole =
- (DOMAINDECOMP(commrec) && dd_moleculesAreAlwaysWhole(*commrec->dd));
+ (haveDDAtomOrdering(*commrec) && dd_moleculesAreAlwaysWhole(*commrec->dd));
// WholeMoleculeTransform is only supported with a single PP rank
if (!moleculesAreAlwaysWhole && !havePPDomainDecomposition(commrec)
&& (useEwaldSurfaceCorrection || haveOrientationRestraints))
}
forcerec->wholeMoleculeTransform = std::make_unique<gmx::WholeMoleculeTransform>(
- mtop, inputrec.pbcType, DOMAINDECOMP(commrec));
+ mtop, inputrec.pbcType, haveDDAtomOrdering(*commrec));
}
- forcerec->bMolPBC = !DOMAINDECOMP(commrec) || dd_bonded_molpbc(*commrec->dd, forcerec->pbcType);
+ forcerec->bMolPBC =
+ !haveDDAtomOrdering(*commrec) || dd_bonded_molpbc(*commrec->dd, forcerec->pbcType);
if (useEwaldSurfaceCorrection)
{
/* Set all the static charge group info */
forcerec->atomInfoForEachMoleculeBlock = makeAtomInfoForEachMoleculeBlock(mtop, forcerec);
- if (!DOMAINDECOMP(commrec))
+ if (!haveDDAtomOrdering(*commrec))
{
forcerec->atomInfo = expandAtomInfo(mtop.molblock.size(), forcerec->atomInfoForEachMoleculeBlock);
}
- if (!DOMAINDECOMP(commrec))
+ if (!haveDDAtomOrdering(*commrec))
{
forcerec_set_ranges(forcerec, mtop.natoms, mtop.natoms, mtop.natoms);
}
for (int iter = 0; iter < lincsd->nIter; iter++)
{
- if ((lincsd->bCommIter && DOMAINDECOMP(cr) && cr->dd->constraints))
+ if ((lincsd->bCommIter && haveDDAtomOrdering(*cr) && cr->dd->constraints))
{
#pragma omp barrier
#pragma omp master
{
/* Communicate the corrected non-local coordinates */
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_move_x_constraints(cr->dd, box, xpPadded.unpaddedArrayRef(), ArrayRef<RVec>(), FALSE);
}
}
int natoms;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
if (cr->dd->constraints)
{
li->blnr.resize(numEntries + 1);
li->bllen.resize(numEntries);
li->tmpv.resizeWithPadding(numEntries);
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
li->nlocat.resize(numEntries);
}
/* Without DD we order the blbnb matrix to optimize memory access.
* With DD the overhead of sorting is more than the gain during access.
*/
- bSortMatrix = !DOMAINDECOMP(cr);
+ bSortMatrix = !haveDDAtomOrdering(*cr);
li->blbnb.resize(li->ncc);
}
}
- if (ir->nstfout && DOMAINDECOMP(cr))
+ if (ir->nstfout && haveDDAtomOrdering(*cr))
{
snew(of->f_global, top_global.natoms);
}
char buf[1024], suffix[5 + STEPSTRSIZE], sbuf[STEPSTRSIZE];
t_fileio* ret;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
npmenodes = cr->npmenodes;
}
std::strcpy(headerContents.version, gmx_version());
std::strcpy(headerContents.fprog, gmx::getProgramContext().fullBinaryPath());
std::strcpy(headerContents.ftime, timebuf.c_str());
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
copy_ivec(domdecCells, headerContents.dd_nc);
}
of->bKeepAndNumCPT,
fplog,
cr,
- DOMAINDECOMP(cr) ? cr->dd->numCells : one_ivec,
- DOMAINDECOMP(cr) ? cr->dd->nnodes : cr->nnodes,
+ haveDDAtomOrdering(*cr) ? cr->dd->numCells : one_ivec,
+ haveDDAtomOrdering(*cr) ? cr->dd->nnodes : cr->nnodes,
of->eIntegrator,
of->simulation_part,
of->bExpanded,
{
const rvec* f_global;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
if (mdof_flags & MDOF_CPT)
{
wallcycle_stop(wcycle, WallCycleCounter::Run);
wallcycle_reset_all(wcycle);
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
reset_dd_statistics_counters(cr->dd);
}
}
const bool fillGrid = (stepWork.doNeighborSearch && stepWork.stateChanged);
- const bool calcCGCM = (fillGrid && !DOMAINDECOMP(cr));
+ const bool calcCGCM = (fillGrid && !haveDDAtomOrdering(*cr));
if (calcCGCM)
{
put_atoms_in_box_omp(fr->pbcType,
}
wallcycle_start(wcycle, WallCycleCounter::NS);
- if (!DOMAINDECOMP(cr))
+ if (!haveDDAtomOrdering(*cr))
{
const rvec vzero = { 0.0_real, 0.0_real, 0.0_real };
const rvec boxDiagonal = { box[XX][XX], box[YY][YY], box[ZZ][ZZ] };
/* Reset energies */
reset_enerdata(enerd);
- if (DOMAINDECOMP(cr) && simulationWork.haveSeparatePmeRank)
+ if (haveDDAtomOrdering(*cr) && simulationWork.haveSeparatePmeRank)
{
wallcycle_start(wcycle, WallCycleCounter::PpDuringPme);
dd_force_flop_start(cr->dd, nrnb);
/* 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->pbcType, DOMAINDECOMP(cr) ? cr->dd->numCells : nullptr, TRUE, box);
+ set_pbc_dd(&pbc, fr->pbcType, haveDDAtomOrdering(*cr) ? cr->dd->numCells : nullptr, TRUE, box);
}
for (int mtsIndex = 0; mtsIndex < (simulationWork.useMts && stepWork.computeSlowForces ? 2 : 1);
nrnb,
lambda,
mdatoms,
- DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr,
+ haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr,
stepWork);
}
}
enerd,
stepWork,
InteractionLocality::Local,
- DOMAINDECOMP(cr) ? enbvClearFNo : enbvClearFYes,
+ haveDDAtomOrdering(*cr) ? enbvClearFNo : enbvClearFYes,
step,
nrnb,
wcycle);
// NOTE: If there are virtual sites, the forces are modified on host after this D2H copy. Hence,
// they should not be copied in do_md(...) for the output.
if (!simulationWork.useGpuUpdate
- || (simulationWork.useGpuUpdate && DOMAINDECOMP(cr) && simulationWork.useCpuPmePpCommunication)
+ || (simulationWork.useGpuUpdate && haveDDAtomOrdering(*cr) && simulationWork.useCpuPmePpCommunication)
|| vsite)
{
stateGpu->copyForcesFromGpu(forceWithShift, AtomLocality::Local);
launchGpuEndOfStepTasks(
nbv, fr->listedForcesGpu.get(), fr->pmedata, enerd, *runScheduleWork, step, wcycle);
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_force_flop_stop(cr->dd, nrnb);
}
// Communicate the signals between the simulations.
gmx_sum_sim(eglsNR, mpiBuffer_.data(), ms_);
}
- if (DOMAINDECOMP(cr_))
+ if (haveDDAtomOrdering(*cr_))
{
// Communicate the signals from the master to the others.
gmx_bcast(eglsNR * sizeof(mpiBuffer_[0]), mpiBuffer_.data(), cr_->mpi_comm_mygroup);
}
else
{
- doSDUpdateGeneral<SDUpdate::Combined>(sd,
- start,
- nrend,
- dt,
- nFreeze,
- invmass,
- ptype,
- cFREEZE,
- cTC,
- x,
- xprime,
- v,
- f,
- step,
- seed,
- DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr);
+ doSDUpdateGeneral<SDUpdate::Combined>(
+ sd,
+ start,
+ nrend,
+ dt,
+ nFreeze,
+ invmass,
+ ptype,
+ cFREEZE,
+ cTC,
+ x,
+ xprime,
+ v,
+ f,
+ step,
+ seed,
+ haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr);
}
}
nullptr,
step,
inputRecord.ld_seed,
- DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr);
+ haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr);
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
}
inputRecord.bd_fric,
sd_.bd_rf.data(),
inputRecord.ld_seed,
- DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr);
+ haveDDAtomOrdering(*cr) ? cr->dd->globalAtomIndices.data() : nullptr);
break;
case (IntegrationAlgorithm::VV):
case (IntegrationAlgorithm::VVAK):
top_global,
constr ? constr->numFlexibleConstraints() : 0,
ir->nstcalcenergy,
- DOMAINDECOMP(cr),
+ haveDDAtomOrdering(*cr),
useGpuForPme);
{
? PinningPolicy::PinnedIfSupported
: PinningPolicy::CannotBePinned);
const t_mdatoms* md = mdAtoms->mdatoms();
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
// Local state only becomes valid now.
dd_init_local_state(*cr->dd, state_global, state);
// TODO: the assertions below should be handled by UpdateConstraintsBuilder.
if (useGpuForUpdate)
{
- GMX_RELEASE_ASSERT(!DOMAINDECOMP(cr) || ddUsesUpdateGroups(*cr->dd) || constr == nullptr
- || constr->numConstraintsTotal() == 0,
+ GMX_RELEASE_ASSERT(!haveDDAtomOrdering(*cr) || ddUsesUpdateGroups(*cr->dd)
+ || constr == nullptr || constr->numConstraintsTotal() == 0,
"Constraints in domain decomposition are only supported with update "
"groups if using GPU update.\n");
GMX_RELEASE_ASSERT(ir->eConstrAlg != ConstraintAlgorithm::Shake || constr == nullptr
}
}
}
- if (DOMAINDECOMP(cr) && bMasterState)
+ if (haveDDAtomOrdering(*cr) && bMasterState)
{
dd_collect_state(cr->dd, state, state_global);
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
/* Repartition the domain decomposition */
dd_partition_system(fplog,
{
if (useGpuForUpdate)
{
- if (bNS && (bFirstStep || DOMAINDECOMP(cr)))
+ if (bNS && (bFirstStep || haveDDAtomOrdering(*cr)))
{
integrator->set(stateGpu->getCoordinates(),
stateGpu->getVelocities(),
MASTER(cr) && mdrunOptions.verbose,
bRerunMD);
- if (bNeedRepartition && DOMAINDECOMP(cr))
+ if (bNeedRepartition && haveDDAtomOrdering(*cr))
{
dd_collect_state(cr->dd, state, state_global);
}
bExchanged = replica_exchange(fplog, cr, ms, repl_ex, state_global, enerd, state, step, t);
}
- if ((bExchanged || bNeedRepartition) && DOMAINDECOMP(cr))
+ if ((bExchanged || bNeedRepartition) && haveDDAtomOrdering(*cr))
{
dd_partition_system(fplog,
mdlog,
}
cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
- if (DOMAINDECOMP(cr) && wcycle)
+ if (haveDDAtomOrdering(*cr) && wcycle)
{
dd_cycles_add(cr->dd, cycles, ddCyclStep);
}
auto* nonConstInputrec = const_cast<t_inputrec*>(inputrec);
nonConstInputrec->nsteps = MimicCommunicator::getStepNumber();
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
// TODO: Avoid changing inputrec (#3854)
auto* nonConstInputrec = const_cast<t_inputrec*>(inputrec);
top_global,
constr ? constr->numFlexibleConstraints() : 0,
ir->nstcalcenergy,
- DOMAINDECOMP(cr),
+ haveDDAtomOrdering(*cr),
runScheduleWork->simulationWork.useGpuPme);
{
}
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
// Local state only becomes valid now.
dd_init_local_state(*cr->dd, state_global, state);
if (MASTER(cr))
{
const bool constructVsites = ((vsite != nullptr) && mdrunOptions.rerunConstructVsites);
- if (constructVsites && DOMAINDECOMP(cr))
+ if (constructVsites && haveDDAtomOrdering(*cr))
{
gmx_fatal(FARGS,
"Vsite recalculation with -rerun is not implemented with domain "
}
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
/* Repartition the domain decomposition */
const bool bMasterState = true;
gmx::HostVector<gmx::RVec> fglobal(top_global.natoms);
gmx::ArrayRef<gmx::RVec> ftemp;
gmx::ArrayRef<const gmx::RVec> flocal = f.view().force();
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
ftemp = gmx::makeArrayRef(fglobal);
dd_collect_vec(cr->dd, state->ddp_count, state->ddp_count_cg_gl, state->cg_gl, flocal, ftemp);
}
cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
- if (DOMAINDECOMP(cr) && wcycle)
+ if (haveDDAtomOrdering(*cr) && wcycle)
{
dd_cycles_add(cr->dd, cycles, ddCyclStep);
}
}
}
- if (la_max >= 0 && DOMAINDECOMP(cr))
+ if (la_max >= 0 && haveDDAtomOrdering(*cr))
{
a_max = cr->dd->globalAtomIndices[la_max];
}
top_global,
constr ? constr->numFlexibleConstraints() : 0,
ir->nstcalcenergy,
- DOMAINDECOMP(cr),
+ haveDDAtomOrdering(*cr),
thisRankHasDuty(cr, DUTY_PME));
}
else
}
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
// Local state only becomes valid now.
dd_init_local_state(*cr->dd, state_global, &ems->s);
if (confout != nullptr)
{
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
/* If bX=true, x was collected to state_global in the call above */
if (!bX)
if (MASTER(cr))
{
- if (ir->pbcType != PbcType::No && !ir->bPeriodicMols && DOMAINDECOMP(cr))
+ if (ir->pbcType != PbcType::No && !ir->bPeriodicMols && haveDDAtomOrdering(*cr))
{
/* Make molecules whole only for confout writing */
do_pbc_mtop(ir->pbcType, state->s.box, &top_global, state_global->x.rvec_array());
s1 = &ems1->s;
s2 = &ems2->s;
- if (DOMAINDECOMP(cr) && s1->ddp_count != cr->dd->ddp_count)
+ if (haveDDAtomOrdering(*cr) && s1->ddp_count != cr->dd->ddp_count)
{
gmx_incons("state mismatch in do_em_step");
}
state_change_natoms(s2, s1->natoms);
ems2->f.resize(s2->natoms);
}
- if (DOMAINDECOMP(cr) && s2->cg_gl.size() != s1->cg_gl.size())
+ if (haveDDAtomOrdering(*cr) && s2->cg_gl.size() != s1->cg_gl.size())
{
s2->cg_gl.resize(s1->cg_gl.size());
}
}
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
/* OpenMP does not supported unsigned loop variables */
#pragma omp for schedule(static) nowait
}
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
s2->ddp_count = s1->ddp_count;
s2->ddp_count_cg_gl = s1->ddp_count_cg_gl;
// Compute the buffer size of the pair list
const real bufferSize = inputrec->rlist - std::max(inputrec->rcoulomb, inputrec->rvdw);
- if (bFirst || bufferSize <= 0 || (DOMAINDECOMP(cr) && ems->s.ddp_count != ddpCountPairSearch))
+ if (bFirst || bufferSize <= 0 || (haveDDAtomOrdering(*cr) && ems->s.ddp_count != ddpCountPairSearch))
{
/* This is the first state or an old state used before the last ns */
bNS = TRUE;
> bufferSize;
}
- if (DOMAINDECOMP(cr) && bNS)
+ if (haveDDAtomOrdering(*cr) && bNS)
{
/* Repartition the domain decomposition */
em_dd_partition_system(
* and might have to sum it in parallel runs.
*/
- if (!DOMAINDECOMP(cr)
+ if (!haveDDAtomOrdering(*cr)
|| (s_min->s.ddp_count == cr->dd->ddp_count && s_b->s.ddp_count == cr->dd->ddp_count))
{
auto fm = s_min->f.view().force();
a = 0.0;
c = a + stepsize; /* reference position along line is zero */
- if (DOMAINDECOMP(cr) && s_min->s.ddp_count < cr->dd->ddp_count)
+ if (haveDDAtomOrdering(*cr) && s_min->s.ddp_count < cr->dd->ddp_count)
{
em_dd_partition_system(fplog,
mdlog,
b = 0.5 * (a + c);
}
- if (DOMAINDECOMP(cr) && s_min->s.ddp_count != cr->dd->ddp_count)
+ if (haveDDAtomOrdering(*cr) && s_min->s.ddp_count != cr->dd->ddp_count)
{
/* Reload the old state */
em_dd_partition_system(fplog,
"be available in a different form in a future version of GROMACS, "
"e.g. gmx minimize and an .mdp option.");
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
gmx_fatal(FARGS, "L_BFGS is currently not supported");
}
/* If energy is not smaller make the step smaller... */
ustep *= 0.5;
- if (DOMAINDECOMP(cr) && s_min->s.ddp_count != cr->dd->ddp_count)
+ if (haveDDAtomOrdering(*cr) && s_min->s.ddp_count != cr->dd->ddp_count)
{
/* Reload the old state */
em_dd_partition_system(fplog,
* is true!
*
* Since we are using a dynamical integrator, the only
- * decomposition is DD, so PAR(cr) and DOMAINDECOMP(cr) are
+ * decomposition is DD, so PAR(cr) and haveDDAtomOrdering(*cr) are
* synonymous. The only way for cr->nnodes > 1 to be true is
* if we are using DD. */
}
* each simulation know whether they need to participate in
* collecting the state. Otherwise, they might as well get on with
* the next thing to do. */
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
#if GMX_MPI
MPI_Bcast(&bThisReplicaExchanged, sizeof(gmx_bool), MPI_BYTE, MASTERRANK(cr), cr->mpi_comm_mygroup);
{
/* Exchange the states */
/* Collect the global state on the master node */
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_collect_state(cr->dd, state_local, state);
}
}
/* With domain decomposition the global state is distributed later */
- if (!DOMAINDECOMP(cr))
+ if (!haveDDAtomOrdering(*cr))
{
/* Copy the global state to the local state data structure */
copy_state_serial(state, state_local);
top_global,
constr ? constr->numFlexibleConstraints() : 0,
ir->nstcalcenergy,
- DOMAINDECOMP(cr),
+ haveDDAtomOrdering(*cr),
runScheduleWork->simulationWork.useGpuPme);
{
}
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
// Local state only becomes valid now.
dd_init_local_state(*cr->dd, state_global, state);
if (MASTER(cr))
{
const bool constructVsites = ((vsite != nullptr) && mdrunOptions.rerunConstructVsites);
- if (constructVsites && DOMAINDECOMP(cr))
+ if (constructVsites && haveDDAtomOrdering(*cr))
{
gmx_fatal(FARGS,
"Vsite recalculation with -rerun is not implemented with domain "
isLastStep = isLastStep || stopHandler->stoppingAfterCurrentStep(bNS);
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
/* Repartition the domain decomposition */
const bool bMasterState = true;
}
cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
- if (DOMAINDECOMP(cr) && wcycle)
+ if (haveDDAtomOrdering(*cr) && wcycle)
{
dd_cycles_add(cr->dd, cycles, ddCyclStep);
}
print_flop(fplog, nrnb_tot, &nbfs, &mflop);
}
- if (thisRankHasDuty(cr, DUTY_PP) && DOMAINDECOMP(cr))
+ if (thisRankHasDuty(cr, DUTY_PP) && haveDDAtomOrdering(*cr))
{
print_dd_statistics(cr, inputrec, fplog);
}
globalState = std::make_unique<t_state>();
}
broadcastStateWithoutDynamics(
- cr->mpiDefaultCommunicator, DOMAINDECOMP(cr), PAR(cr), globalState.get());
+ cr->mpiDefaultCommunicator, haveDDAtomOrdering(*cr), PAR(cr), globalState.get());
}
/* A parallel command line option consistency check that we can
// Enable Peer access between GPUs where available
// Only for DD, only master PP rank needs to perform setup, and only if thread MPI plus
// any of the GPU communication features are active.
- if (DOMAINDECOMP(cr) && MASTER(cr) && thisRankHasDuty(cr, DUTY_PP) && GMX_THREAD_MPI
+ if (haveDDAtomOrdering(*cr) && MASTER(cr) && thisRankHasDuty(cr, DUTY_PP) && GMX_THREAD_MPI
&& (runScheduleWork.simulationWork.useGpuHaloExchange
|| runScheduleWork.simulationWork.useGpuPmePpCommunication))
{
}
}
// Make the DD reverse topology, now that any vsites that are present are available
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_make_reverse_top(fplog, cr->dd, mtop, vsite.get(), *inputrec, domdecOptions.ddBondedChecking);
}
mdrunOptions.imdOptions,
startingBehavior);
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
GMX_RELEASE_ASSERT(fr, "fr was NULL while cr->duty was DUTY_PP");
/* This call is not included in init_domain_decomposition
int a0, a1;
gmx_domdec_t* dd = nullptr;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd = cr->dd;
a0 = 0;
double dt, w_dt;
int n, d;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
n = dd_ac1;
}
ArrayRef<t_shell> shells = shfc->shells;
const int nflexcon = shfc->nflexcon;
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
nat = dd_natoms_vsite(*cr->dd);
if (nflexcon > 0)
ArrayRef<RVec> x = xPadded.unpaddedArrayRef();
ArrayRef<RVec> v = vPadded.unpaddedArrayRef();
- if (bDoNS && inputrec->pbcType != PbcType::No && !DOMAINDECOMP(cr))
+ if (bDoNS && inputrec->pbcType != PbcType::No && !haveDDAtomOrdering(*cr))
{
/* This is the only time where the coordinates are used
* before do_force is called, which normally puts all
//! The node id for the master
#define MASTERRANK(cr) (0)
-/*! \brief Returns whether the domain decomposition machinery is active
+/*! \brief Returns whether the domain decomposition machinery is active and reorders atoms
+ *
+ * This tells whether atoms are reordered at pair search steps. When the return value
+ * is true, atoms are not in the order of the input and mtop.
*
* Note that when the return value is true, there are not necessarily
* multiple domains. The domain decomposition machinery is also active and
* reorders the atoms also with a single MPI rank, or 1 PP and 1 PME rank,
* with most integrators. Only a few special non-integrator "integrators"
* do not (yet) support the domain decomposition machinery and therefore
- * this macro is still needed.
+ * this function is still needed.
*/
-#define DOMAINDECOMP(cr) ((cr)->dd != nullptr)
+static bool inline haveDDAtomOrdering(const t_commrec& cr)
+{
+ return cr.dd != nullptr;
+}
/*! \brief Returns whether we have actual domain decomposition for the particle-particle interactions
*
UniformRealDistribution<real> uniformDist;
TabulatedNormalDistribution<real, 14> normalDist;
- const bool doDomainDecomposition = DOMAINDECOMP(cr_);
+ const bool atomOrderingIsDD = haveDDAtomOrdering(*cr_);
auto velocities = statePropagatorData_->velocitiesView().unpaddedArrayRef();
continue;
}
- const int globalAtomIdx = doDomainDecomposition ? cr_->dd->globalAtomIndices[atomIdx] : atomIdx;
+ const int globalAtomIdx = atomOrderingIsDD ? cr_->dd->globalAtomIndices[atomIdx] : atomIdx;
rng.restart(step, globalAtomIdx);
// For massive Andersen, this function is only called periodically, but we apply each time
imdSession_(imdSession),
pull_work_(pull_work)
{
- GMX_ASSERT(DOMAINDECOMP(cr), "Domain decomposition Helper constructed in non-DD simulation");
+ GMX_ASSERT(haveDDAtomOrdering(*cr),
+ "Domain decomposition Helper constructed in non-DD simulation");
}
void DomDecHelper::setup()
{
doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_distribute_dfhist(cr->dd, dfhist_.get());
}
{
doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_bcast(cr->dd, sizeof(conservedEnergyContribution_), &conservedEnergyContribution_);
dd_bcast(cr->dd, sizeof(conservedEnergyContributionStep_), &conservedEnergyContributionStep_);
globalTopology,
constr ? constr->numFlexibleConstraints() : 0,
inputrec->nstcalcenergy,
- DOMAINDECOMP(cr),
+ haveDDAtomOrdering(*cr),
runScheduleWork->simulationWork.useGpuPme)),
doShellFC_(shellfc_ != nullptr),
nextNSStep_(-1),
{
std::fill(lambda_.begin(), lambda_.end(), 0);
- if (doShellFC_ && !DOMAINDECOMP(cr))
+ if (doShellFC_ && !haveDDAtomOrdering(*cr))
{
// This was done in mdAlgorithmsSetupAtomData(), but shellfc
// won't be available outside this element.
gmx_multisim_t* ms = nullptr;
- if (!DOMAINDECOMP(cr_) && (flags & GMX_FORCE_NS) && inputrecDynamicBox(inputrec_))
+ if (!haveDDAtomOrdering(*cr_) && (flags & GMX_FORCE_NS) && inputrecDynamicBox(inputrec_))
{
// TODO: Correcting the box is done in DomDecHelper (if using DD) or here (non-DD simulations).
// Think about unifying this responsibility, could this be done in one place?
&checkpointData.value());
doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_bcast(cr->dd, sizeof(int), &freeEnergyPerturbationData_->currentFEPState_);
dd_bcast(cr->dd,
// When using domain decomposition, statePropagatorData might not have the initial
// box yet, so we get it from the legacy state_global instead.
// TODO: Make sure we have a valid state in statePropagatorData at all times (#3421)
- if (DOMAINDECOMP(legacySimulatorData->cr))
+ if (haveDDAtomOrdering(*legacySimulatorData->cr))
{
if (MASTER(legacySimulatorData->cr))
{
{
doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_bcast(cr->dd, int(sizeof(real)), &etaVelocity_);
dd_bcast(cr->dd, int(sizeof(real)), &invMass_);
}
for (auto& group : noseHooverGroups_)
{
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
group.broadcastCheckpointValues(cr->dd);
}
{
doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_bcast(cr->dd, sizeof(boxVelocity_), boxVelocity_);
dd_bcast(cr->dd, sizeof(boxRel_), boxRel_);
}
double cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
- if (DOMAINDECOMP(cr) && wcycle)
+ if (haveDDAtomOrdering(*cr) && wcycle)
{
dd_cycles_add(cr->dd, static_cast<float>(cycles), ddCyclStep);
}
registerWithInfrastructureAndSignallers(trajectoryElement.get());
// Build domdec helper (free energy element is a client, so keep this after it is built)
- if (DOMAINDECOMP(legacySimulatorData_->cr))
+ if (haveDDAtomOrdering(*legacySimulatorData_->cr))
{
algorithm.domDecHelper_ =
domDecHelperBuilder_.build(legacySimulatorData_->mdrunOptions.verbose,
{
bool stateHasVelocities;
// Local state only becomes valid now.
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_init_local_state(*cr->dd, globalState, localState);
stateHasVelocities = ((localState->flags & enumValueToBitMask(StateEntry::V)) != 0);
changePinningPolicy(&x_, gmx::PinningPolicy::PinnedIfSupported);
}
- if (DOMAINDECOMP(cr) && MASTER(cr))
+ if (haveDDAtomOrdering(*cr) && MASTER(cr))
{
xGlobal_.resizeWithPadding(totalNumAtoms_);
previousXGlobal_.resizeWithPadding(totalNumAtoms_);
void StatePropagatorData::Element::saveCheckpointState(std::optional<WriteCheckpointData> checkpointData,
const t_commrec* cr)
{
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
// Collect state from all ranks into global vectors
dd_collect_vec(cr->dd,
}
// Copy data to global state to be distributed by DD at setup stage
- if (DOMAINDECOMP(cr) && MASTER(cr))
+ if (haveDDAtomOrdering(*cr) && MASTER(cr))
{
updateGlobalState(statePropagatorData_->globalState_,
statePropagatorData_->xGlobal_,
statePropagatorData_->cgGl_);
}
// Everything is local - copy global vectors to local ones
- if (!DOMAINDECOMP(cr))
+ if (!haveDDAtomOrdering(*cr))
{
statePropagatorData_->x_.resizeWithPadding(statePropagatorData_->totalNumAtoms_);
statePropagatorData_->v_.resizeWithPadding(statePropagatorData_->totalNumAtoms_);
GMX_ASSERT(localStateBackupValid_, "Final trajectory writing called, but no state saved.");
wallcycle_start(mdoutf_get_wcycle(outf), WallCycleCounter::Traj);
- if (DOMAINDECOMP(cr_))
+ if (haveDDAtomOrdering(*cr_))
{
auto globalXRef =
MASTER(cr_) ? statePropagatorData_->globalState_->x : gmx::ArrayRef<gmx::RVec>();
VirtualSitesHandler* vsite) :
globalTopology_(globalTopology), localTopology_(localTopology), clients_(std::move(clients))
{
- if (!DOMAINDECOMP(cr))
+ if (!haveDDAtomOrdering(*cr))
{
// Generate and initialize new topology
// Note that most of the data needed for the constructor is used here -
{
doCheckpointData(&checkpointData.value());
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_bcast(cr->dd, xi_.size() * sizeof(real), xi_.data());
dd_bcast(cr->dd, xiVelocities_.size() * sizeof(real), xiVelocities_.data());
{
doCheckpointData<CheckpointDataOperation::Read>(&checkpointData.value());
}
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
dd_bcast(cr->dd,
ssize(temperatureCouplingIntegral_) * int(sizeof(double)),
case KernelType::Cpu4xN_Simd_2xNN:
#if GMX_SIMD
return "SIMD";
-#else // GMX_SIMD
+#else // GMX_SIMD
return "not available";
#endif // GMX_SIMD
case KernelType::Gpu8x8x8: return "GPU";
auto pairlistSets = std::make_unique<PairlistSets>(
pairlistParams, haveMultipleDomains, minimumIlistCountForGpuBalancing);
- auto pairSearch =
- std::make_unique<PairSearch>(inputrec.pbcType,
- EI_TPI(inputrec.eI),
- DOMAINDECOMP(commrec) ? &commrec->dd->numCells : nullptr,
- DOMAINDECOMP(commrec) ? domdec_zones(commrec->dd) : nullptr,
- pairlistParams.pairlistType,
- bFEP_NonBonded,
- gmx_omp_nthreads_get(ModuleMultiThread::Pairsearch),
- pinPolicy);
+ auto pairSearch = std::make_unique<PairSearch>(
+ inputrec.pbcType,
+ EI_TPI(inputrec.eI),
+ haveDDAtomOrdering(*commrec) ? &commrec->dd->numCells : nullptr,
+ haveDDAtomOrdering(*commrec) ? domdec_zones(commrec->dd) : nullptr,
+ pairlistParams.pairlistType,
+ bFEP_NonBonded,
+ gmx_omp_nthreads_get(ModuleMultiThread::Pairsearch),
+ pinPolicy);
return std::make_unique<nonbonded_verlet_t>(
std::move(pairlistSets), std::move(pairSearch), std::move(nbat), kernelSetup, gpu_nbv, wcycle);
/* Does rlist fit in the box? */
bBox = (gmx::square(rlist_new) < max_cutoff2(ir->pbcType, box));
bDD = true;
- if (bBox && DOMAINDECOMP(cr))
+ if (bBox && haveDDAtomOrdering(*cr))
{
/* Currently (as of July 2020), the code in this if clause is never executed.
* increaseNstlist(...) is only called from prepare_verlet_scheme, which in turns
- * gets called by the runner _before_ setting up DD. DOMAINDECOMP(cr) will therefore
- * always be false here. See #3334.
+ * gets called by the runner _before_ setting up DD. haveDDAtomOrdering(*cr) will
+ * therefore always be false here. See #3334.
*/
/* Check if rlist fits in the domain decomposition */
if (inputrec2nboundeddim(ir) < DIM)
maxNumThreads);
}
- if (cr != nullptr && DOMAINDECOMP(cr))
+ if (cr != nullptr && haveDDAtomOrdering(*cr))
{
/* Set up the global to local atom mapping for PBC atoms */
for (pull_group_work_t& group : pull->group)
* when we have an external pull potential, since then the external
* potential provider expects each rank to have the coordinate.
*/
- comm->bParticipateAll = (cr == nullptr || !DOMAINDECOMP(cr) || cr->dd->nnodes <= 32
+ comm->bParticipateAll = (cr == nullptr || !haveDDAtomOrdering(*cr) || cr->dd->nnodes <= 32
|| pull->numCoordinatesWithExternalPotential > 0
|| getenv("GMX_PULL_PARTICIPATE_ALL") != nullptr);
/* This sub-commicator is not used with comm->bParticipateAll,
/**************************************************************************/
/* Done communicating, we can start to count cycles for the load balancing now ... */
- if (DOMAINDECOMP(cr))
+ if (haveDDAtomOrdering(*cr))
{
ddReopenBalanceRegionCpu(cr->dd);
}
{
pull_set_pbcatoms(cr, pull, x, comm->pbcAtomBuffer);
- if (cr != nullptr && DOMAINDECOMP(cr))
+ if (cr != nullptr && haveDDAtomOrdering(*cr))
{
/* We can keep these PBC reference coordinates fixed for nstlist
* steps, since atoms won't jump over PBC.
}
// All ranks wait for the update to finish.
// tMPI ranks are depending on structures that may have just been updated.
- if (DOMAINDECOMP(&cr))
+ if (haveDDAtomOrdering(cr))
{
// Note: this assumes that all ranks are hitting this line, which is not generally true.
// I need to find the right subcommunicator. What I really want is a _scoped_ communicator...
// Center of mass to return for the site. Currently the only form of site
// implemented is as a global atomic coordinate.
gmx::RVec r = { 0, 0, 0 };
- if (DOMAINDECOMP(&cr)) // Domain decomposition
+ if (haveDDAtomOrdering(cr)) // Domain decomposition
{
// Get global-to-local indexing structure
auto* crossRef = cr.dd->ga2la;
swapstateIons_t* gs;
swaphistory_t* swapstate = nullptr;
- if ((PAR(cr)) && !DOMAINDECOMP(cr))
+ if ((PAR(cr)) && !haveDDAtomOrdering(*cr))
{
gmx_fatal(FARGS, "Position swapping is only implemented for domain decomposition!");
}