Gromacs  2024.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions | Variables
pairlist_tuning.cpp File Reference
#include "gmxpre.h"
#include "pairlist_tuning.h"
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include "gromacs/domdec/domdec.h"
#include "gromacs/hardware/cpuinfo.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/calc_verletbuf.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/interaction_const.h"
#include "gromacs/mdtypes/multipletimestepping.h"
#include "gromacs/mdtypes/state.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/logger.h"
#include "gromacs/utility/strconvert.h"
#include "gromacs/utility/stringutil.h"
#include "nbnxm_geometry.h"
#include "pairlistsets.h"
+ Include dependency graph for pairlist_tuning.cpp:

Description

Implements functions for tuning adjustable parameters for the nbnxn non-bonded search and interaction kernels.

Author
Berk Hess hess@.nosp@m.kth..nosp@m.se

Classes

struct  CalcVerletBufferParameters
 Struct with references for most parameters for calling calcVerletBufferSize() More...
 

Macros

#define NNSTL   (sizeof(nstlist_try) / sizeof(nstlist_try[0]))
 Number of elements in the neighborsearch list trials.
 

Functions

static bool supportsDynamicPairlistGenerationInterval (const t_inputrec &ir)
 Returns if we can (heuristically) change nstlist and rlist. More...
 
static real getPressureTolerance (const real inputrecVerletBufferPressureTolerance)
 Returns the Verlet buffer pressure tolerance set by an env.var. or from input.
 
void increaseNstlist (FILE *fp, t_commrec *cr, t_inputrec *ir, int nstlist_cmdline, const gmx_mtop_t *mtop, const matrix box, const real effectiveAtomDensity, bool useOrEmulateGpuForNonbondeds, const gmx::CpuInfo &cpuinfo)
 Try to increase nstlist when using the Verlet cut-off scheme. More...
 
static real calcPruneVerletBufferSize (const CalcVerletBufferParameters &params, const int nstlist)
 Wrapper for calcVerletBufferSize() for determining the pruning cut-off. More...
 
static void setDynamicPairlistPruningParameters (const t_inputrec &inputrec, const gmx_mtop_t &mtop, const real effectiveAtomDensity, const bool useGpuList, const VerletbufListSetup &listSetup, const bool userSetNstlistPrune, const interaction_const_t &interactionConst, PairlistParams *listParams)
 Set the dynamic pairlist pruning parameters in ic. More...
 
static std::string formatListSetup (const std::string &listName, int nstList, int nstListForSpacing, real rList, real interactionCutoff)
 Returns a string describing the setup of a single pair-list. More...
 
void setupDynamicPairlistPruning (const gmx::MDLogger &mdlog, const t_inputrec &inputrec, const gmx_mtop_t &mtop, const real effectiveAtomDensity, const interaction_const_t &interactionConst, PairlistParams *listParams)
 Set up the dynamic pairlist pruning. More...
 
void printNbnxmPressureError (const gmx::MDLogger &mdlog, const t_inputrec &inputrec, const gmx_mtop_t &mtop, const real effectiveAtomDensity, const PairlistParams &listParams)
 Prints an estimate of the error in the pressure due to missing interactions. More...
 

Variables

static const int nbnxnReferenceNstlist = 10
 Cost of non-bonded kernels. More...
 
const int nstlist_try [] = { 20, 25, 40, 50, 80, 100 }
 The values to try when switching.
 
static const float c_nbnxnListSizeFactorCpu = 1.25
 Target pair-list size increase ratio for CPU.
 
static const float c_nbnxnListSizeFactorIntelXeonPhi = 1.4
 Target pair-list size increase ratio for Intel KNL.
 
static const float c_nbnxnListSizeFactorGPU = 1.4
 Target pair-list size increase ratio for GPU.
 
static const float c_nbnxnListSizeFactorMargin = 0.1
 Never increase the size of the pair-list more than the factor above plus this margin.
 
static const int c_nbnxnGpuRollingListPruningInterval = 2
 The interval in steps at which we perform dynamic, rolling pruning on a GPU. More...
 
static const int c_nbnxnCpuDynamicListPruningMinLifetime = 5
 The minimum nstlist for dynamic pair list pruning on CPUs. More...
 
static const int c_nbnxnGpuDynamicListPruningMinLifetime = 4
 The minimum nstlist for dynamic pair list pruning om GPUs. More...
 

Function Documentation

static real calcPruneVerletBufferSize ( const CalcVerletBufferParameters params,
const int  nstlist 
)
static

Wrapper for calcVerletBufferSize() for determining the pruning cut-off.

Parameters
[in]paramsReferences to most parameters for calcVerletBufferSize()
[in]nstlistThe pruning interval, also used for setting the list lifetime
Returns
The cut-off for pruning the pairlist
static std::string formatListSetup ( const std::string &  listName,
int  nstList,
int  nstListForSpacing,
real  rList,
real  interactionCutoff 
)
static

Returns a string describing the setup of a single pair-list.

Parameters
[in]listNameShort name of the list, can be ""
[in]nstListThe list update interval in steps
[in]nstListForSpacingUpdate interval for setting the number characters for printing nstList
[in]rListList cut-off radius
[in]interactionCutoffThe interaction cut-off, use for printing the list buffer size
void increaseNstlist ( FILE *  fplog,
t_commrec *  cr,
t_inputrec *  ir,
int  nstlistOnCmdline,
const gmx_mtop_t *  mtop,
const matrix  box,
real  effectiveAtomDensity,
bool  useOrEmulateGpuForNonbondeds,
const gmx::CpuInfo cpuinfo 
)

Try to increase nstlist when using the Verlet cut-off scheme.

Parameters
[in,out]fplogLog file
[in]crThe communication record
[in]irThe input parameter record
[in]nstlistOnCmdlineThe value of nstlist provided on the command line
[in]mtopThe global topology
[in]boxThe unit cell
[in]effectiveAtomDensityThe effective atom density
[in]useOrEmulateGpuForNonbondedsTells if we are using a GPU for non-bondeds
[in]cpuinfoInformation about the CPU(s)
void printNbnxmPressureError ( const gmx::MDLogger mdlog,
const t_inputrec &  inputrec,
const gmx_mtop_t &  mtop,
real  effectiveAtomDensity,
const PairlistParams listParams 
)

Prints an estimate of the error in the pressure due to missing interactions.

The NBNxM algorithm tolerates a few missing pair interactions. Missing pair interactions will lead to a systematic overestimates of the pressure when dispersion forces dominate at the cut-off distance. This routine prints an overestimate of the error in the average pressure.

Parameters
[in,out]mdlogMD logger
[in]inputrecThe input parameter record
[in]mtopThe global topology
[in]effectiveAtomDensityThe effective atom density of the system
[in]listParamsThe list setup parameters
static void setDynamicPairlistPruningParameters ( const t_inputrec &  inputrec,
const gmx_mtop_t &  mtop,
const real  effectiveAtomDensity,
const bool  useGpuList,
const VerletbufListSetup &  listSetup,
const bool  userSetNstlistPrune,
const interaction_const_t &  interactionConst,
PairlistParams listParams 
)
static

Set the dynamic pairlist pruning parameters in ic.

Parameters
[in]inputrecThe input parameter record
[in]mtopThe global topology
[in]effectiveAtomDensityThe effective atom density of the system
[in]useGpuListTells if we are using a GPU type pairlist
[in]listSetupThe nbnxn pair list setup
[in]userSetNstlistPruneThe user set ic->nstlistPrune (using an env.var.)
[in]interactionConstThe nonbonded interactions constants
[in,out]listParamsThe list setup parameters
void setupDynamicPairlistPruning ( const gmx::MDLogger mdlog,
const t_inputrec &  inputrec,
const gmx_mtop_t &  mtop,
real  effectiveAtomDensity,
const interaction_const_t &  interactionConst,
PairlistParams listParams 
)

Set up the dynamic pairlist pruning.

Parameters
[in,out]mdlogMD logger
[in]inputrecThe input parameter record
[in]mtopThe global topology
[in]effectiveAtomDensityThe effective atom density of the system
[in]interactionConstThe nonbonded interactions constants
[in,out]listParamsThe list setup parameters
static bool supportsDynamicPairlistGenerationInterval ( const t_inputrec &  ir)
static

Returns if we can (heuristically) change nstlist and rlist.

Parameters
[in]irThe input parameter record

Variable Documentation

const int c_nbnxnCpuDynamicListPruningMinLifetime = 5
static

The minimum nstlist for dynamic pair list pruning on CPUs.

In most cases going lower than 5 will lead to a too high pruning cost.

const int c_nbnxnGpuDynamicListPruningMinLifetime = 4
static

The minimum nstlist for dynamic pair list pruning om GPUs.

In most cases going lower than 4 will lead to a too high pruning cost. This value should be a multiple of c_nbnxnGpuRollingListPruningInterval

const int c_nbnxnGpuRollingListPruningInterval = 2
static

The interval in steps at which we perform dynamic, rolling pruning on a GPU.

Ideally we should auto-tune this value. Not considering overheads, 1 would be the ideal value. But 2 seems a reasonable compromise that reduces GPU kernel launch overheads and also avoids inefficiency on large GPUs when pruning small lists. Because with domain decomposition we alternate local/non-local pruning at even/odd steps, which gives a period of 2, this value currenly needs to be 2, which is indirectly asserted when the GPU pruning is dispatched during the force evaluation.

const int nbnxnReferenceNstlist = 10
static

Cost of non-bonded kernels.

We determine the extra cost of the non-bonded kernels compared to a reference nstlist value of 10 (which is the default in grompp).