#cmakedefine01 HAVE_FSEEKO
/* Define to 1 if _fseeki64 (and presumably _fseeki64) exists and is declared. */
+//NOLINTNEXTLINE(bugprone-reserved-identifier)
#cmakedefine01 HAVE__FSEEKI64
/* Have io.h (windows)*/
#cmakedefine01 HAVE_MEMALIGN
/* Define to 1 if you have the MSVC _aligned_malloc() function. */
+//NOLINTNEXTLINE(bugprone-reserved-identifier)
#cmakedefine01 HAVE__ALIGNED_MALLOC
/* Define to 1 if you have the clock_gettime() function. */
#cmakedefine01 HAVE_FSYNC
/* Define to 1 if you have the Windows _commit() function. */
+//NOLINTNEXTLINE(bugprone-reserved-identifier)
#cmakedefine01 HAVE__COMMIT
/* Define to 1 if you have the fileno() function. */
#cmakedefine01 HAVE_FILENO
/* Define to 1 if you have the _fileno() function. */
+//NOLINTNEXTLINE(bugprone-reserved-identifier)
#cmakedefine01 HAVE__FILENO
/* Define to 1 if you have the sigaction() function. */
* malloc.h or xmmintrin.h, and 0 otherwise. Note that you need to
* conditionally include the three headers too before using _mm_malloc().
*/
+//NOLINTNEXTLINE(bugprone-reserved-identifier)
#cmakedefine01 HAVE__MM_MALLOC
/* Define if SIGUSR1 is present */
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2009,2010,2014,2015,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/utility/fatalerror.h"
#include "domdec_internal.h"
+#include "math.h"
/*! \brief Calculates the average and standard deviation in 3D of atoms */
static void calc_pos_av_stddev(gmx::ArrayRef<const gmx::RVec> x, rvec av, rvec stddev, const MPI_Comm* mpiCommunicator)
/*! \brief Determines if dimensions require triclinic treatment and stores this info in ddbox */
static void set_tric_dir(const ivec* dd_nc, gmx_ddbox_t* ddbox, const matrix box)
{
- int npbcdim, d, i, j;
- rvec *v, *normal;
- real dep, inv_skew_fac2;
-
- npbcdim = ddbox->npbcdim;
- normal = ddbox->normal;
- for (d = 0; d < DIM; d++)
+ int npbcdim = ddbox->npbcdim;
+ rvec* normal = ddbox->normal;
+ for (int d = 0; d < DIM; d++)
{
ddbox->tric_dir[d] = 0;
- for (j = d + 1; j < npbcdim; j++)
+ for (int j = d + 1; j < npbcdim; j++)
{
if (box[j][d] != 0)
{
*/
if (ddbox->tric_dir[d])
{
- inv_skew_fac2 = 1;
- v = ddbox->v[d];
+ real inv_skew_fac2 = 1;
+ rvec* v = ddbox->v[d];
if (d == XX || d == YY)
{
/* Normalize such that the "diagonal" is 1 */
svmul(1 / box[d + 1][d + 1], box[d + 1], v[d + 1]);
- for (i = 0; i < d; i++)
+ for (int i = 0; i < d; i++)
{
v[d + 1][i] = 0;
}
/* Normalize such that the "diagonal" is 1 */
svmul(1 / box[d + 2][d + 2], box[d + 2], v[d + 2]);
/* Set v[d+2][d+1] to zero by shifting along v[d+1] */
- dep = v[d + 2][d + 1] / v[d + 1][d + 1];
- for (i = 0; i < DIM; i++)
+ const real dep = v[d + 2][d + 1] / v[d + 1][d + 1];
+ for (int i = 0; i < DIM; i++)
{
v[d + 2][i] -= dep * v[d + 1][i];
}
if (debug)
{
fprintf(debug, "box[%d] %.3f %.3f %.3f\n", d, box[d][XX], box[d][YY], box[d][ZZ]);
- for (i = d + 1; i < DIM; i++)
+ for (int i = d + 1; i < DIM; i++)
{
fprintf(debug, " v[%d] %.3f %.3f %.3f\n", i, v[i][XX], v[i][YY], v[i][ZZ]);
}
}
ddbox->skew_fac[d] = 1.0 / std::sqrt(inv_skew_fac2);
/* Set the normal vector length to skew_fac */
- dep = ddbox->skew_fac[d] / norm(normal[d]);
+ const real dep = ddbox->skew_fac[d] / norm(normal[d]);
svmul(dep, normal[d], normal[d]);
if (debug)
{
ddbox->skew_fac[d] = 1;
- for (i = 0; i < DIM; i++)
+ for (int i = 0; i < DIM; i++)
{
clear_rvec(ddbox->v[d][i]);
ddbox->v[d][i][i] = 1;
gmx_ddbox_t* ddbox)
{
rvec av, stddev;
- real b0, b1;
- int d;
ddbox->npbcdim = numPbcDimensions;
ddbox->nboundeddim = numBoundedDimensions;
- for (d = 0; d < numBoundedDimensions; d++)
+ for (int d = 0; d < numBoundedDimensions; d++)
{
ddbox->box0[d] = 0;
ddbox->box_size[d] = box[d][d];
* gives a uniform load for a rectangular block of cg's.
* For a sphere it is not a bad approximation for 4x1x1 up to 4x2x2.
*/
- for (d = ddbox->nboundeddim; d < DIM; d++)
+ for (int d = ddbox->nboundeddim; d < DIM; d++)
{
- b0 = av[d] - GRID_STDDEV_FAC * stddev[d];
- b1 = av[d] + GRID_STDDEV_FAC * stddev[d];
+ const real b0 = av[d] - GRID_STDDEV_FAC * stddev[d];
+ const real b1 = av[d] + GRID_STDDEV_FAC * stddev[d];
if (debug)
{
fprintf(debug, "Setting global DD grid boundaries to %f - %f\n", b0, b1);
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "atomdistribution.h"
#include "domdec_internal.h"
+#include "math.h"
#include "utility.h"
static void set_pme_maxshift(gmx_domdec_t* dd,
const gmx_ddbox_t* ddbox,
const real* cellFrac)
{
- gmx_domdec_comm_t* comm;
- int nc, ns, s;
- int * xmin, *xmax;
- real range, pme_boundary;
- int sh;
+ int sh = 0;
- comm = dd->comm;
- nc = dd->numCells[ddpme->dim];
- ns = ddpme->nslab;
+ gmx_domdec_comm_t* comm = dd->comm;
+ const int nc = dd->numCells[ddpme->dim];
+ const int ns = ddpme->nslab;
if (!ddpme->dim_match)
{
/* We need to check for all pme nodes which nodes they
* could possibly need to communicate with.
*/
- xmin = ddpme->pp_min;
- xmax = ddpme->pp_max;
+ const int* xmin = ddpme->pp_min;
+ const int* xmax = ddpme->pp_max;
/* Allow for atoms to be maximally 2/3 times the cut-off
* out of their DD cell. This is a reasonable balance between
* between performance and support for most charge-group/cut-off
* combinations.
*/
- range = 2.0 / 3.0 * comm->systemInfo.cutoff / ddbox->box_size[ddpme->dim];
+ real range = 2.0 / 3.0 * comm->systemInfo.cutoff / ddbox->box_size[ddpme->dim];
/* Avoid extra communication when we are exactly at a boundary */
range *= 0.999;
- sh = 1;
- for (s = 0; s < ns; s++)
+ int sh = 1;
+ for (int s = 0; s < ns; s++)
{
/* PME slab s spreads atoms between box frac. s/ns and (s+1)/ns */
- pme_boundary = static_cast<real>(s) / ns;
+ real pme_boundary = static_cast<real>(s) / ns;
while (sh + 1 < ns
&& ((s - (sh + 1) >= 0 && cellFrac[xmax[s - (sh + 1)] + 1] + range > pme_boundary)
|| (s - (sh + 1) < 0 && cellFrac[xmax[s - (sh + 1) + ns] + 1] - 1 + range > pme_boundary)))
static void check_box_size(const gmx_domdec_t* dd, const gmx_ddbox_t* ddbox)
{
- int d, dim;
-
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
- dim = dd->dim[d];
+ const int dim = dd->dim[d];
if (dim < ddbox->nboundeddim
&& ddbox->box_size[dim] * ddbox->skew_fac[dim]
< dd->numCells[dim] * dd->comm->cellsize_limit * DD_CELL_MARGIN)
real grid_jump_limit(const gmx_domdec_comm_t* comm, real cutoff, int dim_ind)
{
- real grid_jump_limit;
-
/* The distance between the boundaries of cells at distance
* x+-1,y+-1 or y+-1,z+-1 is limited by the cut-off restrictions
* and by the fact that cells should not be shifted by more than
* half their size, such that cg's only shift by one cell
* at redecomposition.
*/
- grid_jump_limit = comm->cellsize_limit;
+ real grid_jump_limit = comm->cellsize_limit;
if (!comm->bVacDLBNoLimit)
{
if (comm->bPMELoadBalDLBLimits)
*/
static real cellsize_min_dlb(gmx_domdec_comm_t* comm, int dim_ind, int dim)
{
- real cellsize_min;
-
- cellsize_min = comm->cellsize_min[dim];
+ real cellsize_min = comm->cellsize_min[dim];
if (!comm->bVacDLBNoLimit)
{
real cellsize_limit_f,
int range[])
{
- gmx_domdec_comm_t* comm;
- real halfway, cellsize_limit_f_i, region_size;
- gmx_bool bLastHi = FALSE;
- int nrange[] = { range[0], range[1] };
+ gmx_bool bLastHi = FALSE;
+ int nrange[] = { range[0], range[1] };
- region_size = rowMaster->cellFrac[range[1]] - rowMaster->cellFrac[range[0]];
+ const real region_size = rowMaster->cellFrac[range[1]] - rowMaster->cellFrac[range[0]];
GMX_ASSERT(region_size >= (range[1] - range[0]) * cellsize_limit_f,
"The region should fit all cells at minimum size");
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
const int ncd = dd->numCells[dim];
{
rowMaster->isCellMin[i] = false;
}
- int nmin = 0;
- int nmin_old;
+ int nmin = 0;
+ int nmin_old = 0;
do
{
nmin_old = nmin;
if (!rowMaster->isCellMin[i])
{
cell_size[i] *= fac;
- if (!dimHasPbc && (i == 0 || i == dd->numCells[dim] - 1))
- {
- cellsize_limit_f_i = 0;
- }
- else
- {
- cellsize_limit_f_i = cellsize_limit_f;
- }
+ const real cellsize_limit_f_i =
+ (!dimHasPbc && (i == 0 || i == dd->numCells[dim] - 1)) ? 0 : cellsize_limit_f;
if (cell_size[i] < cellsize_limit_f_i)
{
rowMaster->isCellMin[i] = true;
*/
for (int i = range[0] + 1; i < range[1]; i++)
{
- halfway = 0.5 * (rowMaster->oldCellFrac[i] + rowMaster->oldCellFrac[i - 1]);
+ real halfway = 0.5 * (rowMaster->oldCellFrac[i] + rowMaster->oldCellFrac[i - 1]);
if (rowMaster->cellFrac[i] < halfway)
{
rowMaster->cellFrac[i] = halfway;
{
real load_aver = comm->load[d].sum_m / ncd;
real change_max = 0;
- real load_i;
- real change;
for (int i = 0; i < ncd; i++)
{
/* Determine the relative imbalance of cell i */
- load_i = comm->load[d].load[i * comm->load[d].nload + 2];
- real imbalance = (load_i - load_aver) / (load_aver > 0 ? load_aver : 1);
+ const real load_i = comm->load[d].load[i * comm->load[d].nload + 2];
+ const real imbalance = (load_i - load_aver) / (load_aver > 0 ? load_aver : 1);
/* Determine the change of the cell size using underrelaxation */
- change = -c_relax * imbalance;
- change_max = std::max(change_max, std::max(change, -change));
+ const real change = -c_relax * imbalance;
+ change_max = std::max(change_max, std::max(change, -change));
}
/* Limit the amount of scaling.
* We need to use the same rescaling for all cells in one row,
for (int i = 0; i < ncd; i++)
{
/* Determine the relative imbalance of cell i */
- load_i = comm->load[d].load[i * comm->load[d].nload + 2];
- real imbalance = (load_i - load_aver) / (load_aver > 0 ? load_aver : 1);
+ const real load_i = comm->load[d].load[i * comm->load[d].nload + 2];
+ const real imbalance = (load_i - load_aver) / (load_aver > 0 ? load_aver : 1);
/* Determine the change of the cell size using underrelaxation */
- change = -sc * imbalance;
+ const real change = -sc * imbalance;
cell_size[i] = (rowMaster->cellFrac[i + 1] - rowMaster->cellFrac[i]) * (1 + change);
}
}
static void set_dd_cell_sizes_dlb_nochange(gmx_domdec_t* dd, const gmx_ddbox_t* ddbox)
{
- int d;
-
/* This function assumes the box is static and should therefore
* not be called when the box has changed since the last
* call to dd_partition_system.
*/
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
relative_to_absolute_cell_bounds(dd, ddbox, d);
}
int64_t step,
gmx_wallcycle_t wcycle)
{
- gmx_domdec_comm_t* comm;
- int dim;
-
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
if (bDoDLB)
{
}
/* Set the dimensions for which no DD is used */
- for (dim = 0; dim < DIM; dim++)
+ for (int dim = 0; dim < DIM; dim++)
{
if (dd->numCells[dim] == 1)
{
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "atomdistribution.h"
#include "cellsizes.h"
#include "domdec_internal.h"
+#include "math.h"
#include "utility.h"
static void distributeVecSendrecv(gmx_domdec_t* dd,
{
// Use double for the sums to avoid natoms^2 overflowing
// (65537^2 > 2^32)
- int nat_sum, nat_min, nat_max;
- double nat2_sum;
-
- nat_sum = 0;
- nat2_sum = 0;
- nat_min = ma.domainGroups[0].numAtoms;
- nat_max = ma.domainGroups[0].numAtoms;
+ int nat_sum = 0;
+ double nat2_sum = 0;
+ int nat_min = ma.domainGroups[0].numAtoms;
+ int nat_max = ma.domainGroups[0].numAtoms;
for (int rank = 0; rank < dd->nnodes; rank++)
{
int numAtoms = ma.domainGroups[rank].numAtoms;
const gmx_ddbox_t* ddbox,
rvec pos[])
{
- AtomDistribution* ma = dd->ma.get();
- int * ibuf, buf2[2] = { 0, 0 };
+ AtomDistribution* ma = dd->ma.get();
+ int * ibuf = nullptr, buf2[2] = { 0, 0 };
gmx_bool bMaster = DDMASTER(dd);
std::vector<std::vector<int>> groupIndices;
}
ibuf = ma->intBuffer.data();
}
- else
- {
- ibuf = nullptr;
- }
dd_scatter(dd, 2 * sizeof(int), ibuf, buf2);
dd->ncg_home = buf2[0];
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/utility/gmxassert.h"
#include "domdec_internal.h"
+#include "math.h"
/*! \brief Struct for timing the region for dynamic load balancing */
struct BalanceRegion
//! Accumulates flop counts for force calculations.
static double force_flop_count(const t_nrnb* nrnb)
{
- int i;
- double sum;
- const char* name;
-
- sum = 0;
- for (i = 0; i < eNR_NBKERNEL_FREE_ENERGY; i++)
+ double sum = 0;
+ for (int i = 0; i < eNR_NBKERNEL_FREE_ENERGY; i++)
{
/* To get closer to the real timings, we half the count
* for the normal loops and again half it for water loops.
*/
- name = nrnb_str(i);
+ const char* name = nrnb_str(i);
if (strstr(name, "W3") != nullptr || strstr(name, "W4") != nullptr)
{
sum += nrnb->n[i] * 0.25 * cost_nrnb(i);
sum += nrnb->n[i] * 0.50 * cost_nrnb(i);
}
}
- for (i = eNR_NBKERNEL_FREE_ENERGY; i <= eNR_NB14; i++)
+ for (int i = eNR_NBKERNEL_FREE_ENERGY; i <= eNR_NB14; i++)
{
- name = nrnb_str(i);
+ const char* name = nrnb_str(i);
if (strstr(name, "W3") != nullptr || strstr(name, "W4") != nullptr)
{
sum += nrnb->n[i] * cost_nrnb(i);
}
}
- for (i = eNR_BONDS; i <= eNR_WALLS; i++)
+ for (int i = eNR_BONDS; i <= eNR_WALLS; i++)
{
sum += nrnb->n[i] * cost_nrnb(i);
}
void clear_dd_cycle_counts(gmx_domdec_t* dd)
{
- int i;
-
- for (i = 0; i < ddCyclNr; i++)
+ for (int i = 0; i < ddCyclNr; i++)
{
dd->comm->cycl[i] = 0;
dd->comm->cycl_n[i] = 0;
#include "domdec_internal.h"
#include "domdec_setup.h"
#include "domdec_vsite.h"
+#include "math.h"
#include "redistribute.h"
#include "utility.h"
int ddglatnr(const gmx_domdec_t* dd, int i)
{
- int atnr;
+ int atnr = 0;
if (dd == nullptr)
{
void dd_store_state(gmx_domdec_t* dd, t_state* state)
{
- int i;
-
if (state->ddp_count != dd->ddp_count)
{
gmx_incons("The MD state does not match the domain decomposition state");
}
state->cg_gl.resize(dd->ncg_home);
- for (i = 0; i < dd->ncg_home; i++)
+ for (int i = 0; i < dd->ncg_home; i++)
{
state->cg_gl[i] = dd->globalAtomGroupIndices[i];
}
{
wallcycle_start(wcycle, ewcMOVEX);
- int nzone, nat_tot;
- gmx_domdec_comm_t* comm;
- gmx_domdec_comm_dim_t* cd;
- rvec shift = { 0, 0, 0 };
- gmx_bool bPBC, bScrew;
+ rvec shift = { 0, 0, 0 };
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
- nzone = 1;
- nat_tot = comm->atomRanges.numHomeAtoms();
+ int nzone = 1;
+ int nat_tot = comm->atomRanges.numHomeAtoms();
for (int d = 0; d < dd->ndim; d++)
{
- bPBC = (dd->ci[dd->dim[d]] == 0);
- bScrew = (bPBC && dd->unitCellInfo.haveScrewPBC && dd->dim[d] == XX);
+ const bool bPBC = (dd->ci[dd->dim[d]] == 0);
+ const bool bScrew = (bPBC && dd->unitCellInfo.haveScrewPBC && dd->dim[d] == XX);
if (bPBC)
{
copy_rvec(box[dd->dim[d]], shift);
}
- cd = &comm->cd[d];
+ gmx_domdec_comm_dim_t* cd = &comm->cd[d];
for (const gmx_domdec_ind_t& ind : cd->ind)
{
DDBufferAccess<gmx::RVec> sendBufferAccess(comm->rvecBuffer, ind.nsend[nzone + 1]);
void dd_atom_spread_real(gmx_domdec_t* dd, real v[])
{
- int nzone, nat_tot;
- gmx_domdec_comm_t* comm;
- gmx_domdec_comm_dim_t* cd;
-
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
- nzone = 1;
- nat_tot = comm->atomRanges.numHomeAtoms();
+ int nzone = 1;
+ int nat_tot = comm->atomRanges.numHomeAtoms();
for (int d = 0; d < dd->ndim; d++)
{
- cd = &comm->cd[d];
+ gmx_domdec_comm_dim_t* cd = &comm->cd[d];
for (const gmx_domdec_ind_t& ind : cd->ind)
{
/* Note: We provision for RVec instead of real, so a factor of 3
void dd_atom_sum_real(gmx_domdec_t* dd, real v[])
{
- int nzone, nat_tot;
- gmx_domdec_comm_t* comm;
- gmx_domdec_comm_dim_t* cd;
-
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
- nzone = comm->zones.n / 2;
- nat_tot = comm->atomRanges.end(DDAtomRanges::Type::Zones);
+ int nzone = comm->zones.n / 2;
+ int nat_tot = comm->atomRanges.end(DDAtomRanges::Type::Zones);
for (int d = dd->ndim - 1; d >= 0; d--)
{
- cd = &comm->cd[d];
+ gmx_domdec_comm_dim_t* cd = &comm->cd[d];
for (int p = cd->numPulses() - 1; p >= 0; p--)
{
const gmx_domdec_ind_t& ind = cd->ind[p];
real dd_cutoff_twobody(const gmx_domdec_t* dd)
{
- real r_mb;
-
- r_mb = dd_cutoff_multibody(dd);
+ const real r_mb = dd_cutoff_multibody(dd);
return std::max(dd->comm->systemInfo.cutoff, r_mb);
}
static int gmx_ddcoord2pmeindex(const t_commrec* cr, int x, int y, int z)
{
- gmx_domdec_t* dd;
- ivec coords;
- int slab;
+ ivec coords;
- dd = cr->dd;
- coords[XX] = x;
- coords[YY] = y;
- coords[ZZ] = z;
- slab = ddindex2pmeindex(dd->comm->ddRankSetup, dd_index(dd->numCells, coords));
+ gmx_domdec_t* dd = cr->dd;
+ coords[XX] = x;
+ coords[YY] = y;
+ coords[ZZ] = z;
+ const int slab = ddindex2pmeindex(dd->comm->ddRankSetup, dd_index(dd->numCells, coords));
return slab;
}
static gmx_bool receive_vir_ener(const gmx_domdec_t* dd, gmx::ArrayRef<const int> pmeRanks, const t_commrec* cr)
{
- gmx_bool bReceive = TRUE;
+ bool bReceive = true;
const DDRankSetup& ddRankSetup = dd->comm->ddRankSetup;
if (ddRankSetup.usePmeOnlyRanks)
coords[cartSetup.cartpmedim]++;
if (coords[cartSetup.cartpmedim] < dd->numCells[cartSetup.cartpmedim])
{
- int rank;
+ int rank = 0;
MPI_Cart_rank(cr->mpi_comm_mysim, coords, &rank);
if (dd_simnode2pmenode(ddRankSetup, cartSetup, pmeRanks, cr, rank) == pmenode)
{
static void set_slb_pme_dim_f(gmx_domdec_t* dd, int dim, real** dim_f)
{
- gmx_domdec_comm_t* comm;
- int i;
-
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
snew(*dim_f, dd->numCells[dim] + 1);
(*dim_f)[0] = 0;
- for (i = 1; i < dd->numCells[dim]; i++)
+ for (int i = 1; i < dd->numCells[dim]; i++)
{
if (comm->slb_frac[dim])
{
*/
if (dimind == 0 || xyz[XX] == dd->ci[XX])
{
- const int pmeindex = ddindex2pmeindex(ddRankSetup, i);
- int slab;
- if (dimind == 0)
- {
- slab = pmeindex / nso;
- }
- else
- {
- slab = pmeindex % ddpme->nslab;
- }
+ const int pmeindex = ddindex2pmeindex(ddRankSetup, i);
+ const int slab = (dimind == 0) ? pmeindex / nso : pmeindex % ddpme->nslab;
ddpme->pp_min[slab] = std::min(ddpme->pp_min[slab], xyz[dimind]);
ddpme->pp_max[slab] = std::max(ddpme->pp_max[slab], xyz[dimind]);
}
#if GMX_MPI
static void make_load_communicator(gmx_domdec_t* dd, int dim_ind, ivec loc)
{
- MPI_Comm c_row;
- int dim, i, rank;
+ MPI_Comm c_row = nullptr;
ivec loc_c;
- gmx_bool bPartOfGroup = FALSE;
+ bool bPartOfGroup = false;
- dim = dd->dim[dim_ind];
+ const int dim = dd->dim[dim_ind];
copy_ivec(loc, loc_c);
- for (i = 0; i < dd->numCells[dim]; i++)
+ for (int i = 0; i < dd->numCells[dim]; i++)
{
- loc_c[dim] = i;
- rank = dd_index(dd->numCells, loc_c);
+ loc_c[dim] = i;
+ const int rank = dd_index(dd->numCells, loc_c);
if (rank == dd->rank)
{
/* This process is part of the group */
void dd_setup_dlb_resource_sharing(const t_commrec* cr, int gpu_id)
{
#if GMX_MPI
- int physicalnode_id_hash;
- gmx_domdec_t* dd;
- MPI_Comm mpi_comm_pp_physicalnode;
+ MPI_Comm mpi_comm_pp_physicalnode = nullptr;
if (!thisRankHasDuty(cr, DUTY_PP) || gpu_id < 0)
{
return;
}
- physicalnode_id_hash = gmx_physicalnode_id_hash();
+ const int physicalnode_id_hash = gmx_physicalnode_id_hash();
- dd = cr->dd;
+ gmx_domdec_t* dd = cr->dd;
if (debug)
{
static void make_load_communicators(gmx_domdec_t gmx_unused* dd)
{
#if GMX_MPI
- int dim0, dim1, i, j;
ivec loc;
if (debug)
make_load_communicator(dd, 0, loc);
if (dd->ndim > 1)
{
- dim0 = dd->dim[0];
- for (i = 0; i < dd->numCells[dim0]; i++)
+ const int dim0 = dd->dim[0];
+ for (int 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->numCells[dim0]; i++)
+ const int dim0 = dd->dim[0];
+ for (int i = 0; i < dd->numCells[dim0]; i++)
{
- loc[dim0] = i;
- dim1 = dd->dim[1];
- for (j = 0; j < dd->numCells[dim1]; j++)
+ loc[dim0] = i;
+ const int dim1 = dd->dim[1];
+ for (int j = 0; j < dd->numCells[dim1]; j++)
{
loc[dim1] = j;
make_load_communicator(dd, 2, loc);
/*! \brief Sets up the relation between neighboring domains and zones */
static void setup_neighbor_relations(gmx_domdec_t* dd)
{
- int d, dim, m;
- ivec tmp, s;
- gmx_domdec_zones_t* zones;
+ ivec tmp, s;
GMX_ASSERT((dd->ndim >= 0) && (dd->ndim <= DIM), "Must have valid number of dimensions for DD");
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
- dim = dd->dim[d];
+ const int dim = dd->dim[d];
copy_ivec(dd->ci, tmp);
tmp[dim] = (tmp[dim] + 1) % dd->numCells[dim];
dd->neighbor[d][0] = ddcoord2ddnodeid(dd, tmp);
int nizone = (1 << std::max(dd->ndim - 1, 0));
assert(nizone >= 1 && nizone <= DD_MAXIZONE);
- zones = &dd->comm->zones;
+ gmx_domdec_zones_t* zones = &dd->comm->zones;
for (int i = 0; i < nzone; i++)
{
- m = 0;
+ int m = 0;
clear_ivec(zones->shift[i]);
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
zones->shift[i][dd->dim[d]] = dd_zo[i][m++];
}
zones->n = nzone;
for (int i = 0; i < nzone; i++)
{
- for (d = 0; d < DIM; d++)
+ for (int d = 0; d < DIM; d++)
{
s[d] = dd->ci[d] - zones->shift[i][d];
if (s[d] < 0)
*/
iZone.jZoneRange = gmx::Range<int>(std::min(ddNonbondedZonePairRanges[iZoneIndex][1], nzone),
std::min(ddNonbondedZonePairRanges[iZoneIndex][2], nzone));
- for (dim = 0; dim < DIM; dim++)
+ for (int dim = 0; dim < DIM; dim++)
{
if (dd->numCells[dim] == 1)
{
{
periods[i] = TRUE;
}
- MPI_Comm comm_cart;
+ MPI_Comm comm_cart = nullptr;
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;
/* Get the rank of the DD master,
* above we made sure that the master node is a PP node.
*/
- int rank;
- if (MASTER(cr))
- {
- rank = dd->rank;
- }
- else
- {
- rank = 0;
- }
+ int rank = MASTER(cr) ? dd->rank : 0;
MPI_Allreduce(&rank, &dd->masterrank, 1, MPI_INT, MPI_SUM, dd->mpi_comm_all);
}
else if (cartSetup.bCartesianPP)
if (cartSetup.bCartesianPP_PME)
{
#if GMX_MPI
- int rank;
+ int rank = 0;
ivec periods;
GMX_LOG(mdlog.info)
{
periods[i] = TRUE;
}
- MPI_Comm comm_cart;
+ MPI_Comm comm_cart = nullptr;
MPI_Cart_create(cr->mpi_comm_mysim, DIM, cartSetup.ntot, periods, static_cast<int>(reorder), &comm_cart);
MPI_Comm_rank(comm_cart, &rank);
if (MASTER(cr) && rank != 0)
static real* get_slb_frac(const gmx::MDLogger& mdlog, const char* dir, int nc, const char* size_string)
{
- real * slb_frac, tot;
- int i, n;
- double dbl;
-
- slb_frac = nullptr;
+ real* slb_frac = nullptr;
if (nc > 1 && size_string != nullptr)
{
GMX_LOG(mdlog.info).appendTextFormatted("Using static load balancing for the %s direction", dir);
snew(slb_frac, nc);
- tot = 0;
- for (i = 0; i < nc; i++)
+ real tot = 0;
+ for (int i = 0; i < nc; i++)
{
- dbl = 0;
+ double dbl = 0;
+ int n = 0;
sscanf(size_string, "%20lf%n", &dbl, &n);
if (dbl == 0)
{
}
/* Normalize */
std::string relativeCellSizes = "Relative cell sizes:";
- for (i = 0; i < nc; i++)
+ for (int i = 0; i < nc; i++)
{
slb_frac[i] /= tot;
relativeCellSizes += gmx::formatString(" %5.3f", slb_frac[i]);
{
int n = 0;
gmx_mtop_ilistloop_t iloop = gmx_mtop_ilistloop_init(mtop);
- int nmol;
+ int nmol = 0;
while (const InteractionLists* ilists = gmx_mtop_ilistloop_next(iloop, &nmol))
{
for (auto& ilist : extractILists(*ilists, IF_BOND))
static int dd_getenv(const gmx::MDLogger& mdlog, const char* env_var, int def)
{
- char* val;
- int nst;
-
- nst = def;
- val = getenv(env_var);
+ int nst = def;
+ char* val = getenv(env_var);
if (val)
{
if (sscanf(val, "%20d", &nst) <= 0)
/* Returns whether mtop contains constraints and/or vsites */
static bool systemHasConstraintsOrVsites(const gmx_mtop_t& mtop)
{
- auto ilistLoop = gmx_mtop_ilistloop_init(mtop);
- int nmol;
+ auto* ilistLoop = gmx_mtop_ilistloop_init(mtop);
+ int nmol = 0;
while (const InteractionLists* ilists = gmx_mtop_ilistloop_next(ilistLoop, &nmol))
{
if (!extractILists(*ilists, IF_CONSTRAINT | IF_VSITE).empty())
}
else
{
- real r_2b, r_mb;
+ real r_2b = 0;
+ real r_mb = 0;
if (ddRole == DDRole::Master)
{
{
if (options.numCells[XX] <= 0 && (ddGridSetup.numDomains[XX] == 0))
{
- char buf[STRLEN];
- gmx_bool bC = (systemInfo.haveSplitConstraints
- && systemInfo.constraintCommunicationRange > systemInfo.minCutoffForMultiBody);
- sprintf(buf,
- "Change the number of ranks or mdrun option %s%s%s",
- !bC ? "-rdd" : "-rcon",
- ddSettings.initialDlbState != DlbState::offUser ? " or -dds" : "",
- bC ? " or your LINCS settings" : "");
+ const bool bC = (systemInfo.haveSplitConstraints
+ && systemInfo.constraintCommunicationRange > systemInfo.minCutoffForMultiBody);
+ std::string message =
+ gmx::formatString("Change the number of ranks or mdrun option %s%s%s",
+ !bC ? "-rdd" : "-rcon",
+ ddSettings.initialDlbState != DlbState::offUser ? " or -dds" : "",
+ bC ? " or your LINCS settings" : "");
gmx_fatal_collective(FARGS,
communicator,
"Look in the log file for details on the domain decomposition",
numNodes - ddGridSetup.numPmeOnlyRanks,
cellsizeLimit,
- buf);
+ message.c_str());
}
const real acs = average_cellsize_min(ddbox, ddGridSetup.numDomains);
gmx_bool bBCheck,
gmx::ArrayRef<cginfo_mb_t> cginfo_mb)
{
- gmx_domdec_comm_t* comm;
-
dd_make_reverse_top(fplog, dd, &mtop, vsite, ir, bBCheck);
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
if (comm->systemInfo.filterBondedCommunication)
{
real dlb_scale,
const gmx_ddbox_t* ddbox)
{
- gmx_domdec_comm_t* comm;
- int d;
- ivec np;
- real limit, shrink;
-
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
if (bDynLoadBal)
{
log->writeString("The maximum number of communication pulses is:");
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
log->writeStringFormatted(" %c %d", dim2char(dd->dim[d]), comm->cd[d].np_dlb);
}
comm->cellsize_limit);
log->writeLineFormatted("The requested allowed shrink of DD cells (option -dds) is: %.2f", dlb_scale);
log->writeString("The allowed shrink of domain decomposition cells is:");
- for (d = 0; d < DIM; d++)
+ for (int d = 0; d < DIM; d++)
{
if (dd->numCells[d] > 1)
{
- 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->numCells[d]);
- }
+ const real shrink =
+ (d >= ddbox->npbcdim && dd->numCells[d] == 2)
+ ? 0
+ : comm->cellsize_min_dlb[d]
+ / (ddbox->box_size[d] * ddbox->skew_fac[d] / dd->numCells[d]);
log->writeStringFormatted(" %c %.2f", dim2char(d), shrink);
}
}
}
else
{
+ ivec np;
set_dd_cell_sizes_slb(dd, ddbox, setcellsizeslbPULSE_ONLY, np);
log->writeString("The initial number of communication pulses is:");
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
log->writeStringFormatted(" %c %d", dim2char(dd->dim[d]), np[dd->dim[d]]);
}
log->ensureLineBreak();
log->writeString("The initial domain decomposition cell size is:");
- for (d = 0; d < DIM; d++)
+ for (int d = 0; d < DIM; d++)
{
if (dd->numCells[d] > 1)
{
log->writeLineFormatted(
"%40s %-7s %6.3f nm", "non-bonded interactions", "", comm->systemInfo.cutoff);
+ real limit = 0;
if (bDynLoadBal)
{
limit = dd->comm->cellsize_limit;
"deformation)");
}
limit = dd->comm->cellsize_min[XX];
- for (d = 1; d < DIM; d++)
+ for (int d = 1; d < DIM; d++)
{
limit = std::min(limit, dd->comm->cellsize_min[d]);
}
const t_inputrec* ir,
const gmx_ddbox_t* ddbox)
{
- gmx_domdec_comm_t* comm;
- int d, dim, npulse, npulse_d_max, npulse_d;
- gmx_bool bNoCutOff;
+ int npulse = 0, npulse_d_max = 0, npulse_d = 0;
- comm = dd->comm;
+ gmx_domdec_comm_t* comm = dd->comm;
- bNoCutOff = (ir->rvdw == 0 || ir->rcoulomb == 0);
+ bool bNoCutOff = (ir->rvdw == 0 || ir->rcoulomb == 0);
/* Determine the maximum number of comm. pulses in one dimension */
{
/* See if we can do with less pulses, based on dlb_scale */
npulse_d_max = 0;
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
- dim = dd->dim[d];
+ int dim = dd->dim[d];
npulse_d = static_cast<int>(
1
+ dd->numCells[dim] * comm->systemInfo.cutoff
}
/* This env var can override npulse */
- d = dd_getenv(mdlog, "GMX_DD_NPULSE", 0);
+ int d = dd_getenv(mdlog, "GMX_DD_NPULSE", 0);
if (d > 0)
{
npulse = d;
comm->maxpulse = 1;
comm->bVacDLBNoLimit = (ir->pbcType == PbcType::No);
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
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);
}
comm->cellsize_limit = std::max(comm->cellsize_limit, comm->cutoff_mbody);
/* Set the minimum cell size for each DD dimension */
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
if (comm->bVacDLBNoLimit || comm->cd[d].np_dlb * comm->cellsize_limit >= comm->systemInfo.cutoff)
{
logSettings(mdlog, dd, mtop, ir, dlb_scale, ddbox);
- real vol_frac;
- if (ir->pbcType == PbcType::No)
- {
- vol_frac = 1 - 1 / static_cast<double>(dd->nnodes);
- }
- else
- {
- vol_frac = (1 + comm_box_frac(dd->numCells, comm->systemInfo.cutoff, *ddbox))
- / static_cast<double>(dd->nnodes);
- }
+ const real vol_frac = (ir->pbcType == PbcType::No)
+ ? (1 - 1 / static_cast<double>(dd->nnodes))
+ : ((1 + comm_box_frac(dd->numCells, comm->systemInfo.cutoff, *ddbox))
+ / static_cast<double>(dd->nnodes));
if (debug)
{
fprintf(debug, "Volume fraction for all DD zones: %f\n", vol_frac);
static gmx_bool test_dd_cutoff(const t_commrec* cr, const matrix box, gmx::ArrayRef<const gmx::RVec> x, real cutoffRequested)
{
gmx_ddbox_t ddbox;
- int d, dim, np;
- real inv_cell_size;
- int LocallyLimited;
+ int LocallyLimited = 0;
const auto* dd = cr->dd;
LocallyLimited = 0;
- for (d = 0; d < dd->ndim; d++)
+ for (int d = 0; d < dd->ndim; d++)
{
- dim = dd->dim[d];
+ const int dim = dd->dim[d];
- inv_cell_size = DD_CELL_MARGIN * dd->numCells[dim] / ddbox.box_size[dim];
+ real inv_cell_size = DD_CELL_MARGIN * dd->numCells[dim] / ddbox.box_size[dim];
if (dd->unitCellInfo.ddBoxIsDynamic)
{
inv_cell_size *= DD_PRES_SCALE_MARGIN;
}
- np = 1 + static_cast<int>(cutoffRequested * inv_cell_size * ddbox.skew_fac[dim]);
+ const int np = 1 + static_cast<int>(cutoffRequested * inv_cell_size * ddbox.skew_fac[dim]);
if (!isDlbDisabled(dd->comm) && (dim < ddbox.npbcdim) && (dd->comm->cd[d].np_dlb > 0))
{
gmx_bool change_dd_cutoff(t_commrec* cr, const matrix box, gmx::ArrayRef<const gmx::RVec> x, real cutoffRequested)
{
- gmx_bool bCutoffAllowed;
-
- bCutoffAllowed = test_dd_cutoff(cr, box, x, cutoffRequested);
+ bool bCutoffAllowed = test_dd_cutoff(cr, box, x, cutoffRequested);
if (bCutoffAllowed)
{
*
* Copyright (c) 2006,2007,2008,2009,2010 by the GROMACS development team.
* Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team.
- * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
{
/* Walk further */
const int* iap = constr_iatomptr(ia1, ia2, coni);
- int b;
- if (a == iap[1])
- {
- b = iap[2];
- }
- else
- {
- b = iap[1];
- }
+ const int b = (a == iap[1]) ? iap[2] : iap[1];
if (!ga2la.findHome(offset + b))
{
walk_out(coni, con_offset, b, offset, nrec - 1, ia1, ia2, at2con, ga2la, FALSE, dc, dcc, il_local, ireq);
{
if (GET_CGINFO_SETTLE(cginfo[a]))
{
- int a_gl = dd->globalAtomIndices[a];
- int a_mol;
+ int a_gl = dd->globalAtomIndices[a];
+ int a_mol = 0;
mtopGetMolblockIndex(mtop, a_gl, &mb, nullptr, &a_mol);
const gmx_molblock_t* molb = &mtop->molblock[mb];
{
if (GET_CGINFO_CONSTR(cginfo[a]))
{
- int a_gl = dd->globalAtomIndices[a];
- int molnr, a_mol;
+ int a_gl = dd->globalAtomIndices[a];
+ int molnr = 0, a_mol = 0;
mtopGetMolblockIndex(mtop, a_gl, &mb, &molnr, &a_mol);
const gmx_molblock_t& molb = mtop->molblock[mb];
const auto& at2con = at2con_mt[molb.type];
for (const int con : at2con[a_mol])
{
- const int* iap = constr_iatomptr(ia1, ia2, con);
- int b_mol;
+ const int* iap = constr_iatomptr(ia1, ia2, con);
+ int b_mol = 0;
if (a_mol == iap[1])
{
b_mol = iap[2];
int nrec,
gmx::ArrayRef<InteractionList> il_local)
{
- gmx_domdec_constraints_t* dc;
- InteractionList * ilc_local, *ils_local;
- gmx::HashedMap<int>* ga2la_specat;
- int at_end, i, j;
-
// This code should not be called unless this condition is true,
// because that's the only time init_domdec_constraints is
// called...
// true. dd->constraint_comm is unilaterally dereferenced before
// the call to atoms_to_settles.
- dc = dd->constraints;
+ gmx_domdec_constraints_t* dc = dd->constraints;
- ilc_local = &il_local[F_CONSTR];
- ils_local = &il_local[F_SETTLE];
+ InteractionList* ilc_local = &il_local[F_CONSTR];
+ InteractionList* ils_local = &il_local[F_SETTLE];
dc->ncon = 0;
gmx::ArrayRef<const ListOfLists<int>> at2con_mt;
}
else
{
- int t0_set;
-
/* Do the constraints, if present, on the first thread.
* Do the settles on all other threads.
*/
- t0_set = ((!at2con_mt.empty() && dc->nthread > 1) ? 1 : 0);
+ const int t0_set = ((!at2con_mt.empty() && dc->nthread > 1) ? 1 : 0);
#pragma omp parallel for num_threads(dc->nthread) schedule(static)
for (int thread = 0; thread < dc->nthread; thread++)
if (thread >= t0_set)
{
- int cg0, cg1;
- InteractionList* ilst;
-
/* Distribute the settle check+assignments over
* dc->nthread or dc->nthread-1 threads.
*/
- cg0 = (dd->ncg_home * (thread - t0_set)) / (dc->nthread - t0_set);
- cg1 = (dd->ncg_home * (thread - t0_set + 1)) / (dc->nthread - t0_set);
+ int cg0 = (dd->ncg_home * (thread - t0_set)) / (dc->nthread - t0_set);
+ int cg1 = (dd->ncg_home * (thread - t0_set + 1)) / (dc->nthread - t0_set);
- if (thread == t0_set)
- {
- ilst = ils_local;
- }
- else
- {
- ilst = &dc->ils[thread];
- }
+ InteractionList* ilst = (thread == t0_set) ? ils_local : &dc->ils[thread];
ilst->clear();
std::vector<int>& ireqt = dc->requestedGlobalAtomIndices[thread];
}
}
+ int at_end = 0;
if (dd->constraint_comm)
{
- int nral1;
-
at_end = setup_specat_communication(dd,
ireq,
dd->constraint_comm,
" or lincs-order");
/* Fill in the missing indices */
- ga2la_specat = dd->constraints->ga2la.get();
+ gmx::HashedMap<int>* ga2la_specat = dd->constraints->ga2la.get();
- nral1 = 1 + NRAL(F_CONSTR);
- for (i = 0; i < ilc_local->size(); i += nral1)
+ int nral1 = 1 + NRAL(F_CONSTR);
+ for (int i = 0; i < ilc_local->size(); i += nral1)
{
int* iap = ilc_local->iatoms.data() + i;
- for (j = 1; j < nral1; j++)
+ for (int j = 1; j < nral1; j++)
{
if (iap[j] < 0)
{
}
nral1 = 1 + NRAL(F_SETTLE);
- for (i = 0; i < ils_local->size(); i += nral1)
+ for (int i = 0; i < ils_local->size(); i += nral1)
{
int* iap = ils_local->iatoms.data() + i;
- for (j = 1; j < nral1; j++)
+ for (int j = 1; j < nral1; j++)
{
if (iap[j] < 0)
{
void init_domdec_constraints(gmx_domdec_t* dd, const gmx_mtop_t* mtop)
{
- gmx_domdec_constraints_t* dc;
- const gmx_molblock_t* molb;
-
if (debug)
{
fprintf(debug, "Begin init_domdec_constraints\n");
}
- dd->constraints = new gmx_domdec_constraints_t;
- dc = dd->constraints;
+ dd->constraints = new gmx_domdec_constraints_t;
+ gmx_domdec_constraints_t* dc = dd->constraints;
dc->molb_con_offset.resize(mtop->molblock.size());
dc->molb_ncon_mol.resize(mtop->molblock.size());
int ncon = 0;
for (size_t mb = 0; mb < mtop->molblock.size(); mb++)
{
- molb = &mtop->molblock[mb];
- dc->molb_con_offset[mb] = ncon;
- dc->molb_ncon_mol[mb] = mtop->moltype[molb->type].ilist[F_CONSTR].size() / 3
+ const gmx_molblock_t* molb = &mtop->molblock[mb];
+ dc->molb_con_offset[mb] = ncon;
+ dc->molb_ncon_mol[mb] = mtop->moltype[molb->type].ilist[F_CONSTR].size() / 3
+ mtop->moltype[molb->type].ilist[F_CONSTRNC].size() / 3;
ncon += molb->nmol * dc->molb_ncon_mol[mb];
}
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2008-2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2008-2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
int gmx_unused n_r_bw)
{
#if GMX_MPI
- int rank_fw, rank_bw, nreq;
MPI_Request req[4];
MPI_Status stat[4];
- rank_fw = dd->neighbor[ddimind][0];
- rank_bw = dd->neighbor[ddimind][1];
+ int rank_fw = dd->neighbor[ddimind][0];
+ int rank_bw = dd->neighbor[ddimind][1];
if (!dd->comm->ddSettings.useSendRecv2)
{
* are slower.
* SendRecv2 can be turned on with the env.var. GMX_DD_SENDRECV2
*/
- nreq = 0;
+ int nreq = 0;
if (n_r_fw)
{
MPI_Irecv(buf_r_fw[0], n_r_fw * sizeof(rvec), MPI_BYTE, rank_bw, 0, dd->mpi_comm_all, &req[nreq++]);
void* rbuf)
{
#if GMX_MPI
- int dum;
+ int dum = 0;
if (dd->nnodes > 1)
{
void gmx_unused* rbuf)
{
#if GMX_MPI
- int dum;
+ int dum = 0;
if (scount == 0)
{
*
* Copyright (c) 2008,2009,2010,2011,2012 by the GROMACS development team.
* Copyright (c) 2013,2014,2015,2017,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "box.h"
#include "domdec_internal.h"
+#include "math.h"
#include "utility.h"
// TODO remove this when moving domdec into gmx namespace
/*! \brief Compute largest common divisor of \p n1 and \b n2 */
static int lcd(int n1, int n2)
{
- int d, i;
-
- d = 1;
- for (i = 2; (i <= n1 && i <= n2); i++)
+ int d = 1;
+ for (int i = 2; (i <= n1 && i <= n2); i++)
{
if (n1 % i == 0 && n2 % i == 0)
{
const matrix box,
int nrank_tot)
{
- float ratio;
- int npme;
-
- ratio = pme_load_estimate(mtop, ir, box);
+ float ratio = pme_load_estimate(mtop, ir, box);
GMX_LOG(mdlog.info).appendTextFormatted("Guess for relative PME load: %.2f", ratio);
* We start with a minimum PME node fraction of 1/16
* and avoid ratios which lead to large prime factors in nnodes-npme.
*/
- npme = (nrank_tot + 15) / 16;
+ int npme = (nrank_tot + 15) / 16;
while (npme <= nrank_tot / 3)
{
if (nrank_tot % npme == 0)
real comm_box_frac(const gmx::IVec& dd_nc, real cutoff, const gmx_ddbox_t& ddbox)
{
- int i, j, k;
rvec nw;
- real comm_vol;
- for (i = 0; i < DIM; i++)
+ for (int i = 0; i < DIM; i++)
{
real bt = ddbox.box_size[i] * ddbox.skew_fac[i];
nw[i] = dd_nc[i] * cutoff / bt;
}
- comm_vol = 0;
- for (i = 0; i < DIM; i++)
+ real comm_vol = 0;
+ for (int i = 0; i < DIM; i++)
{
if (dd_nc[i] > 1)
{
comm_vol += nw[i];
- for (j = i + 1; j < DIM; j++)
+ for (int j = i + 1; j < DIM; j++)
{
if (dd_nc[j] > 1)
{
comm_vol += nw[i] * nw[j] * M_PI / 4;
- for (k = j + 1; k < DIM; k++)
+ for (int k = j + 1; k < DIM; k++)
{
if (dd_nc[k] > 1)
{
static float comm_pme_cost_vol(int npme, int a, int b, int c)
{
/* We use a float here, since an integer might overflow */
- float comm_vol;
-
- comm_vol = npme - 1;
+ float comm_vol = npme - 1;
comm_vol *= npme;
comm_vol *= div_up(a, npme);
comm_vol *= div_up(b, npme);
const gmx::IVec& nc)
{
gmx::IVec npme = { 1, 1, 1 };
- int i, j, nk, overlap;
rvec bt;
- float comm_vol, comm_vol_xf, comm_pme, cost_pbcdx;
/* This is the cost of a pbc_dx call relative to the cost
* of communicating the coordinate and force of an atom.
* This will be machine dependent.
*/
float pbcdx_rect_fac = 0.1;
float pbcdx_tric_fac = 0.2;
- float temp;
/* Check the DD algorithm restrictions */
if ((ir.pbcType == PbcType::XY && ir.nwall < 2 && nc[ZZ] > 1)
assert(ddbox.npbcdim <= DIM);
/* Check if the triclinic requirements are met */
- for (i = 0; i < DIM; i++)
+ for (int i = 0; i < DIM; i++)
{
- for (j = i + 1; j < ddbox.npbcdim; j++)
+ for (int j = i + 1; j < ddbox.npbcdim; j++)
{
if (box[j][i] != 0 || ir.deform[j][i] != 0 || (ir.epc != epcNO && ir.compress[j][i] != 0))
{
}
}
- for (i = 0; i < DIM; i++)
+ for (int i = 0; i < DIM; i++)
{
bt[i] = ddbox.box_size[i] * ddbox.skew_fac[i];
* for the smallest index, so the decomposition does not
* depend sensitively on the rounding of the box elements.
*/
- for (i = 0; i < DIM; i++)
+ for (int i = 0; i < DIM; i++)
{
- for (j = i + 1; j < DIM; j++)
+ for (int j = i + 1; j < DIM; j++)
{
/* Check if the box size is nearly identical,
* in that case we prefer nx > ny and ny > nz.
* and the "back"-communication cost is identical to the forward cost.
*/
- comm_vol = comm_box_frac(nc, cutoff, ddbox);
+ float comm_vol = comm_box_frac(nc, cutoff, ddbox);
- comm_pme = 0;
- for (i = 0; i < 2; i++)
+ float comm_pme = 0;
+ for (int i = 0; i < 2; i++)
{
/* Determine the largest volume for PME x/f redistribution */
if (nc[i] % npme[i] != 0)
{
- if (nc[i] > npme[i])
- {
- comm_vol_xf = (npme[i] == 2 ? 1.0 / 3.0 : 0.5);
- }
- else
- {
- comm_vol_xf = 1.0 - lcd(nc[i], npme[i]) / static_cast<double>(npme[i]);
- }
+ float comm_vol_xf = (nc[i] > npme[i])
+ ? (npme[i] == 2 ? 1.0 / 3.0 : 0.5)
+ : (1.0 - lcd(nc[i], npme[i]) / static_cast<double>(npme[i]));
comm_pme += 3 * natoms * comm_vol_xf;
}
/* Grid overlap communication */
if (npme[i] > 1)
{
- nk = (i == 0 ? ir.nkx : ir.nky);
- overlap = (nk % npme[i] == 0 ? ir.pme_order - 1 : ir.pme_order);
- temp = npme[i];
+ const int nk = (i == 0 ? ir.nkx : ir.nky);
+ const int overlap = (nk % npme[i] == 0 ? ir.pme_order - 1 : ir.pme_order);
+ float temp = npme[i];
temp *= overlap;
temp *= ir.nkx;
temp *= ir.nky;
comm_pme += comm_pme_cost_vol(npme[XX], ir.nkx, ir.nky, ir.nkz);
/* Add cost of pbc_dx for bondeds */
- cost_pbcdx = 0;
+ float cost_pbcdx = 0;
if ((nc[XX] == 1 || nc[YY] == 1) || (nc[ZZ] == 1 && ir.pbcType != PbcType::XY))
{
if ((ddbox.tric_dir[XX] && nc[XX] == 1) || (ddbox.tric_dir[YY] && nc[YY] == 1))
gmx::IVec* irTryPtr,
gmx::IVec* opt)
{
- int x, y, i;
- float ce;
gmx::IVec& ir_try = *irTryPtr;
if (ndiv == 0)
{
- ce = comm_cost_est(limit, cutoff, box, ddbox, natoms, ir, pbcdxr, npme, ir_try);
+ const float ce = comm_cost_est(limit, cutoff, box, ddbox, natoms, ir, pbcdxr, npme, ir_try);
if (ce >= 0
&& ((*opt)[XX] == 0
|| ce < comm_cost_est(limit, cutoff, box, ddbox, natoms, ir, pbcdxr, npme, *opt)))
return;
}
- for (x = mdiv[0]; x >= 0; x--)
+ for (int x = mdiv[0]; x >= 0; x--)
{
- for (i = 0; i < x; i++)
+ for (int i = 0; i < x; i++)
{
ir_try[XX] *= div[0];
}
- for (y = mdiv[0] - x; y >= 0; y--)
+ for (int y = mdiv[0] - x; y >= 0; y--)
{
- for (i = 0; i < y; i++)
+ for (int i = 0; i < y; i++)
{
ir_try[YY] *= div[0];
}
- for (i = 0; i < mdiv[0] - x - y; i++)
+ for (int i = 0; i < mdiv[0] - x - y; i++)
{
ir_try[ZZ] *= div[0];
}
assign_factors(
limit, cutoff, box, ddbox, natoms, ir, pbcdxr, npme, ndiv - 1, div + 1, mdiv + 1, irTryPtr, opt);
- for (i = 0; i < mdiv[0] - x - y; i++)
+ for (int i = 0; i < mdiv[0] - x - y; i++)
{
ir_try[ZZ] /= div[0];
}
- for (i = 0; i < y; i++)
+ for (int i = 0; i < y; i++)
{
ir_try[YY] /= div[0];
}
}
- for (i = 0; i < x; i++)
+ for (int i = 0; i < x; i++)
{
ir_try[XX] /= div[0];
}
const t_inputrec& ir,
const DDSystemInfo& systemInfo)
{
- double pbcdxr;
+ double pbcdxr = 0;
const int numPPRanks = numRanksRequested - numPmeOnlyRanks;
const matrix box,
const int numRanksRequested)
{
- int numPmeOnlyRanks;
- const char* extraMessage = "";
+ int numPmeOnlyRanks = 0;
+ const char* extraMessage = "";
if (options.numCells[XX] > 0)
{
*
* Copyright (c) 2006,2007,2008,2009,2010 by the GROMACS development team.
* Copyright (c) 2012,2013,2014,2015,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
void dd_move_f_specat(const gmx_domdec_t* dd, gmx_domdec_specat_comm_t* spac, rvec* f, rvec* fshift)
{
- gmx_specatsend_t* spas;
- rvec* vbuf;
- int n, n0, n1, dim, dir;
- ivec vis;
- int is;
- gmx_bool bPBC, bScrew;
+ ivec vis;
- n = spac->at_end;
+ int n = spac->at_end;
for (int d = dd->ndim - 1; d >= 0; d--)
{
- dim = dd->dim[d];
+ const int dim = dd->dim[d];
if (dd->numCells[dim] > 2)
{
/* Pulse the grid forward and backward */
- spas = spac->spas[d];
- n0 = spas[0].nrecv;
- n1 = spas[1].nrecv;
+ gmx_specatsend_t* spas = spac->spas[d];
+ int n0 = spas[0].nrecv;
+ int n1 = spas[1].nrecv;
n -= n1 + n0;
- vbuf = as_rvec_array(spac->vbuf.data());
+ rvec* vbuf = as_rvec_array(spac->vbuf.data());
/* Send and receive the coordinates */
dd_sendrecv2_rvec(dd,
d,
n1,
vbuf + spas[0].a.size(),
spas[1].a.size());
- for (dir = 0; dir < 2; dir++)
+ for (int dir = 0; dir < 2; dir++)
{
- bPBC = ((dir == 0 && dd->ci[dim] == 0)
- || (dir == 1 && dd->ci[dim] == dd->numCells[dim] - 1));
- bScrew = (bPBC && dd->unitCellInfo.haveScrewPBC && dim == XX);
+ bool bPBC = ((dir == 0 && dd->ci[dim] == 0)
+ || (dir == 1 && dd->ci[dim] == dd->numCells[dim] - 1));
+ bool bScrew = (bPBC && dd->unitCellInfo.haveScrewPBC && dim == XX);
- spas = &spac->spas[d][dir];
+ gmx_specatsend_t* spas = &spac->spas[d][dir];
/* Sum the buffer into the required forces */
if (!bPBC || (!bScrew && fshift == nullptr))
{
{
clear_ivec(vis);
vis[dim] = (dir == 0 ? 1 : -1);
- is = IVEC2IS(vis);
+ int is = IVEC2IS(vis);
if (!bScrew)
{
/* Sum and add to shift forces */
else
{
/* Two cells, so we only need to communicate one way */
- spas = &spac->spas[d][0];
+ gmx_specatsend_t* spas = &spac->spas[d][0];
n -= spas->nrecv;
/* Send and receive the coordinates */
ddSendrecv(dd, d, dddirForward, f + n, spas->nrecv, as_rvec_array(spac->vbuf.data()), spas->a.size());
rvec* x1,
gmx_bool bX1IsCoord)
{
- gmx_specatsend_t* spas;
- int nvec, v, n, nn, ns0, ns1, nr0, nr1, nr, d, dim, dir, i;
- gmx_bool bPBC, bScrew = FALSE;
- rvec shift = { 0, 0, 0 };
+ rvec shift = { 0, 0, 0 };
- nvec = 1;
+ int nvec = 1;
if (x1 != nullptr)
{
nvec++;
}
- n = spac->at_start;
- for (d = 0; d < dd->ndim; d++)
+ int n = spac->at_start;
+ for (int d = 0; d < dd->ndim; d++)
{
- dim = dd->dim[d];
+ int dim = dd->dim[d];
if (dd->numCells[dim] > 2)
{
/* Pulse the grid forward and backward */
rvec* vbuf = as_rvec_array(spac->vbuf.data());
- for (dir = 0; dir < 2; dir++)
+ for (int dir = 0; dir < 2; dir++)
{
+ bool bPBC = false;
+ bool bScrew = false;
if (dir == 0 && dd->ci[dim] == 0)
{
- bPBC = TRUE;
+ bPBC = true;
bScrew = (dd->unitCellInfo.haveScrewPBC && dim == XX);
copy_rvec(box[dim], shift);
}
else if (dir == 1 && dd->ci[dim] == dd->numCells[dim] - 1)
{
- bPBC = TRUE;
+ bPBC = true;
bScrew = (dd->unitCellInfo.haveScrewPBC && dim == XX);
- for (i = 0; i < DIM; i++)
+ for (int i = 0; i < DIM; i++)
{
shift[i] = -box[dim][i];
}
}
- else
- {
- bPBC = FALSE;
- bScrew = FALSE;
- }
- spas = &spac->spas[d][dir];
- for (v = 0; v < nvec; v++)
+ gmx_specatsend_t* spas = &spac->spas[d][dir];
+ for (int v = 0; v < nvec; v++)
{
rvec* x = (v == 0 ? x0 : x1);
/* Copy the required coordinates to the send buffer */
}
}
/* Send and receive the coordinates */
- spas = spac->spas[d];
- ns0 = spas[0].a.size();
- nr0 = spas[0].nrecv;
- ns1 = spas[1].a.size();
- nr1 = spas[1].nrecv;
+ gmx_specatsend_t* spas = spac->spas[d];
+ int ns0 = spas[0].a.size();
+ int nr0 = spas[0].nrecv;
+ int ns1 = spas[1].a.size();
+ int nr1 = spas[1].nrecv;
if (nvec == 1)
{
rvec* vbuf = as_rvec_array(spac->vbuf.data());
dd_sendrecv2_rvec(
dd, d, vbuf + 2 * ns0, 2 * ns1, rbuf, 2 * nr1, vbuf, 2 * ns0, rbuf + 2 * nr1, 2 * nr0);
/* Split the buffer into the two vectors */
- nn = n;
- for (dir = 1; dir >= 0; dir--)
+ int nn = n;
+ for (int dir = 1; dir >= 0; dir--)
{
- nr = spas[dir].nrecv;
- for (v = 0; v < 2; v++)
+ int nr = spas[dir].nrecv;
+ for (int v = 0; v < 2; v++)
{
rvec* x = (v == 0 ? x0 : x1);
- for (i = 0; i < nr; i++)
+ for (int i = 0; i < nr; i++)
{
copy_rvec(*rbuf, x[nn + i]);
rbuf++;
}
else
{
- spas = &spac->spas[d][0];
+ gmx_specatsend_t* spas = &spac->spas[d][0];
/* Copy the required coordinates to the send buffer */
rvec* vbuf = as_rvec_array(spac->vbuf.data());
- for (v = 0; v < nvec; v++)
+ for (int v = 0; v < nvec; v++)
{
rvec* x = (v == 0 ? x0 : x1);
if (dd->unitCellInfo.haveScrewPBC && dim == XX
rvec* rbuf = as_rvec_array(spac->vbuf2.data());
ddSendrecv(dd, d, dddirBackward, vbuf, 2 * spas->a.size(), rbuf, 2 * spas->nrecv);
/* Split the buffer into the two vectors */
- nr = spas[0].nrecv;
- for (v = 0; v < 2; v++)
+ int nr = spas[0].nrecv;
+ for (int v = 0; v < 2; v++)
{
rvec* x = (v == 0 ? x0 : x1);
- for (i = 0; i < nr; i++)
+ for (int i = 0; i < nr; i++)
{
copy_rvec(*rbuf, x[n + i]);
rbuf++;
const char* specat_type,
const char* add_err)
{
- int nsend[2], nlast, nsend_zero[2] = { 0, 0 }, *nsend_ptr;
- int dim, ndir, nr, ns, nrecv_local, n0, start, buf[2];
- int nat_tot_specat, nat_tot_prev;
- gmx_bool bPBC;
- gmx_specatsend_t* spas;
+ int nsend[2], nsend_zero[2] = { 0, 0 };
+ int buf[2];
if (debug)
{
const int numRequested = ireq->size();
nsend[0] = ireq->size();
nsend[1] = nsend[0];
- nlast = nsend[1];
+ int nlast = nsend[1];
for (int d = dd->ndim - 1; d >= 0; d--)
{
/* Pulse the grid forward and backward */
- dim = dd->dim[d];
- bPBC = (dim < dd->unitCellInfo.npbcdim);
- if (dd->numCells[dim] == 2)
- {
- /* Only 2 cells, so we only need to communicate once */
- ndir = 1;
- }
- else
- {
- ndir = 2;
- }
+ int dim = dd->dim[d];
+ bool bPBC = (dim < dd->unitCellInfo.npbcdim);
+ const int ndir = (dd->numCells[dim] == 2)
+ ?
+ /* Only 2 cells, so we only need to communicate once */
+ 1
+ : 2;
+ int* nsend_ptr = nullptr;
for (int dir = 0; dir < ndir; dir++)
{
if (!bPBC && dd->numCells[dim] > 2
}
/* Communicate the number of indices */
ddSendrecv(dd, d, dir == 0 ? dddirForward : dddirBackward, nsend_ptr, 2, spac->nreq[d][dir], 2);
- nr = spac->nreq[d][dir][1];
+ int nr = spac->nreq[d][dir][1];
ireq->resize(nlast + nr);
/* Communicate the indices */
ddSendrecv(dd,
}
/* Search for the requested atoms and communicate the indices we have */
- nat_tot_specat = at_start;
- nrecv_local = 0;
+ int nat_tot_specat = at_start;
+ int nrecv_local = 0;
for (int d = 0; d < dd->ndim; d++)
{
/* Pulse the grid forward and backward */
- if (dd->dim[d] >= dd->unitCellInfo.npbcdim || dd->numCells[dd->dim[d]] > 2)
- {
- ndir = 2;
- }
- else
- {
- ndir = 1;
- }
- nat_tot_prev = nat_tot_specat;
+ const int ndir = (dd->dim[d] >= dd->unitCellInfo.npbcdim || dd->numCells[dd->dim[d]] > 2) ? 2 : 1;
+ int nat_tot_prev = nat_tot_specat;
for (int dir = ndir - 1; dir >= 0; dir--)
{
/* To avoid cost of clearing by resize(), we only increase size */
/* Note: resize initializes new elements to false, which is actually needed here */
spac->sendAtom.resize(nat_tot_specat);
}
- spas = &spac->spas[d][dir];
- n0 = spac->nreq[d][dir][0];
- nr = spac->nreq[d][dir][1];
+ gmx_specatsend_t* spas = &spac->spas[d][dir];
+ const int n0 = spac->nreq[d][dir][0];
+ const int nr = spac->nreq[d][dir][1];
if (debug)
{
fprintf(debug, "dim=%d, dir=%d, searching for %d atoms\n", d, dir, nr);
}
- start = nlast - nr;
+ const int start = nlast - nr;
spas->a.clear();
spac->ibuf.clear();
nsend[0] = 0;
for (int i = 0; i < nr; i++)
{
const int indr = (*ireq)[start + i];
- int ind;
+ int ind = 0;
/* Check if this is a home atom and if so ind will be set */
if (const int* homeIndex = dd->ga2la->findHome(indr))
{
}
/* Increase the x/f communication buffer sizes, when necessary */
- ns = spac->spas[d][0].a.size();
- nr = spac->spas[d][0].nrecv;
+ int ns = spac->spas[d][0].a.size();
+ int nr = spac->spas[d][0].nrecv;
if (ndir == 2)
{
ns += spac->spas[d][1].a.size();
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2006 - 2014, The GROMACS development team.
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "domdec_internal.h"
#include "domdec_vsite.h"
#include "dump.h"
+#include "math.h"
using gmx::ArrayRef;
using gmx::ListOfLists;
/*! \brief Returns the number of atom entries for il in gmx_reverse_top_t */
static int nral_rt(int ftype)
{
- int nral;
-
- nral = NRAL(ftype);
+ int nral = NRAL(ftype);
if (interaction_function[ftype].flags & IF_VSITE)
{
/* With vsites the reverse topology contains an extra entry
numMissingToPrint);
}
log.writeStringFormatted("%20s atoms", interaction_function[ftype].longname);
- int a;
- for (a = 0; a < nral; a++)
+ int a = 0;
+ for (; a < nral; a++)
{
log.writeStringFormatted("%5d", ril.il[j_mol + 2 + a] + 1);
}
a++;
}
log.writeString(" global");
- for (a = 0; a < nral; a++)
+ for (int a = 0; a < nral; a++)
{
log.writeStringFormatted("%6d",
atomRange.begin() + mol * numAtomsPerMolecule
gmx::ArrayRef<const gmx::RVec> x,
const matrix box)
{
- int ndiff_tot, cl[F_NRE], n, ndiff, rest_global, rest_local;
- int ftype, nral;
- gmx_domdec_t* dd;
-
- dd = cr->dd;
+ int cl[F_NRE];
+ gmx_domdec_t* dd = cr->dd;
GMX_LOG(mdlog.warning)
.appendText(
"Not all bonded interactions have been properly assigned to the domain "
"decomposition cells");
- ndiff_tot = local_count - dd->nbonded_global;
+ const int ndiff_tot = local_count - dd->nbonded_global;
- for (ftype = 0; ftype < F_NRE; ftype++)
+ for (int ftype = 0; ftype < F_NRE; ftype++)
{
- nral = NRAL(ftype);
- cl[ftype] = top_local->idef.il[ftype].size() / (1 + nral);
+ const int nral = NRAL(ftype);
+ cl[ftype] = top_local->idef.il[ftype].size() / (1 + nral);
}
gmx_sumi(F_NRE, cl, cr);
if (DDMASTER(dd))
{
GMX_LOG(mdlog.warning).appendText("A list of missing interactions:");
- rest_global = dd->nbonded_global;
- rest_local = local_count;
- for (ftype = 0; ftype < F_NRE; ftype++)
+ int rest_global = dd->nbonded_global;
+ int rest_local = local_count;
+ for (int ftype = 0; ftype < F_NRE; ftype++)
{
/* In the reverse and local top all constraints are merged
* into F_CONSTR. So in the if statement we skip F_CONSTRNC
|| (dd->reverse_top->bConstr && ftype == F_CONSTR)
|| (dd->reverse_top->bSettle && ftype == F_SETTLE))
{
- n = gmx_mtop_ftype_count(top_global, ftype);
+ int n = gmx_mtop_ftype_count(top_global, ftype);
if (ftype == F_CONSTR)
{
n += gmx_mtop_ftype_count(top_global, F_CONSTRNC);
}
- ndiff = cl[ftype] - n;
+ int ndiff = cl[ftype] - n;
if (ndiff != 0)
{
GMX_LOG(mdlog.warning)
}
}
- ndiff = rest_local - rest_global;
+ int ndiff = rest_local - rest_global;
if (ndiff != 0)
{
GMX_LOG(mdlog.warning).appendTextFormatted("%20s of %6d missing %6d", "exclusions", rest_global, -ndiff);
const MolblockIndices* mbi = rt->mbi.data();
int start = 0;
int end = rt->mbi.size(); /* exclusive */
- int mid;
+ int mid = 0;
/* binary search for molblock_ind */
while (TRUE)
gmx_bool bLinkToAllAtoms,
gmx_bool bAssign)
{
- int ftype, j, nlink, link;
- int a;
- int nint;
+ int nint = 0;
- nint = 0;
- for (ftype = 0; ftype < F_NRE; ftype++)
+ for (int ftype = 0; ftype < F_NRE; ftype++)
{
if ((interaction_function[ftype].flags & (IF_BOND | IF_VSITE))
|| (bConstr && (ftype == F_CONSTR || ftype == F_CONSTRNC)) || (bSettle && ftype == F_SETTLE))
const auto& il = il_mt[ftype];
for (int i = 0; i < il.size(); i += 1 + nral)
{
- const int* ia = il.iatoms.data() + i;
- if (bLinkToAllAtoms)
+ const int* ia = il.iatoms.data() + i;
+ const int nlink = bLinkToAllAtoms ? bVSite ? 0 : nral : 1;
+ for (int link = 0; link < nlink; link++)
{
- if (bVSite)
- {
- /* We don't need the virtual sites for the cg-links */
- nlink = 0;
- }
- else
- {
- nlink = nral;
- }
- }
- else
- {
- /* Couple to the first atom in the interaction */
- nlink = 1;
- }
- for (link = 0; link < nlink; link++)
- {
- a = ia[1 + link];
+ const int a = ia[1 + link];
if (bAssign)
{
GMX_ASSERT(!r_il.empty(), "with bAssign not allowed to be empty");
GMX_ASSERT(!r_index.empty(), "with bAssign not allowed to be empty");
r_il[r_index[a] + count[a]] = (ftype == F_CONSTRNC ? F_CONSTR : ftype);
r_il[r_index[a] + count[a] + 1] = ia[0];
- for (j = 1; j < 1 + nral; j++)
+ for (int j = 1; j < 1 + nral; j++)
{
/* Store the molecular atom number */
r_il[r_index[a] + count[a] + 1 + j] = ia[j];
* vsites again.
*/
r_il[r_index[a] + count[a] + 2 + nral] = 0;
- for (j = 2; j < 1 + nral; j++)
+ for (int j = 2; j < 1 + nral; j++)
{
if (atom[ia[j]].ptype == eptVSite)
{
gmx_bool bLinkToAllAtoms,
reverse_ilist_t* ril_mt)
{
- int nat_mt, *count, i, nint_mt;
-
/* Count the interactions */
- nat_mt = atoms->nr;
- snew(count, nat_mt);
+ const int nat_mt = atoms->nr;
+ std::vector<int> count(nat_mt);
low_make_reverse_ilist(
- ilist, atoms->atom, count, bConstr, bSettle, bBCheck, {}, {}, bLinkToAllAtoms, FALSE);
+ ilist, atoms->atom, count.data(), bConstr, bSettle, bBCheck, {}, {}, bLinkToAllAtoms, FALSE);
ril_mt->index.push_back(0);
- for (i = 0; i < nat_mt; i++)
+ for (int i = 0; i < nat_mt; i++)
{
ril_mt->index.push_back(ril_mt->index[i] + count[i]);
count[i] = 0;
ril_mt->il.resize(ril_mt->index[nat_mt]);
/* Store the interactions */
- nint_mt = low_make_reverse_ilist(
- ilist, atoms->atom, count, bConstr, bSettle, bBCheck, ril_mt->index, ril_mt->il, bLinkToAllAtoms, TRUE);
-
- sfree(count);
+ int nint_mt = low_make_reverse_ilist(
+ ilist, atoms->atom, count.data(), bConstr, bSettle, bBCheck, ril_mt->index, ril_mt->il, bLinkToAllAtoms, TRUE);
ril_mt->numAtomsInMolecule = atoms->nr;
const t_iatom* iatoms,
InteractionDefinitions* idef)
{
- int k;
t_iatom tiatoms[1 + MAXATOMLIST];
- int j, ftype_r, nral_r;
/* Add this interaction to the local topology */
add_ifunc_for_vsites(tiatoms, ga2la, nral, bHomeA, a, a_gl, a_mol, iatoms, &idef->il[ftype]);
if (iatoms[1 + nral])
{
/* Check for recursion */
- for (k = 2; k < 1 + nral; k++)
+ for (int k = 2; k < 1 + nral; k++)
{
if ((iatoms[1 + nral] & (2 << k)) && (tiatoms[k] < 0))
{
/* Find the vsite construction */
/* Check all interactions assigned to this atom */
- j = index[iatoms[k]];
+ int j = index[iatoms[k]];
while (j < index[iatoms[k] + 1])
{
- ftype_r = rtil[j++];
- nral_r = NRAL(ftype_r);
+ int ftype_r = rtil[j++];
+ int nral_r = NRAL(ftype_r);
if (interaction_function[ftype_r].flags & IF_VSITE)
{
/* Add this vsite (recursion) */
/*! \brief Append t_idef structures 1 to nsrc in src to *dest */
static void combine_idef(InteractionDefinitions* dest, gmx::ArrayRef<const thread_work_t> src)
{
- int ftype;
-
- for (ftype = 0; ftype < F_NRE; ftype++)
+ for (int ftype = 0; ftype < F_NRE; ftype++)
{
int n = 0;
for (gmx::index s = 1; s < src.ssize(); s++)
}
else
{
- gmx_bool bUse;
+ bool bUse = false;
/* Copy the type */
tiatoms[0] = iatoms[0];
/* Assign single-body interactions to the home zone */
if (iz == 0)
{
- bUse = TRUE;
+ bUse = true;
tiatoms[1] = i;
if (ftype == F_POSRES)
{
{
add_fbposres(mol, i_mol, numAtomsInMolecule, molb, tiatoms, ip_in, idef);
}
- }
- else
- {
- bUse = FALSE;
+ else
+ {
+ bUse = false;
+ }
}
}
else if (nral == 2)
/* This is a two-body interaction, we can assign
* analogous to the non-bonded assignments.
*/
- int k_gl;
-
- if (!bInterMolInteractions)
- {
- /* Get the global index using the offset in the molecule */
- k_gl = i_gl + iatoms[2] - i_mol;
- }
- else
- {
- k_gl = iatoms[2];
- }
+ const int k_gl = (!bInterMolInteractions)
+ ?
+ /* Get the global index using the offset in the molecule */
+ (i_gl + iatoms[2] - i_mol)
+ : iatoms[2];
if (const auto* entry = dd->ga2la->find(k_gl))
{
int kz = entry->cell;
/* If necessary check the cgcm distance */
if (bRCheck2B && dd_dist2(pbc_null, cg_cm, tiatoms[1], tiatoms[2]) >= rc2)
{
- bUse = FALSE;
+ bUse = false;
}
}
}
* with 2 DD cells an extra check may be necessary.
*/
ivec k_zero, k_plus;
- int k;
-
- bUse = TRUE;
+ bUse = true;
clear_ivec(k_zero);
clear_ivec(k_plus);
- for (k = 1; k <= nral && bUse; k++)
+ for (int k = 1; k <= nral && bUse; k++)
{
- int k_gl;
- if (!bInterMolInteractions)
- {
- /* Get the global index using the offset in the molecule */
- k_gl = i_gl + iatoms[k] - i_mol;
- }
- else
- {
- k_gl = iatoms[k];
- }
+ const int k_gl = (!bInterMolInteractions)
+ ?
+ /* Get the global index using the offset in the molecule */
+ (i_gl + iatoms[k] - i_mol)
+ : iatoms[k];
const auto* entry = dd->ga2la->find(k_gl);
if (entry == nullptr || entry->cell >= zones->n)
{
}
else
{
- int d;
-
tiatoms[k] = entry->la;
- for (d = 0; d < DIM; d++)
+ for (int d = 0; d < DIM; d++)
{
if (zones->shift[entry->cell][d] == 0)
{
bUse = (bUse && (k_zero[XX] != 0) && (k_zero[YY] != 0) && (k_zero[ZZ] != 0));
if (bRCheckMB)
{
- int d;
-
- for (d = 0; (d < DIM && bUse); d++)
+ for (int d = 0; (d < DIM && bUse); d++)
{
/* Check if the cg_cm distance falls within
* the cut-off to avoid possible multiple
int izone,
const gmx::Range<int>& atomRange)
{
- int mb, mt, mol, i_mol;
- gmx_bool bBCheck;
- gmx_reverse_top_t* rt;
- int nbonded_local;
+ int mb = 0, mt = 0, mol = 0, i_mol = 0;
- rt = dd->reverse_top;
+ gmx_reverse_top_t* rt = dd->reverse_top;
- bBCheck = rt->bBCheck;
+ bool bBCheck = rt->bBCheck;
- nbonded_local = 0;
+ int nbonded_local = 0;
for (int i : atomRange)
{
if (GET_CGINFO_EXCL_INTER(cginfo[at]))
{
- int a_gl, mb, mt, mol, a_mol;
+ int mb = 0, mt = 0, mol = 0, a_mol = 0;
/* Copy the exclusions from the global top */
- a_gl = dd->globalAtomIndices[at];
+ int a_gl = dd->globalAtomIndices[at];
global_atomnr_to_moltype_ind(dd->reverse_top, a_gl, &mb, &mt, &mol, &a_mol);
const auto excls = moltype[mt].excls[a_mol];
for (const int aj_mol : excls)
ListOfLists<int>* lexcls,
int* excl_count)
{
- int nzone_bondeds;
- int cg0, cg1;
- real rc2;
- int nbonded_local;
- gmx_reverse_top_t* rt;
+ int nzone_bondeds = 0;
if (dd->reverse_top->bInterAtomicInteractions)
{
/* We only use exclusions from i-zones to i- and j-zones */
const int numIZonesForExclusions = (dd->haveExclusions ? zones->iZones.size() : 0);
- rt = dd->reverse_top;
+ gmx_reverse_top_t* rt = dd->reverse_top;
- rc2 = rc * rc;
+ real rc2 = rc * rc;
/* Clear the counts */
idef->clear();
- nbonded_local = 0;
+ int nbonded_local = 0;
lexcls->clear();
*excl_count = 0;
for (int izone = 0; izone < nzone_bondeds; izone++)
{
- cg0 = zones->cg_range[izone];
- cg1 = zones->cg_range[izone + 1];
+ int cg0 = zones->cg_range[izone];
+ int cg1 = zones->cg_range[izone + 1];
const int numThreads = rt->th_work.size();
#pragma omp parallel for num_threads(numThreads) schedule(static)
{
try
{
- int cg0t, cg1t;
- InteractionDefinitions* idef_t;
+ InteractionDefinitions* idef_t = nullptr;
- cg0t = cg0 + ((cg1 - cg0) * thread) / numThreads;
- cg1t = cg0 + ((cg1 - cg0) * (thread + 1)) / numThreads;
+ int cg0t = cg0 + ((cg1 - cg0) * thread) / numThreads;
+ int cg1t = cg0 + ((cg1 - cg0) * (thread + 1)) / numThreads;
if (thread == 0)
{
if (izone < numIZonesForExclusions)
{
- ListOfLists<int>* excl_t;
+ ListOfLists<int>* excl_t = nullptr;
if (thread == 0)
{
// Thread 0 stores exclusions directly in the final storage
const gmx_mtop_t& mtop,
gmx_localtop_t* ltop)
{
- gmx_bool bRCheckMB, bRCheck2B;
- real rc = -1;
- ivec rcheck;
- int d, nexcl;
- t_pbc pbc, *pbc_null = nullptr;
+ real rc = -1;
+ ivec rcheck;
+ int nexcl = 0;
+ t_pbc pbc, *pbc_null = nullptr;
if (debug)
{
fprintf(debug, "Making local topology\n");
}
- bRCheckMB = FALSE;
- bRCheck2B = FALSE;
+ bool bRCheckMB = false;
+ bool bRCheck2B = false;
if (dd->reverse_top->bInterAtomicInteractions)
{
}
/* Should we check cg_cm distances when assigning bonded interactions? */
- for (d = 0; d < DIM; d++)
+ for (int d = 0; d < DIM; d++)
{
rcheck[d] = FALSE;
/* Only need to check for dimensions where the part of the box
/*! \brief Check if a link is stored in \p link between charge groups \p cg_gl and \p cg_gl_j and if not so, store a link */
static void check_link(t_blocka* link, int cg_gl, int cg_gl_j)
{
- int k;
- gmx_bool bFound;
-
- bFound = FALSE;
- for (k = link->index[cg_gl]; k < link->index[cg_gl + 1]; k++)
+ bool bFound = false;
+ for (int k = link->index[cg_gl]; k < link->index[cg_gl + 1]; k++)
{
GMX_RELEASE_ASSERT(link->a, "Inconsistent NULL pointer while making charge-group links");
if (link->a[k] == cg_gl_j)
t_blocka* makeBondedLinks(const gmx_mtop_t& mtop, gmx::ArrayRef<cginfo_mb_t> cginfo_mb)
{
- t_blocka* link;
- cginfo_mb_t* cgi_mb;
+ t_blocka* link = nullptr;
/* For each atom make a list of other atoms in the system
* that a linked to it via bonded interactions
reverse_ilist_t ril;
make_reverse_ilist(molt.ilist, &molt.atoms, FALSE, FALSE, FALSE, TRUE, &ril);
- cgi_mb = &cginfo_mb[mb];
+ cginfo_mb_t* cgi_mb = &cginfo_mb[mb];
- int mol;
+ int mol = 0;
for (mol = 0; mol < (mtop.bIntermolecularInteractions ? molb.nmol : 1); mol++)
{
for (int a = 0; a < molt.atoms.nr; a++)
for (int aj = ai + 1; aj < nral; aj++)
{
rvec dx;
- real rij2;
+ real rij2 = NAN;
int atom_j = il.iatoms[i + 1 + aj];
ArrayRef<const RVec> x,
ArrayRef<RVec> xs)
{
- int n, i;
-
if (pbcType != PbcType::No)
{
mk_mshift(nullptr, graph, pbcType, box, as_rvec_array(x.data()));
* unchanged, just to be 100% sure that we do not affect
* binary reproducibility of simulations.
*/
- n = molt->atoms.nr;
- for (i = 0; i < n; i++)
+ for (int i = 0; i < molt->atoms.nr; i++)
{
copy_rvec(x[i], xs[i]);
}
real* r_2b,
real* r_mb)
{
- gmx_bool bExclRequired;
- int at_offset;
bonded_distance_t bd_2b = { 0, -1, -1, -1 };
bonded_distance_t bd_mb = { 0, -1, -1, -1 };
- bExclRequired = inputrecExclForces(ir);
+ bool bExclRequired = inputrecExclForces(ir);
- *r_2b = 0;
- *r_mb = 0;
- at_offset = 0;
+ *r_2b = 0;
+ *r_mb = 0;
+ int at_offset = 0;
for (const gmx_molblock_t& molb : mtop->molblock)
{
const gmx_moltype_t& molt = mtop->moltype[molb.type];
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2015,2017,2018,2019,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
//! Implement malloc of \c bytes of memory, aligned to \c alignment.
void* mallocImpl(std::size_t bytes, std::size_t alignment)
{
- void* p;
+ void* p = nullptr;
#if HAVE__MM_MALLOC
p = _mm_malloc(bytes, alignment);
//! \todo Move this function into sysinfo.cpp where other OS-specific code/includes live
static std::size_t getPageSize()
{
- long pageSize;
+ long pageSize = 0;
#if GMX_NATIVE_WINDOWS
SYSTEM_INFO si;
GetNativeSystemInfo(&si);
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
* Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#if !GMX_MPI
return false;
#else
- int n;
+ int n = 0;
MPI_Initialized(&n);
return n != 0;
return 1;
}
# endif
- int i;
+ int i = 0;
(void)MPI_Comm_size(MPI_COMM_WORLD, &i);
return i;
#endif
return 0;
}
# endif
- int i;
+ int i = 0;
(void)MPI_Comm_rank(MPI_COMM_WORLD, &i);
return i;
#endif
static int mpi_hostname_hash()
{
- int hash_int;
+ int hash_int = 0;
#if GMX_LIB_MPI
int resultlen;
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2010,2012,2014,2015,2018 by the GROMACS development team.
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*/
#include "gromacs/utility/baseversion_gen.h"
-const char _gmx_ver_string[] = "@GMX_VERSION_STRING_FULL@";
-const char _gmx_full_git_hash[] = "@GMX_VERSION_FULL_HASH@";
-const char _gmx_central_base_hash[] = "@GMX_VERSION_CENTRAL_BASE_HASH@";
+const char gmx_ver_string[] = "@GMX_VERSION_STRING_FULL@";
+const char gmx_full_git_hash[] = "@GMX_VERSION_FULL_HASH@";
+const char gmx_central_base_hash[] = "@GMX_VERSION_CENTRAL_BASE_HASH@";
const char gmxSourceDoiString[] = "@GMX_SOURCE_DOI@";
const char gmxReleaseSourceFileChecksum[] = "@GMX_RELEASE_SOURCE_FILE_CHECKSUM@";
const char gmxCurrentSourceFileChecksum[] = "@GMX_CURRENT_SOURCE_FILE_CHECKSUM@";
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2014,2015,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
const char* gmx_version()
{
- return _gmx_ver_string;
+ return gmx_ver_string;
}
const char* gmx_version_git_full_hash()
{
- return _gmx_full_git_hash;
+ return gmx_full_git_hash;
}
const char* gmx_version_git_central_base_hash()
{
- return _gmx_central_base_hash;
+ return gmx_central_base_hash;
}
const char* gmxDOI()
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 2010,2012,2013,2014,2015 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
//! \{
//! Version string, containing the version, date, and abbreviated hash.
-extern const char _gmx_ver_string[];
+extern const char gmx_ver_string[];
//! Full git hash of the latest commit.
-extern const char _gmx_full_git_hash[];
+extern const char gmx_full_git_hash[];
//! Full git hash of the latest commit in a central \Gromacs repository.
-extern const char _gmx_central_base_hash[];
+extern const char gmx_central_base_hash[];
/*! \brief
* DOI string for the \Gromacs source code populated by CMake.
*
va_end(ap);
}
-void _gmx_error(const char* key, const std::string& msg, const char* file, int line)
+void gmx_error_function(const char* key, const std::string& msg, const char* file, int line)
{
call_error_handler(key, file, line, msg);
gmx_exit_on_fatal_error(ExitType_Abort, 1);
}
-void _range_check(int n, int n_min, int n_max, const char* warn_str, const char* var, const char* file, int line)
+void range_check_function(int n, int n_min, int n_max, const char* warn_str, const char* var, const char* file, int line)
{
if ((n < n_min) || (n >= n_max))
{
n_min,
n_max);
- _gmx_error("range", buf, file, line);
+ gmx_error_function("range", buf, file, line);
}
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2014,2015,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2018,2019,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
}
\endcode
*/
-extern FILE* debug;
+extern FILE* debug; //NOLINT(cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors)
/** Whether extra debugging is enabled. */
-extern gmx_bool gmx_debug_at;
+extern gmx_bool gmx_debug_at; //NOLINT(cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors)
/*! \brief
* Initializes debugging variables.
#define FARGS 0, __FILE__, __LINE__
/** Implementation for gmx_error(). */
-[[noreturn]] void _gmx_error(const char* key, const std::string& msg, const char* file, int line);
+[[noreturn]] void gmx_error_function(const char* key, const std::string& msg, const char* file, int line);
/*! \brief
* Alternative fatal error routine with canned messages.
*
* based on a string key, and printf-style formatting is not supported.
* Should not typically be called directly, but through gmx_call() etc.
*/
-#define gmx_error(key, msg) _gmx_error(key, msg, __FILE__, __LINE__)
+#define gmx_error(key, msg) gmx_error_function(key, msg, __FILE__, __LINE__)
/*! \name Fatal error routines for certain types of errors
*
*
* \p warn_str can be NULL.
*/
-void _range_check(int n, int n_min, int n_max, const char* warn_str, const char* var, const char* file, int line);
+void range_check_function(int n, int n_min, int n_max, const char* warn_str, const char* var, const char* file, int line);
/*! \brief
* Checks that a variable is within a range.
* \p n_min is inclusive, but \p n_max is not.
*/
#define range_check_mesg(n, n_min, n_max, str) \
- _range_check(n, n_min, n_max, str, #n, __FILE__, __LINE__)
+ range_check_function(n, n_min, n_max, str, #n, __FILE__, __LINE__)
/*! \brief
* Checks that a variable is within a range.
*
* This works as range_check_mesg(), but with a default error message.
*/
-#define range_check(n, n_min, n_max) _range_check(n, n_min, n_max, NULL, #n, __FILE__, __LINE__)
+#define range_check(n, n_min, n_max) \
+ range_check_function(n, n_min, n_max, NULL, #n, __FILE__, __LINE__)
/*! \brief
* Prints a warning message to stderr.
static void push_ps(FILE* fp)
{
- t_pstack* ps;
+ t_pstack* ps = nullptr;
Lock pstackLock(pstack_mutex);
int gmx_ffclose(FILE* fp)
{
- t_pstack *ps, *tmp;
+ t_pstack *ps = nullptr, *tmp = nullptr;
int ret = 0;
Lock pstackLock(pstack_mutex);
static FILE* uncompress(const std::string& fn, const char* mode)
{
- FILE* fp;
+ FILE* fp = nullptr;
std::string buf = "uncompress -c < " + fn;
fprintf(stderr, "Going to execute '%s'\n", buf.c_str());
if ((fp = popen(buf.c_str(), mode)) == nullptr)
static FILE* gunzip(const std::string& fn, const char* mode)
{
- FILE* fp;
+ FILE* fp = nullptr;
std::string buf = "gunzip -c < ";
buf += fn;
fprintf(stderr, "Going to execute '%s'\n", buf.c_str());
gmx_bool gmx_fexist(const std::string& fname)
{
- FILE* test;
+ FILE* test = nullptr;
if (fname.empty())
{
FILE* gmx_ffopen(const std::string& file, const char* mode)
{
- FILE* ff = nullptr;
- gmx_bool bRead;
- int bs;
+ FILE* ff = nullptr;
+ gmx_bool bRead = 0;
+ int bs = 0;
if (file.empty())
{
}
else
{
- char* ptr;
+ char* ptr = nullptr;
snew(ptr, bs + 8);
if (setvbuf(ff, ptr, _IOFBF, bs) != 0)
{
* \todo Use std::string and std::vector<char>. */
static int makeTemporaryFilename(char* buf)
{
- int len;
+ int len = 0;
if ((len = strlen(buf)) < 7)
{
* since windows doesnt support it we have to separate the cases.
* 20090307: mktemp deprecated, use iso c++ _mktemp instead.
*/
- int fd;
+ int fd = 0;
#if GMX_NATIVE_WINDOWS
_mktemp(buf);
if (buf == NULL)
while (!feof(in.get()))
{
- size_t nread;
+ size_t nread = 0;
nread = fread(buf.data(), sizeof(char), FILECOPY_BUFSIZE, in.get());
if (nread > 0)
{
- size_t ret;
+ size_t ret = 0;
if (!out)
{
/* so this is where we open when copy_if_empty is false:
int rc = 0;
{
- int fn;
+ int fn = 0;
/* get the file number */
#if HAVE_FILENO