const t_inputrec &ir,
const matrix box,
const interaction_const_t &ic,
- const NbnxnListParameters &listParams,
+ const nonbonded_verlet_t &nbv,
gmx_pme_t *pmedata,
gmx_bool bUseGPU,
gmx_bool *bPrinting)
pme_lb->cutoff_scheme = ir.cutoff_scheme;
- pme_lb->rbufOuter_coulomb = listParams.rlistOuter - ic.rcoulomb;
- pme_lb->rbufOuter_vdw = listParams.rlistOuter - ic.rvdw;
- pme_lb->rbufInner_coulomb = listParams.rlistInner - ic.rcoulomb;
- pme_lb->rbufInner_vdw = listParams.rlistInner - ic.rvdw;
+ pme_lb->rbufOuter_coulomb = nbv.pairlistOuterRadius() - ic.rcoulomb;
+ pme_lb->rbufOuter_vdw = nbv.pairlistOuterRadius() - ic.rvdw;
+ pme_lb->rbufInner_coulomb = nbv.pairlistInnerRadius() - ic.rcoulomb;
+ pme_lb->rbufInner_vdw = nbv.pairlistInnerRadius() - ic.rvdw;
/* Scale box with Ewald wall factor; note that we pmedata->boxScaler
* can't always usedd as it's not available with separate PME ranks.
pme_lb->cur = 0;
pme_lb->setup[0].rcut_coulomb = ic.rcoulomb;
- pme_lb->setup[0].rlistOuter = listParams.rlistOuter;
- pme_lb->setup[0].rlistInner = listParams.rlistInner;
+ pme_lb->setup[0].rlistOuter = nbv.pairlistOuterRadius();
+ pme_lb->setup[0].rlistInner = nbv.pairlistInnerRadius();
pme_lb->setup[0].grid[XX] = ir.nkx;
pme_lb->setup[0].grid[YY] = ir.nky;
pme_lb->setup[0].grid[ZZ] = ir.nkz;
set = &pme_lb->setup[pme_lb->cur];
ic->rcoulomb = set->rcut_coulomb;
- nbv->pairlistSets_->changeRadii(set->rlistOuter, set->rlistInner);
+ nbv->changePairlistRadii(set->rlistOuter, set->rlistInner);
ic->ewaldcoeff_q = set->ewaldcoeff_q;
/* TODO: centralize the code that sets the potentials shifts */
if (ic->coulomb_modifier == eintmodPOTSHIFT)
/* We always re-initialize the tables whether they are used or not */
init_interaction_const_tables(nullptr, ic, rtab);
- Nbnxm::gpu_pme_loadbal_update_param(nbv, ic, &nbv->pairlistSets().params());
+ Nbnxm::gpu_pme_loadbal_update_param(nbv, ic);
if (!pme_lb->bSepPMERanks)
{
* This also ensures that we won't disable the currently
* optimal setting during a second round of PME balancing.
*/
- set_dd_dlb_max_cutoff(cr, fr->nbv->pairlistSets().params().rlistOuter);
+ set_dd_dlb_max_cutoff(cr, fr->nbv->pairlistOuterRadius());
}
}
step);
/* Update deprecated rlist in forcerec to stay in sync with fr->nbv */
- fr->rlist = fr->nbv->pairlistSets().params().rlistOuter;
+ fr->rlist = fr->nbv->pairlistOuterRadius();
if (ir.eDispCorr != edispcNO)
{
#include "gromacs/mdtypes/interaction_const.h"
#include "gromacs/timing/wallcycle.h"
-struct NbnxnListParameters;
+struct nonbonded_verlet_t;
struct t_commrec;
struct t_inputrec;
class t_state;
const t_inputrec &ir,
const matrix box,
const interaction_const_t &ic,
- const NbnxnListParameters &listParams,
+ const nonbonded_verlet_t &nbv,
gmx_pme_t *pmedata,
gmx_bool bUseGPU,
gmx_bool *bPrinting);
/* When dynamic pair-list pruning is requested, we need to prune
* at nstlistPrune steps.
*/
- if (nbv->pairlistSets().isDynamicPruningStepCpu(step))
+ if (nbv->isDynamicPruningStepCpu(step))
{
/* Prune the pair-list beyond fr->ic->rlistPrune using
* the current coordinates of the atoms.
wallcycle_sub_start_nocount(wcycle, ewcsLAUNCH_GPU_NONBONDED);
Nbnxm::gpu_clear_outputs(nbv->gpu_nbv, flags);
- if (nbv->pairlistSets().isDynamicPruningStepGpu(step))
+ if (nbv->isDynamicPruningStepGpu(step))
{
nbv->dispatchPruneKernelGpu(step);
}
if (bPMETune)
{
pme_loadbal_init(&pme_loadbal, cr, mdlog, *ir, state->box,
- *fr->ic, fr->nbv->pairlistSets().params(), fr->pmedata, fr->nbv->useGpu(),
+ *fr->ic, *fr->nbv, fr->pmedata, fr->nbv->useGpu(),
&bPMETunePrinting);
}
#include "gromacs/nbnxm/atomdata.h"
#include "gromacs/nbnxm/gpu_data_mgmt.h"
#include "gromacs/nbnxm/nbnxm.h"
+#include "gromacs/nbnxm/pairlistsets.h"
#include "gromacs/pbcutil/ishift.h"
#include "gromacs/timing/gpu_timing.h"
#include "gromacs/utility/basedefinitions.h"
/*! Copies all parameters related to the cut-off from ic to nbp */
static void set_cutoff_parameters(cu_nbparam_t *nbp,
const interaction_const_t *ic,
- const NbnxnListParameters *listParams)
+ const PairlistParams &listParams)
{
nbp->ewald_beta = ic->ewaldcoeff_q;
nbp->sh_ewald = ic->sh_ewald;
nbp->c_rf = ic->c_rf;
nbp->rvdw_sq = ic->rvdw * ic->rvdw;
nbp->rcoulomb_sq = ic->rcoulomb * ic->rcoulomb;
- nbp->rlistOuter_sq = listParams->rlistOuter * listParams->rlistOuter;
- nbp->rlistInner_sq = listParams->rlistInner * listParams->rlistInner;
- nbp->useDynamicPruning = listParams->useDynamicPruning;
+ nbp->rlistOuter_sq = listParams.rlistOuter * listParams.rlistOuter;
+ nbp->rlistInner_sq = listParams.rlistInner * listParams.rlistInner;
+ nbp->useDynamicPruning = listParams.useDynamicPruning;
nbp->sh_lj_ewald = ic->sh_lj_ewald;
nbp->ewaldcoeff_lj = ic->ewaldcoeff_lj;
/*! Initializes the nonbonded parameter data structure. */
static void init_nbparam(cu_nbparam_t *nbp,
const interaction_const_t *ic,
- const NbnxnListParameters *listParams,
+ const PairlistParams &listParams,
const nbnxn_atomdata_t::Params &nbatParams)
{
int ntypes;
/*! Re-generate the GPU Ewald force table, resets rlist, and update the
* electrostatic type switching to twin cut-off (or back) if needed. */
void gpu_pme_loadbal_update_param(const nonbonded_verlet_t *nbv,
- const interaction_const_t *ic,
- const NbnxnListParameters *listParams)
+ const interaction_const_t *ic)
{
if (!nbv || !nbv->useGpu())
{
}
cu_nbparam_t *nbp = nbv->gpu_nbv->nbparam;
- set_cutoff_parameters(nbp, ic, listParams);
+ set_cutoff_parameters(nbp, ic, nbv->pairlistSets().params());
nbp->eeltype = pick_ewald_kernel_type(ic->rcoulomb != ic->rvdw);
/*! Initializes simulation constant data. */
static void cuda_init_const(gmx_nbnxn_cuda_t *nb,
const interaction_const_t *ic,
- const NbnxnListParameters *listParams,
+ const PairlistParams &listParams,
const nbnxn_atomdata_t::Params &nbatParams)
{
init_atomdata_first(nb->atdat, nbatParams.numTypes);
gmx_nbnxn_cuda_t *
gpu_init(const gmx_device_info_t *deviceInfo,
const interaction_const_t *ic,
- const NbnxnListParameters *listParams,
+ const PairlistParams &listParams,
const nbnxn_atomdata_t *nbat,
int /*rank*/,
gmx_bool bLocalAndNonlocal)
struct nonbonded_verlet_group_t;
struct NbnxnPairlistGpu;
struct nbnxn_atomdata_t;
-struct NbnxnListParameters;
+struct PairlistParams;
struct gmx_wallclock_gpu_nbnxn_t;
struct gmx_gpu_info_t;
struct gmx_device_info_t;
gmx_nbnxn_gpu_t *
gpu_init(const gmx_device_info_t gmx_unused *deviceInfo,
const interaction_const_t gmx_unused *ic,
- const NbnxnListParameters gmx_unused *listParams,
+ const PairlistParams gmx_unused &listParams,
const nbnxn_atomdata_t gmx_unused *nbat,
int gmx_unused rank,
/* true if both local and non-local are done on GPU */
*/
GPU_FUNC_QUALIFIER
void gpu_pme_loadbal_update_param(const struct nonbonded_verlet_t gmx_unused *nbv,
- const interaction_const_t gmx_unused *ic,
- const NbnxnListParameters gmx_unused *listParams) GPU_FUNC_TERM
+ const interaction_const_t gmx_unused *ic) GPU_FUNC_TERM
/** Uploads shift vector to the GPU if the box is dynamic (otherwise just returns). */
GPU_FUNC_QUALIFIER
#include "gromacs/utility/real.h"
#include "kernel_common.h"
+#include "pairlistsets.h"
#define INCLUDE_KERNELFUNCTION_TABLES
#include "gromacs/nbnxm/kernels_reference/kernel_ref.h"
#ifdef GMX_NBNXN_SIMD_2XNN
#include "gromacs/nbnxm/atomdata.h"
#include "gromacs/timing/wallcycle.h"
+#include "pairlistsets.h"
#include "pairsearch.h"
/*! \cond INTERNAL */
}
}
+bool nonbonded_verlet_t::isDynamicPruningStepCpu(int64_t step) const
+{
+ return pairlistSets_->isDynamicPruningStepCpu(step);
+}
+
+bool nonbonded_verlet_t::isDynamicPruningStepGpu(int64_t step) const
+{
+ return pairlistSets_->isDynamicPruningStepGpu(step);
+}
+
gmx::ArrayRef<const int> nonbonded_verlet_t::getLocalAtomOrder() const
{
/* Return the atom order for the home cell (index 0) */
wallcycle_stop(wcycle, ewcNB_XF_BUF_OPS);
}
+real nonbonded_verlet_t::pairlistInnerRadius() const
+{
+ return pairlistSets_->params().rlistInner;
+}
+
+real nonbonded_verlet_t::pairlistOuterRadius() const
+{
+ return pairlistSets_->params().rlistOuter;
+}
+
+void nonbonded_verlet_t::changePairlistRadii(real rlistOuter,
+ real rlistInner)
+{
+ pairlistSets_->changePairlistRadii(rlistOuter, rlistInner);
+}
+
/*! \endcond */
struct gmx_wallcycle;
struct interaction_const_t;
struct nonbonded_verlet_t;
-enum class PairlistType;
class PairSearch;
-class PairlistSet;
+class PairlistSets;
struct t_blocka;
struct t_commrec;
struct t_lambda;
enum class KernelType;
}
-/*! \libinternal
- * \brief The setup for generating and pruning the nbnxn pair list.
- *
- * Without dynamic pruning rlistOuter=rlistInner.
- */
-struct NbnxnListParameters
-{
- /*! \brief Constructor producing a struct with dynamic pruning disabled
- */
- NbnxnListParameters(Nbnxm::KernelType kernelType,
- bool haveFep,
- real rlist,
- bool haveMultipleDomains);
-
- PairlistType pairlistType; //!< The type of cluster-pair list
- bool haveFep; //!< Tells whether we have perturbed interactions
- real rlistOuter; //!< Cut-off of the larger, outer pair-list
- real rlistInner; //!< Cut-off of the smaller, inner pair-list
- bool haveMultipleDomains; //!< True when using DD with multiple domains
- bool useDynamicPruning; //!< Are we using dynamic pair-list pruning
- int nstlistPrune; //!< Pair-list dynamic pruning interval
- int numRollingPruningParts; //!< The number parts to divide the pair-list into for rolling pruning, a value of 1 gives no rolling pruning
- int lifetime; //!< Lifetime in steps of the pair-list
-};
-
-/*! \brief Resources that can be used to execute non-bonded kernels on */
-enum class NonbondedResource : int
-{
- Cpu,
- Gpu,
- EmulateGpu
-};
-
namespace Nbnxm
{
enbvClearFNo, enbvClearFYes
};
-/*! \brief Generates a pair-list for the given locality.
- *
- * With perturbed particles, also a group scheme style nbl_fep list is made.
- */
-void nbnxn_make_pairlist(nonbonded_verlet_t *nbv,
- Nbnxm::InteractionLocality iLocality,
- PairlistSet *pairlistSet,
- const t_blocka *excl,
- int64_t step,
- t_nrnb *nrnb);
-
-/*! \brief Prune all pair-lists with given locality (currently CPU only)
- *
- * For all pair-lists with given locality, takes the outer list and prunes out
- * pairs beyond the pairlist inner radius and writes the result to a list that is
- * to be consumed by the non-bonded kernel.
- */
-void NbnxnDispatchPruneKernel(PairlistSet *pairlistSet,
- Nbnxm::KernelType kernelType,
- const nbnxn_atomdata_t *nbat,
- const rvec *shift_vec);
-
/*! \libinternal
* \brief Top-level non-bonded data structure for the Verlet-type cut-off scheme. */
struct nonbonded_verlet_t
{
public:
- class PairlistSets
- {
- public:
- PairlistSets(const NbnxnListParameters &listParams,
- bool haveMultipleDomains,
- int minimumIlistCountForGpuBalancing);
-
- //! Construct the pairlist set for the given locality
- void construct(Nbnxm::InteractionLocality iLocality,
- PairSearch *pairSearch,
- nbnxn_atomdata_t *nbat,
- const t_blocka *excl,
- Nbnxm::KernelType kernelbType,
- int64_t step,
- t_nrnb *nrnb);
-
- //! Dispatches the dynamic pruning kernel for the given locality
- void dispatchPruneKernel(Nbnxm::InteractionLocality iLocality,
- const nbnxn_atomdata_t *nbat,
- const rvec *shift_vec,
- Nbnxm::KernelType kernelbType);
-
- //! Returns the pair list parameters
- const NbnxnListParameters ¶ms() const
- {
- return params_;
- }
-
- //! Returns the number of steps performed with the current pair list
- int numStepsWithPairlist(int64_t step) const
- {
- return step - outerListCreationStep_;
- }
-
- //! Returns whether step is a dynamic list pruning step, for CPU lists
- bool isDynamicPruningStepCpu(int64_t step) const
- {
- return (params_.useDynamicPruning &&
- numStepsWithPairlist(step) % params_.nstlistPrune == 0);
- }
-
- //! Returns whether step is a dynamic list pruning step, for GPU lists
- bool isDynamicPruningStepGpu(int64_t step) const
- {
- const int age = numStepsWithPairlist(step);
-
- return (params_.useDynamicPruning &&
- age > 0 &&
- age < params_.lifetime &&
- (params_.haveMultipleDomains || age % 2 == 0));
- }
-
- //! Changes the pair-list outer and inner radius
- void changeRadii(real rlistOuter,
- real rlistInner)
- {
- params_.rlistOuter = rlistOuter;
- params_.rlistInner = rlistInner;
- }
-
- //! Returns the pair-list set for the given locality
- const PairlistSet &pairlistSet(Nbnxm::InteractionLocality iLocality) const
- {
- if (iLocality == Nbnxm::InteractionLocality::Local)
- {
- return *localSet_;
- }
- else
- {
- GMX_ASSERT(nonlocalSet_, "Need a non-local set when requesting access");
- return *nonlocalSet_;
- }
- }
-
- private:
- //! Returns the pair-list set for the given locality
- PairlistSet &pairlistSet(Nbnxm::InteractionLocality iLocality)
- {
- if (iLocality == Nbnxm::InteractionLocality::Local)
- {
- return *localSet_;
- }
- else
- {
- GMX_ASSERT(nonlocalSet_, "Need a non-local set when requesting access");
- return *nonlocalSet_;
- }
- }
-
- //! Parameters for the search and list pruning setup
- NbnxnListParameters params_;
- //! Pair list balancing parameter for use with GPU
- int minimumIlistCountForGpuBalancing_;
- //! Local pairlist set
- std::unique_ptr<PairlistSet> localSet_;
- //! Non-local pairlist set
- std::unique_ptr<PairlistSet> nonlocalSet_;
- //! MD step at with the outer lists in pairlistSets_ were created
- int64_t outerListCreationStep_;
- };
-
//! Constructs an object from its components
nonbonded_verlet_t(std::unique_ptr<PairlistSets> pairlistSets,
std::unique_ptr<PairSearch> pairSearch,
return *pairlistSets_;
}
+ //! Returns whether step is a dynamic list pruning step, for CPU lists
+ bool isDynamicPruningStepCpu(int64_t step) const;
+
+ //! Returns whether step is a dynamic list pruning step, for GPU lists
+ bool isDynamicPruningStepGpu(int64_t step) const;
+
//! Dispatches the dynamic pruning kernel for the given locality, for CPU lists
void dispatchPruneKernelCpu(Nbnxm::InteractionLocality iLocality,
const rvec *shift_vec);
//! Dispatches the dynamic pruning kernel for GPU lists
- void dispatchPruneKernelGpu(int64_t step)
- {
- const bool stepIsEven = (pairlistSets().numStepsWithPairlist(step) % 2 == 0);
-
- Nbnxm::gpu_launch_kernel_pruneonly(gpu_nbv,
- stepIsEven ? Nbnxm::InteractionLocality::Local : Nbnxm::InteractionLocality::NonLocal,
- pairlistSets().params().numRollingPruningParts);
- }
+ void dispatchPruneKernelGpu(int64_t step);
//! \brief Executes the non-bonded kernel of the GPU or launches it on the GPU
void dispatchNonbondedKernel(Nbnxm::InteractionLocality iLocality,
void getLocalNumCells(int *numCellsX,
int *numCellsY) const;
+
+ //! Returns the outer radius for the pair list
+ real pairlistInnerRadius() const;
+
+ //! Returns the outer radius for the pair list
+ real pairlistOuterRadius() const;
+
+ //! Changes the pair-list outer and inner radius
+ void changePairlistRadii(real rlistOuter,
+ real rlistInner);
+
// TODO: Make all data members private
public:
//! All data related to the pair lists
#include "gpu_types.h"
#include "grid.h"
+#include "pairlistsets.h"
#include "pairsearch.h"
namespace Nbnxm
{
+/*! \brief Resources that can be used to execute non-bonded kernels on */
+enum class NonbondedResource : int
+{
+ Cpu,
+ Gpu,
+ EmulateGpu
+};
+
/*! \brief Returns whether CPU SIMD support exists for the given inputrec
*
* If the return value is FALSE and fplog/cr != NULL, prints a fallback
} // namespace Nbnxm
-nonbonded_verlet_t::PairlistSets::PairlistSets(const NbnxnListParameters &listParams,
- const bool haveMultipleDomains,
- const int minimumIlistCountForGpuBalancing) :
- params_(listParams),
+PairlistSets::PairlistSets(const PairlistParams &pairlistParams,
+ const bool haveMultipleDomains,
+ const int minimumIlistCountForGpuBalancing) :
+ params_(pairlistParams),
minimumIlistCountForGpuBalancing_(minimumIlistCountForGpuBalancing)
{
localSet_ = std::make_unique<PairlistSet>(Nbnxm::InteractionLocality::Local,
const bool haveMultipleDomains = (DOMAINDECOMP(cr) && cr->dd->nnodes > 1);
- NbnxnListParameters listParams(kernelSetup.kernelType,
- bFEP_NonBonded,
- ir->rlist,
- havePPDomainDecomposition(cr));
+ PairlistParams pairlistParams(kernelSetup.kernelType,
+ bFEP_NonBonded,
+ ir->rlist,
+ havePPDomainDecomposition(cr));
setupDynamicPairlistPruning(mdlog, ir, mtop, box, fr->ic,
- &listParams);
+ &pairlistParams);
int enbnxninitcombrule;
if (fr->ic->vdwtype == evdwCUT &&
* both local and non-local NB calculation on GPU */
gpu_nbv = gpu_init(deviceInfo,
fr->ic,
- &listParams,
+ pairlistParams,
nbat.get(),
cr->nodeid,
haveMultipleDomains);
}
auto pairlistSets =
- std::make_unique<nonbonded_verlet_t::PairlistSets>(listParams,
- haveMultipleDomains,
- minimumIlistCountForGpuBalancing);
+ std::make_unique<PairlistSets>(pairlistParams,
+ haveMultipleDomains,
+ minimumIlistCountForGpuBalancing);
auto pairSearch =
std::make_unique<PairSearch>(ir->ePBC,
DOMAINDECOMP(cr) ? &cr->dd->nc : nullptr,
DOMAINDECOMP(cr) ? domdec_zones(cr->dd) : nullptr,
- listParams.pairlistType,
+ pairlistParams.pairlistType,
bFEP_NonBonded,
gmx_omp_nthreads_get(emntPairsearch));
#include "gromacs/nbnxm/gpu_jit_support.h"
#include "gromacs/nbnxm/nbnxm.h"
#include "gromacs/nbnxm/nbnxm_gpu.h"
+#include "gromacs/nbnxm/pairlistsets.h"
#include "gromacs/pbcutil/ishift.h"
#include "gromacs/timing/gpu_timing.h"
#include "gromacs/utility/cstringutil.h"
*/
static void set_cutoff_parameters(cl_nbparam_t *nbp,
const interaction_const_t *ic,
- const NbnxnListParameters *listParams)
+ const PairlistParams &listParams)
{
nbp->ewald_beta = ic->ewaldcoeff_q;
nbp->sh_ewald = ic->sh_ewald;
nbp->c_rf = ic->c_rf;
nbp->rvdw_sq = ic->rvdw * ic->rvdw;
nbp->rcoulomb_sq = ic->rcoulomb * ic->rcoulomb;
- nbp->rlistOuter_sq = listParams->rlistOuter * listParams->rlistOuter;
- nbp->rlistInner_sq = listParams->rlistInner * listParams->rlistInner;
- nbp->useDynamicPruning = listParams->useDynamicPruning;
+ nbp->rlistOuter_sq = listParams.rlistOuter * listParams.rlistOuter;
+ nbp->rlistInner_sq = listParams.rlistInner * listParams.rlistInner;
+ nbp->useDynamicPruning = listParams.useDynamicPruning;
nbp->sh_lj_ewald = ic->sh_lj_ewald;
nbp->ewaldcoeff_lj = ic->ewaldcoeff_lj;
*/
static void init_nbparam(cl_nbparam_t *nbp,
const interaction_const_t *ic,
- const NbnxnListParameters *listParams,
+ const PairlistParams &listParams,
const nbnxn_atomdata_t::Params &nbatParams,
const gmx_device_runtime_data_t *runData)
{
//! This function is documented in the header file
void gpu_pme_loadbal_update_param(const nonbonded_verlet_t *nbv,
- const interaction_const_t *ic,
- const NbnxnListParameters *listParams)
+ const interaction_const_t *ic)
{
if (!nbv || !nbv->useGpu())
{
gmx_nbnxn_ocl_t *nb = nbv->gpu_nbv;
cl_nbparam_t *nbp = nb->nbparam;
- set_cutoff_parameters(nbp, ic, listParams);
+ set_cutoff_parameters(nbp, ic, nbv->pairlistSets().params());
nbp->eeltype = gpu_pick_ewald_kernel_type(ic->rcoulomb != ic->rvdw);
*/
static void nbnxn_ocl_init_const(gmx_nbnxn_ocl_t *nb,
const interaction_const_t *ic,
- const NbnxnListParameters *listParams,
+ const PairlistParams &listParams,
const nbnxn_atomdata_t::Params &nbatParams)
{
init_atomdata_first(nb->atdat, nbatParams.numTypes, nb->dev_rundata);
gmx_nbnxn_ocl_t *
gpu_init(const gmx_device_info_t *deviceInfo,
const interaction_const_t *ic,
- const NbnxnListParameters *listParams,
+ const PairlistParams &listParams,
const nbnxn_atomdata_t *nbat,
const int rank,
const gmx_bool bLocalAndNonlocal)
#include "gromacs/utility/smalloc.h"
#include "gridset.h"
+#include "pairlistsets.h"
#include "pairlistwork.h"
#include "pairsearch.h"
// TODO: Move to pairlistset.cpp
PairlistSet::PairlistSet(const Nbnxm::InteractionLocality locality,
- const NbnxnListParameters &listParams) :
+ const PairlistParams &pairlistParams) :
locality_(locality),
- params_(listParams)
+ params_(pairlistParams)
{
isCpuType_ =
(params_.pairlistType == PairlistType::Simple4x2 ||
}
void
-nonbonded_verlet_t::PairlistSets::construct(const InteractionLocality iLocality,
- PairSearch *pairSearch,
- nbnxn_atomdata_t *nbat,
- const t_blocka *excl,
- const Nbnxm::KernelType kernelType,
- const int64_t step,
- t_nrnb *nrnb)
+PairlistSets::construct(const InteractionLocality iLocality,
+ PairSearch *pairSearch,
+ nbnxn_atomdata_t *nbat,
+ const t_blocka *excl,
+ const Nbnxm::KernelType kernelType,
+ const int64_t step,
+ t_nrnb *nrnb)
{
pairlistSet(iLocality).constructPairlists(pairSearch, nbat, excl, kernelType, minimumIlistCountForGpuBalancing_, nrnb);
#include "locality.h"
-struct NbnxnListParameters;
struct NbnxnPairlistCpuWork;
struct NbnxnPairlistGpuWork;
struct nbnxn_atomdata_t;
+struct PairlistParams;
class PairSearch;
struct t_blocka;
struct t_nrnb;
public:
//! Constructor: initializes the pairlist set as empty
PairlistSet(Nbnxm::InteractionLocality locality,
- const NbnxnListParameters &listParams);
+ const PairlistParams &listParams);
~PairlistSet();
//! List of pairlists in GPU layout
std::vector<NbnxnPairlistGpu> gpuLists_;
//! Pairlist parameters describing setup and ranges
- const NbnxnListParameters ¶ms_;
+ const PairlistParams ¶ms_;
//! Tells whether multiple lists get merged into one (the first) after creation
bool combineLists_;
//! Tells whether the lists is of CPU type, otherwise GPU type
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/interaction_const.h"
#include "gromacs/mdtypes/state.h"
-#include "gromacs/nbnxm/nbnxm.h"
#include "gromacs/nbnxm/nbnxm_geometry.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/strconvert.h"
#include "gromacs/utility/stringutil.h"
+#include "pairlistsets.h"
+
/*! \brief Returns if we can (heuristically) change nstlist and rlist
*
* \param [in] ir The input parameter record
const VerletbufListSetup &listSetup,
const bool userSetNstlistPrune,
const interaction_const_t *ic,
- NbnxnListParameters *listParams)
+ PairlistParams *listParams)
{
listParams->lifetime = ir->nstlist - 1;
const gmx_mtop_t *mtop,
matrix box,
const interaction_const_t *ic,
- NbnxnListParameters *listParams)
+ PairlistParams *listParams)
{
GMX_RELEASE_ASSERT(listParams->rlistOuter > 0, "With the nbnxn setup rlist should be > 0");
struct gmx_mtop_t;
struct interaction_const_t;
-struct NbnxnListParameters;
+struct PairlistParams;
struct t_commrec;
struct t_inputrec;
const gmx_mtop_t *mtop,
matrix box,
const interaction_const_t *ic,
- NbnxnListParameters *listParams);
+ PairlistParams *listParams);
#endif /* NBNXM_PAIRLIST_TUNING_H */
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+
+/*! \internal \file
+ * \brief
+ * Implements the PairlistParams constructor
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \ingroup module_nbnxm
+ */
+
+#include "gmxpre.h"
+
+#include "pairlistparams.h"
+
+#include "gromacs/nbnxm/nbnxm.h"
+#include "gromacs/nbnxm/nbnxm_geometry.h"
+#include "gromacs/utility/gmxassert.h"
+
+
+PairlistParams::PairlistParams(const Nbnxm::KernelType kernelType,
+ const bool haveFep,
+ const real rlist,
+ const bool haveMultipleDomains) :
+ haveFep(haveFep),
+ rlistOuter(rlist),
+ rlistInner(rlist),
+ haveMultipleDomains(haveMultipleDomains),
+ useDynamicPruning(false),
+ nstlistPrune(-1),
+ numRollingPruningParts(1),
+ lifetime(-1)
+{
+ if (!Nbnxm::kernelTypeUsesSimplePairlist(kernelType))
+ {
+ pairlistType = PairlistType::HierarchicalNxN;
+ }
+ else
+ {
+ switch (Nbnxm::JClusterSizePerKernelType[kernelType])
+ {
+ case 2:
+ pairlistType = PairlistType::Simple4x2;
+ break;
+ case 4:
+ pairlistType = PairlistType::Simple4x4;
+ break;
+ case 8:
+ pairlistType = PairlistType::Simple4x8;
+ break;
+ default:
+ GMX_RELEASE_ASSERT(false, "Kernel type does not have a pairlist type");
+ }
+ }
+}
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2019, 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+
+/*! \internal \file
+ *
+ * \brief
+ * Declares the PairlistParams class
+ *
+ * This class holds the Nbnxm pairlist parameters.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \ingroup module_nbnxm
+ */
+
+#ifndef GMX_NBNXM_PAIRLISTPARAMS_H
+#define GMX_NBNXM_PAIRLISTPARAMS_H
+
+#include "gromacs/utility/real.h"
+
+#include "locality.h"
+
+enum class PairlistType;
+
+namespace Nbnxm
+{
+enum class KernelType;
+}
+
+
+/*! \internal
+ * \brief The setup for generating and pruning the nbnxn pair list.
+ *
+ * Without dynamic pruning rlistOuter=rlistInner.
+ */
+struct PairlistParams
+{
+ /*! \brief Constructor producing a struct with dynamic pruning disabled
+ */
+ PairlistParams(Nbnxm::KernelType kernelType,
+ bool haveFep,
+ real rlist,
+ bool haveMultipleDomains);
+
+ PairlistType pairlistType; //!< The type of cluster-pair list
+ bool haveFep; //!< Tells whether we have perturbed interactions
+ real rlistOuter; //!< Cut-off of the larger, outer pair-list
+ real rlistInner; //!< Cut-off of the smaller, inner pair-list
+ bool haveMultipleDomains; //!< True when using DD with multiple domains
+ bool useDynamicPruning; //!< Are we using dynamic pair-list pruning
+ int nstlistPrune; //!< Pair-list dynamic pruning interval
+ int numRollingPruningParts; //!< The number parts to divide the pair-list into for rolling pruning, a value of 1 gives no rolling pruning
+ int lifetime; //!< Lifetime in steps of the pair-list
+};
+
+#endif
/*! \internal \file
* \brief
- * Implements functionality for nbnxn_pairlist_set_t.
+ * Implements functionality for PairlistSet.
*
* \author Berk Hess <hess@kth.se>
* \ingroup module_nbnxm
#include "pairlistset.h"
-#include "gromacs/nbnxm/nbnxm.h"
-#include "gromacs/nbnxm/nbnxm_geometry.h"
-#include "gromacs/nbnxm/pairlist.h"
-#include "gromacs/utility/gmxassert.h"
-
#include "pairlistwork.h"
-/*! \cond INTERNAL */
-
-NbnxnListParameters::NbnxnListParameters(const Nbnxm::KernelType kernelType,
- const bool haveFep,
- const real rlist,
- const bool haveMultipleDomains) :
- haveFep(haveFep),
- rlistOuter(rlist),
- rlistInner(rlist),
- haveMultipleDomains(haveMultipleDomains),
- useDynamicPruning(false),
- nstlistPrune(-1),
- numRollingPruningParts(1),
- lifetime(-1)
-{
- if (!Nbnxm::kernelTypeUsesSimplePairlist(kernelType))
- {
- pairlistType = PairlistType::HierarchicalNxN;
- }
- else
- {
- switch (Nbnxm::JClusterSizePerKernelType[kernelType])
- {
- case 2:
- pairlistType = PairlistType::Simple4x2;
- break;
- case 4:
- pairlistType = PairlistType::Simple4x4;
- break;
- case 8:
- pairlistType = PairlistType::Simple4x8;
- break;
- default:
- GMX_RELEASE_ASSERT(false, "Kernel type does not have a pairlist type");
- }
- }
-}
-
PairlistSet::~PairlistSet() = default;
-
-/*! \endcond */
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2012,2013,2014,2015,2017,2018,2019, 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+
+/*! \internal \file
+ *
+ * \brief
+ * Declares the PairlistSets class
+ *
+ * This class holds the local and non-local pairlist sets.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \ingroup module_nbnxm
+ */
+
+#ifndef GMX_NBNXM_PAIRLISTSETS_H
+#define GMX_NBNXM_PAIRLISTSETS_H
+
+#include <memory>
+
+#include "locality.h"
+#include "pairlistparams.h"
+
+struct nbnxn_atomdata_t;
+class PairlistSet;
+enum class PairlistType;
+class PairSearch;
+struct t_blocka;
+struct t_nrnb;
+
+namespace Nbnxm
+{
+enum class KernelType;
+}
+
+
+class PairlistSets
+{
+ public:
+ PairlistSets(const PairlistParams &pairlistParams,
+ bool haveMultipleDomains,
+ int minimumIlistCountForGpuBalancing);
+
+ //! Construct the pairlist set for the given locality
+ void construct(Nbnxm::InteractionLocality iLocality,
+ PairSearch *pairSearch,
+ nbnxn_atomdata_t *nbat,
+ const t_blocka *excl,
+ Nbnxm::KernelType kernelbType,
+ int64_t step,
+ t_nrnb *nrnb);
+
+ //! Dispatches the dynamic pruning kernel for the given locality
+ void dispatchPruneKernel(Nbnxm::InteractionLocality iLocality,
+ const nbnxn_atomdata_t *nbat,
+ const rvec *shift_vec,
+ Nbnxm::KernelType kernelType);
+
+ //! Returns the pair list parameters
+ const PairlistParams ¶ms() const
+ {
+ return params_;
+ }
+
+ //! Returns the number of steps performed with the current pair list
+ int numStepsWithPairlist(int64_t step) const
+ {
+ return step - outerListCreationStep_;
+ }
+
+ //! Returns whether step is a dynamic list pruning step, for CPU lists
+ bool isDynamicPruningStepCpu(int64_t step) const
+ {
+ return (params_.useDynamicPruning &&
+ numStepsWithPairlist(step) % params_.nstlistPrune == 0);
+ }
+
+ //! Returns whether step is a dynamic list pruning step, for GPU lists
+ bool isDynamicPruningStepGpu(int64_t step) const
+ {
+ const int age = numStepsWithPairlist(step);
+
+ return (params_.useDynamicPruning &&
+ age > 0 &&
+ age < params_.lifetime &&
+ (params_.haveMultipleDomains || age % 2 == 0));
+ }
+
+ //! Changes the pair-list outer and inner radius
+ void changePairlistRadii(real rlistOuter,
+ real rlistInner)
+ {
+ params_.rlistOuter = rlistOuter;
+ params_.rlistInner = rlistInner;
+ }
+
+ //! Returns the pair-list set for the given locality
+ const PairlistSet &pairlistSet(Nbnxm::InteractionLocality iLocality) const
+ {
+ if (iLocality == Nbnxm::InteractionLocality::Local)
+ {
+ return *localSet_;
+ }
+ else
+ {
+ GMX_ASSERT(nonlocalSet_, "Need a non-local set when requesting access");
+ return *nonlocalSet_;
+ }
+ }
+
+ private:
+ //! Returns the pair-list set for the given locality
+ PairlistSet &pairlistSet(Nbnxm::InteractionLocality iLocality)
+ {
+ if (iLocality == Nbnxm::InteractionLocality::Local)
+ {
+ return *localSet_;
+ }
+ else
+ {
+ GMX_ASSERT(nonlocalSet_, "Need a non-local set when requesting access");
+ return *nonlocalSet_;
+ }
+ }
+
+ //! Parameters for the search and list pruning setup
+ PairlistParams params_;
+ //! Pair list balancing parameter for use with GPU
+ int minimumIlistCountForGpuBalancing_;
+ //! Local pairlist set
+ std::unique_ptr<PairlistSet> localSet_;
+ //! Non-local pairlist set
+ std::unique_ptr<PairlistSet> nonlocalSet_;
+ //! MD step at with the outer lists in pairlistSets_ were created
+ int64_t outerListCreationStep_;
+};
+
+#endif
#include "gromacs/nbnxm/pairlist.h"
#include "gromacs/utility/gmxassert.h"
+#include "pairlistsets.h"
#include "kernels_reference/kernel_ref_prune.h"
#include "kernels_simd_2xmm/kernel_prune.h"
#include "kernels_simd_4xm/kernel_prune.h"
void
-nonbonded_verlet_t::PairlistSets::dispatchPruneKernel(const Nbnxm::InteractionLocality iLocality,
- const nbnxn_atomdata_t *nbat,
- const rvec *shift_vec,
- const Nbnxm::KernelType kernelType)
+PairlistSets::dispatchPruneKernel(const Nbnxm::InteractionLocality iLocality,
+ const nbnxn_atomdata_t *nbat,
+ const rvec *shift_vec,
+ const Nbnxm::KernelType kernelType)
{
pairlistSet(iLocality).dispatchPruneKernel(nbat, shift_vec, kernelType);
}
{
pairlistSets_->dispatchPruneKernel(iLocality, nbat.get(), shift_vec, kernelSetup_.kernelType);
}
+
+void nonbonded_verlet_t::dispatchPruneKernelGpu(int64_t step)
+{
+ const bool stepIsEven = (pairlistSets().numStepsWithPairlist(step) % 2 == 0);
+
+ Nbnxm::gpu_launch_kernel_pruneonly(gpu_nbv,
+ stepIsEven ? Nbnxm::InteractionLocality::Local : Nbnxm::InteractionLocality::NonLocal,
+ pairlistSets().params().numRollingPruningParts);
+}