Use const refs where possible in global_stat. Use ArrayRef for
signalBuffer and return an int instead of passing pointer to int.
Also movemost variable definitions to closer to their first use.
if (PAR(cr))
{
wallcycle_start(wcycle, ewcMoveE);
if (PAR(cr))
{
wallcycle_start(wcycle, ewcMoveE);
cr,
enerd,
force_vir,
shake_vir,
cr,
enerd,
force_vir,
shake_vir,
ekind,
constraintsRmsdData,
bStopCM ? vcm : nullptr,
ekind,
constraintsRmsdData,
bStopCM ? vcm : nullptr,
- signalBuffer.size(),
- signalBuffer.data(),
*bSumEkinhOld,
flags);
wallcycle_stop(wcycle, ewcMoveE);
*bSumEkinhOld,
flags);
wallcycle_stop(wcycle, ewcMoveE);
-void global_stat(const gmx_global_stat* gs,
+void global_stat(const gmx_global_stat& gs,
const t_commrec* cr,
gmx_enerdata_t* enerd,
tensor fvir,
tensor svir,
const t_commrec* cr,
gmx_enerdata_t* enerd,
tensor fvir,
tensor svir,
- const t_inputrec* inputrec,
+ const t_inputrec& inputrec,
gmx_ekindata_t* ekind,
gmx::ArrayRef<real> constraintsRmsdData,
t_vcm* vcm,
gmx_ekindata_t* ekind,
gmx::ArrayRef<real> constraintsRmsdData,
t_vcm* vcm,
+ gmx::ArrayRef<real> sig,
bool bSumEkinhOld,
int flags)
/* instead of current system, gmx_booleans for summing virial, kinetic energy, and other terms */
{
bool bSumEkinhOld,
int flags)
/* instead of current system, gmx_booleans for summing virial, kinetic energy, and other terms */
{
- t_bin* rb;
- int * itc0, *itc1;
- int ie = 0, ifv = 0, isv = 0, irmsd = 0;
+ int ie = 0, ifv = 0, isv = 0, irmsd = 0;
int idedl = 0, idedlo = 0, idvdll = 0, idvdlnl = 0, iepl = 0, icm = 0, imass = 0, ica = 0, inb = 0;
int idedl = 0, idedlo = 0, idvdll = 0, idvdlnl = 0, iepl = 0, icm = 0, imass = 0, ica = 0, inb = 0;
- int isig = -1;
- int icj = -1, ici = -1, icx = -1;
- int inn[static_cast<int>(NonBondedEnergyTerms::Count)];
- real copyenerd[F_NRE];
- int nener, j;
- double nb;
- gmx_bool bVV, bTemp, bEner, bPres, bConstrVir, bEkinAveVel, bReadEkin;
- bool checkNumberOfBondedInteractions = (flags & CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS) != 0;
+ int isig = -1;
+ int icj = -1, ici = -1, icx = -1;
- bVV = EI_VV(inputrec->eI);
- bTemp = ((flags & CGLO_TEMPERATURE) != 0);
- bEner = ((flags & CGLO_ENERGY) != 0);
- bPres = ((flags & CGLO_PRESSURE) != 0);
- bConstrVir = ((flags & CGLO_CONSTRAINT) != 0);
- bEkinAveVel = (inputrec->eI == IntegrationAlgorithm::VV
- || (inputrec->eI == IntegrationAlgorithm::VVAK && bPres));
- bReadEkin = ((flags & CGLO_READEKIN) != 0);
+ bool checkNumberOfBondedInteractions = (flags & CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS) != 0;
+ bool bVV = EI_VV(inputrec.eI);
+ bool bTemp = ((flags & CGLO_TEMPERATURE) != 0);
+ bool bEner = ((flags & CGLO_ENERGY) != 0);
+ bool bPres = ((flags & CGLO_PRESSURE) != 0);
+ bool bConstrVir = ((flags & CGLO_CONSTRAINT) != 0);
+ bool bEkinAveVel = (inputrec.eI == IntegrationAlgorithm::VV
+ || (inputrec.eI == IntegrationAlgorithm::VVAK && bPres));
+ bool bReadEkin = ((flags & CGLO_READEKIN) != 0);
- rb = gs->rb;
- itc0 = gs->itc0;
- itc1 = gs->itc1;
+ t_bin* rb = gs.rb;
+ int* itc0 = gs.itc0;
+ int* itc1 = gs.itc1;
communicated and summed when they need to be, to avoid repeating
the sums and overcounting. */
communicated and summed when they need to be, to avoid repeating
the sums and overcounting. */
- nener = filter_enerdterm(enerd->term, TRUE, copyenerd, bTemp, bPres, bEner);
+ std::array<real, F_NRE> copyenerd;
+ int nener = filter_enerdterm(enerd->term, TRUE, copyenerd.data(), bTemp, bPres, bEner);
/* First, the data that needs to be communicated with velocity verlet every time
This is just the constraint virial.*/
/* First, the data that needs to be communicated with velocity verlet every time
This is just the constraint virial.*/
- for (j = 0; (j < inputrec->opts.ngtc); j++)
+ for (int j = 0; (j < inputrec.opts.ngtc); j++)
ifv = add_binr(rb, DIM * DIM, fvir[0]);
}
ifv = add_binr(rb, DIM * DIM, fvir[0]);
}
+ gmx::EnumerationArray<NonBondedEnergyTerms, int> inn;
- ie = add_binr(rb, nener, copyenerd);
+ ie = add_binr(rb, nener, copyenerd.data());
if (!constraintsRmsdData.empty())
{
irmsd = add_binr(rb, 2, constraintsRmsdData.data());
}
if (!constraintsRmsdData.empty())
{
irmsd = add_binr(rb, 2, constraintsRmsdData.data());
}
-
- for (j = 0; (j < static_cast<int>(NonBondedEnergyTerms::Count)); j++)
+ for (auto key : gmx::keysOf(inn))
- inn[j] = add_binr(rb, enerd->grpp.nener, enerd->grpp.energyGroupPairTerms[j].data());
+ inn[key] = add_binr(rb, enerd->grpp.nener, enerd->grpp.energyGroupPairTerms[key].data());
- if (inputrec->efep != FreeEnergyPerturbationType::No)
+ if (inputrec.efep != FreeEnergyPerturbationType::No)
{
idvdll = add_bind(rb, enerd->dvdl_lin);
idvdlnl = add_bind(rb, enerd->dvdl_nonlin);
{
idvdll = add_bind(rb, enerd->dvdl_lin);
idvdlnl = add_bind(rb, enerd->dvdl_nonlin);
if (checkNumberOfBondedInteractions)
{
GMX_RELEASE_ASSERT(DOMAINDECOMP(cr),
if (checkNumberOfBondedInteractions)
{
GMX_RELEASE_ASSERT(DOMAINDECOMP(cr),
nb = numBondedInteractions(*cr->dd);
inb = add_bind(rb, 1, &nb);
}
nb = numBondedInteractions(*cr->dd);
inb = add_bind(rb, 1, &nb);
}
- isig = add_binr(rb, nsig, sig);
+ isig = add_binr(rb, sig);
- /* Global sum it all */
- if (debug)
- {
- fprintf(debug, "Summing %d energies\n", rb->maxreal);
- }
sum_bin(rb, cr);
/* Extract all the data locally */
sum_bin(rb, cr);
/* Extract all the data locally */
- for (j = 0; (j < inputrec->opts.ngtc); j++)
+ for (int j = 0; (j < inputrec.opts.ngtc); j++)
- extract_binr(rb, ie, nener, copyenerd);
+ extract_binr(rb, ie, nener, copyenerd.data());
if (!constraintsRmsdData.empty())
{
extract_binr(rb, irmsd, constraintsRmsdData);
}
if (!constraintsRmsdData.empty())
{
extract_binr(rb, irmsd, constraintsRmsdData);
}
-
- for (j = 0; (j < static_cast<int>(NonBondedEnergyTerms::Count)); j++)
+ for (auto key : gmx::keysOf(inn))
- extract_binr(rb, inn[j], enerd->grpp.nener, enerd->grpp.energyGroupPairTerms[j].data());
+ extract_binr(rb, inn[key], enerd->grpp.nener, enerd->grpp.energyGroupPairTerms[key].data());
- if (inputrec->efep != FreeEnergyPerturbationType::No)
+ if (inputrec.efep != FreeEnergyPerturbationType::No)
{
extract_bind(rb, idvdll, enerd->dvdl_lin);
extract_bind(rb, idvdlnl, enerd->dvdl_nonlin);
{
extract_bind(rb, idvdll, enerd->dvdl_lin);
extract_bind(rb, idvdlnl, enerd->dvdl_nonlin);
- filter_enerdterm(copyenerd, FALSE, enerd->term, bTemp, bPres, bEner);
+ filter_enerdterm(copyenerd.data(), FALSE, enerd->term, bTemp, bPres, bEner);
setNumberOfBondedInteractionsOverAllDomains(*cr->dd, gmx::roundToInt(nb));
}
setNumberOfBondedInteractionsOverAllDomains(*cr->dd, gmx::roundToInt(nb));
}
- extract_binr(rb, isig, nsig, sig);
+ extract_binr(rb, isig, sig);
void global_stat_destroy(gmx_global_stat_t gs);
/*! \brief All-reduce energy-like quantities over cr->mpi_comm_mysim */
void global_stat_destroy(gmx_global_stat_t gs);
/*! \brief All-reduce energy-like quantities over cr->mpi_comm_mysim */
-void global_stat(const gmx_global_stat* gs,
+void global_stat(const gmx_global_stat& gs,
const t_commrec* cr,
gmx_enerdata_t* enerd,
tensor fvir,
tensor svir,
const t_commrec* cr,
gmx_enerdata_t* enerd,
tensor fvir,
tensor svir,
- const t_inputrec* inputrec,
+ const t_inputrec& inputrec,
gmx_ekindata_t* ekind,
gmx::ArrayRef<real> constraintsRmsdData,
t_vcm* vcm,
gmx_ekindata_t* ekind,
gmx::ArrayRef<real> constraintsRmsdData,
t_vcm* vcm,
+ gmx::ArrayRef<real> sig,
bool bSumEkinhOld,
int flags);
bool bSumEkinhOld,
int flags);
{
wallcycle_start(wcycle, ewcMoveE);
{
wallcycle_start(wcycle, ewcMoveE);
cr,
enerd,
force_vir,
shake_vir,
cr,
enerd,
force_vir,
shake_vir,
nullptr,
gmx::ArrayRef<real>{},
nullptr,
nullptr,
gmx::ArrayRef<real>{},
nullptr,
+ std::vector<real>(1, terminate),
FALSE,
CGLO_ENERGY | CGLO_PRESSURE | CGLO_CONSTRAINT);
FALSE,
CGLO_ENERGY | CGLO_PRESSURE | CGLO_CONSTRAINT);