-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+/*
+ * This file is part of the GROMACS molecular simulation package.
*
+ * Copyright (c) 2008,2009,2010,2011,2012,2013,2014, 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.
*
- * This file is part of Gromacs Copyright (c) 1991-2008
- * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
*
- * And Hey:
- * Gnomes, ROck Monsters And Chili Sauce
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
#include <stdio.h>
#include <assert.h>
-#include "domdec.h"
-#include "network.h"
-#include "perf_est.h"
-#include "physics.h"
-#include "smalloc.h"
-#include "typedefs.h"
-#include "vec.h"
-#include "names.h"
+#include "gromacs/legacyheaders/domdec.h"
+#include "gromacs/legacyheaders/types/commrec.h"
+#include "gromacs/legacyheaders/network.h"
+#include "gromacs/legacyheaders/perf_est.h"
+#include "gromacs/utility/smalloc.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/legacyheaders/names.h"
/* Margin for setting up the DD grid */
#define DD_GRID_MARGIN_PRES_SCALE 1.05
return ((double)npme/(double)nnodes > 0.95*ratio);
}
-static gmx_bool fits_pp_pme_perf(FILE *fplog,
- t_inputrec *ir, matrix box, gmx_mtop_t *mtop,
- int nnodes, int npme, float ratio)
+static gmx_bool fits_pp_pme_perf(int nnodes, int npme, float ratio)
{
int ndiv, *div, *mdiv, ldiv;
int npp_root3, npme_root2;
/* Note that fits_perf might change the PME grid,
* in the current implementation it does not.
*/
- if (fits_pp_pme_perf(fplog, ir, box, mtop, nnodes, npme, ratio))
+ if (fits_pp_pme_perf(nnodes, npme, ratio))
{
break;
}
while (npme <= nnodes/2)
{
/* Note that fits_perf may change the PME grid */
- if (fits_pp_pme_perf(fplog, ir, box, mtop, nnodes, npme, ratio))
+ if (fits_pp_pme_perf(nnodes, npme, ratio))
{
break;
}
}
if (npme > nnodes/2)
{
- gmx_fatal(FARGS, "Could not find an appropriate number of separate PME nodes. i.e. >= %5f*#nodes (%d) and <= #nodes/2 (%d) and reasonable performance wise (grid_x=%d, grid_y=%d).\n"
- "Use the -npme option of mdrun or change the number of processors or the PME grid dimensions, see the manual for details.",
+ gmx_fatal(FARGS, "Could not find an appropriate number of separate PME ranks. i.e. >= %5f*#ranks (%d) and <= #ranks/2 (%d) and reasonable performance wise (grid_x=%d, grid_y=%d).\n"
+ "Use the -npme option of mdrun or change the number of ranks or the PME grid dimensions, see the manual for details.",
ratio, (int)(0.95*ratio*nnodes+0.5), nnodes/2, ir->nkx, ir->nky);
/* Keep the compiler happy */
npme = 0;
if (fplog)
{
fprintf(fplog,
- "Will use %d particle-particle and %d PME only nodes\n"
+ "Will use %d particle-particle and %d PME only ranks\n"
"This is a guess, check the performance at the end of the log file\n",
nnodes-npme, npme);
}
fprintf(stderr, "\n"
- "Will use %d particle-particle and %d PME only nodes\n"
+ "Will use %d particle-particle and %d PME only ranks\n"
"This is a guess, check the performance at the end of the log file\n",
nnodes-npme, npme);
}
return comm_vol;
}
-static float comm_cost_est(gmx_domdec_t *dd, real limit, real cutoff,
+static float comm_cost_est(real limit, real cutoff,
matrix box, gmx_ddbox_t *ddbox,
int natoms, t_inputrec *ir,
float pbcdxr,
{
bt[i] = ddbox->box_size[i]*ddbox->skew_fac[i];
- /* Without PBC there are no cell size limits with 2 cells */
+ /* Without PBC and with 2 cells, there are no lower limits on the cell size */
if (!(i >= ddbox->npbcdim && nc[i] <= 2) && bt[i] < nc[i]*limit)
{
return -1;
}
+ /* With PBC, check if the cut-off fits in nc[i]-1 cells */
+ if (i < ddbox->npbcdim && nc[i] > 1 && (nc[i] - 1)*bt[i] < nc[i]*cutoff)
+ {
+ return -1;
+ }
}
if (npme_tot > 1)
if (ndiv == 0)
{
- ce = comm_cost_est(dd, limit, cutoff, box, ddbox,
+ ce = comm_cost_est(limit, cutoff, box, ddbox,
natoms, ir, pbcdxr, npme, ir_try);
if (ce >= 0 && (opt[XX] == 0 ||
- ce < comm_cost_est(dd, limit, cutoff, box, ddbox,
+ ce < comm_cost_est(limit, cutoff, box, ddbox,
natoms, ir, pbcdxr,
npme, opt)))
{
t_inputrec *ir,
gmx_domdec_t *dd,
real cellsize_limit, real cutoff,
- gmx_bool bInterCGBondeds, gmx_bool bInterCGMultiBody,
+ gmx_bool bInterCGBondeds,
ivec nc)
{
int npp, npme, ndiv, *div, *mdiv, d, nmax;
gmx_mtop_t *mtop, matrix box, gmx_ddbox_t *ddbox,
gmx_bool bDynLoadBal, real dlb_scale,
real cellsize_limit, real cutoff_dd,
- gmx_bool bInterCGBondeds, gmx_bool bInterCGMultiBody)
+ gmx_bool bInterCGBondeds)
{
- gmx_large_int_t nnodes_div, ldiv;
+ gmx_int64_t nnodes_div, ldiv;
real limit;
if (MASTER(cr))
if (cr->nnodes <= 2)
{
gmx_fatal(FARGS,
- "Can not have separate PME nodes with 2 or less nodes");
+ "Cannot have separate PME ranks with 2 or fewer ranks");
}
if (cr->npmenodes >= cr->nnodes)
{
gmx_fatal(FARGS,
- "Can not have %d separate PME nodes with just %d total nodes",
+ "Cannot have %d separate PME ranks with just %d total ranks",
cr->npmenodes, cr->nnodes);
}
cr->npmenodes = 0;
}
- if (cr->nnodes > 12)
+ if (nnodes_div > 12)
{
ldiv = largest_divisor(nnodes_div);
/* Check if the largest divisor is more than nnodes^2/3 */
if (ldiv*ldiv*ldiv > nnodes_div*nnodes_div)
{
- gmx_fatal(FARGS, "The number of nodes you selected (%d) contains a large prime factor %d. In most cases this will lead to bad performance. Choose a number with smaller prime factors or set the decomposition (option -dd) manually.",
+ gmx_fatal(FARGS, "The number of ranks you selected (%d) contains a large prime factor %d. In most cases this will lead to bad performance. Choose a number with smaller prime factors or set the decomposition (option -dd) manually.",
nnodes_div, ldiv);
}
}
cr->npmenodes = 0;
if (fplog)
{
- fprintf(fplog, "Using %d separate PME nodes, as there are too few total\n nodes for efficient splitting\n", cr->npmenodes);
+ fprintf(fplog, "Using %d separate PME ranks, as there are too few total\n ranks for efficient splitting\n", cr->npmenodes);
}
}
else
cr->npmenodes = guess_npme(fplog, mtop, ir, box, cr->nnodes);
if (fplog)
{
- fprintf(fplog, "Using %d separate PME nodes, as guessed by mdrun\n", cr->npmenodes);
+ fprintf(fplog, "Using %d separate PME ranks, as guessed by mdrun\n", cr->npmenodes);
}
}
}
{
if (fplog)
{
- fprintf(fplog, "Using %d separate PME nodes, per user request\n", cr->npmenodes);
+ fprintf(fplog, "Using %d separate PME ranks, per user request\n", cr->npmenodes);
}
}
}
bDynLoadBal, dlb_scale,
mtop, box, ddbox, ir, dd,
cellsize_limit, cutoff_dd,
- bInterCGBondeds, bInterCGMultiBody,
+ bInterCGBondeds,
dd->nc);
}
else