From 232727980cb6668894a40f5c5e0247c72d7fff31 Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Mon, 18 Mar 2019 16:25:26 +0100 Subject: [PATCH] Move PairlistSet declaration Moved the declaration of PairlistSet to pairlistset.h. Also completed the documentation. Change-Id: I0cac4bbf1919b4a2f39d8ead63aa75f112ab60c7 --- src/gromacs/nbnxm/kerneldispatch.cpp | 2 +- src/gromacs/nbnxm/nbnxm.cpp | 1 + src/gromacs/nbnxm/nbnxm_setup.cpp | 2 +- src/gromacs/nbnxm/pairlist.cpp | 2 +- src/gromacs/nbnxm/pairlist.h | 99 +------------------ src/gromacs/nbnxm/pairlistset.h | 110 +++++++++++++++++++++- src/gromacs/nbnxm/pairsearch.h | 1 + src/gromacs/nbnxm/prunekerneldispatch.cpp | 2 +- 8 files changed, 114 insertions(+), 105 deletions(-) diff --git a/src/gromacs/nbnxm/kerneldispatch.cpp b/src/gromacs/nbnxm/kerneldispatch.cpp index 6b40e39048..5d099ea6df 100644 --- a/src/gromacs/nbnxm/kerneldispatch.cpp +++ b/src/gromacs/nbnxm/kerneldispatch.cpp @@ -51,13 +51,13 @@ #include "gromacs/nbnxm/gpu_data_mgmt.h" #include "gromacs/nbnxm/nbnxm.h" #include "gromacs/nbnxm/nbnxm_simd.h" -#include "gromacs/nbnxm/pairlist.h" #include "gromacs/nbnxm/kernels_reference/kernel_gpu_ref.h" #include "gromacs/simd/simd.h" #include "gromacs/utility/gmxassert.h" #include "gromacs/utility/real.h" #include "kernel_common.h" +#include "pairlistset.h" #include "pairlistsets.h" #define INCLUDE_KERNELFUNCTION_TABLES #include "gromacs/nbnxm/kernels_reference/kernel_ref.h" diff --git a/src/gromacs/nbnxm/nbnxm.cpp b/src/gromacs/nbnxm/nbnxm.cpp index 1d486c60bc..eab38e59f3 100644 --- a/src/gromacs/nbnxm/nbnxm.cpp +++ b/src/gromacs/nbnxm/nbnxm.cpp @@ -49,6 +49,7 @@ #include "gromacs/nbnxm/atomdata.h" #include "gromacs/timing/wallcycle.h" +#include "pairlistset.h" #include "pairlistsets.h" #include "pairsearch.h" diff --git a/src/gromacs/nbnxm/nbnxm_setup.cpp b/src/gromacs/nbnxm/nbnxm_setup.cpp index 5d6576dcf8..794f6f98d4 100644 --- a/src/gromacs/nbnxm/nbnxm_setup.cpp +++ b/src/gromacs/nbnxm/nbnxm_setup.cpp @@ -56,13 +56,13 @@ #include "gromacs/nbnxm/nbnxm_simd.h" #include "gromacs/nbnxm/pairlist.h" #include "gromacs/nbnxm/pairlist_tuning.h" -#include "gromacs/nbnxm/pairlistset.h" #include "gromacs/simd/simd.h" #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/logger.h" #include "gpu_types.h" #include "grid.h" +#include "pairlistset.h" #include "pairlistsets.h" #include "pairsearch.h" diff --git a/src/gromacs/nbnxm/pairlist.cpp b/src/gromacs/nbnxm/pairlist.cpp index 847cf591d8..e0b6fd2416 100644 --- a/src/gromacs/nbnxm/pairlist.cpp +++ b/src/gromacs/nbnxm/pairlist.cpp @@ -59,7 +59,6 @@ #include "gromacs/nbnxm/nbnxm.h" #include "gromacs/nbnxm/nbnxm_geometry.h" #include "gromacs/nbnxm/nbnxm_simd.h" -#include "gromacs/nbnxm/pairlistset.h" #include "gromacs/pbcutil/ishift.h" #include "gromacs/pbcutil/pbc.h" #include "gromacs/simd/simd.h" @@ -71,6 +70,7 @@ #include "gromacs/utility/smalloc.h" #include "gridset.h" +#include "pairlistset.h" #include "pairlistsets.h" #include "pairlistwork.h" #include "pairsearch.h" diff --git a/src/gromacs/nbnxm/pairlist.h b/src/gromacs/nbnxm/pairlist.h index 5ef2559119..da19d70f9e 100644 --- a/src/gromacs/nbnxm/pairlist.h +++ b/src/gromacs/nbnxm/pairlist.h @@ -56,18 +56,7 @@ struct NbnxnPairlistCpuWork; struct NbnxnPairlistGpuWork; -struct nbnxn_atomdata_t; -struct PairlistParams; -struct PairsearchWork; -struct SearchCycleCounting; -struct t_blocka; -struct t_nrnb; - -namespace Nbnxm -{ -class GridSet; -enum class KernelType; -} + /* Convenience type for vector with aligned memory */ template @@ -292,92 +281,6 @@ struct NbnxnPairlistGpu gmx_cache_protect_t cp1; }; -/*! \internal - * \brief An object that holds the local or non-local pairlists - */ -class PairlistSet -{ - public: - //! Constructor: initializes the pairlist set as empty - PairlistSet(Nbnxm::InteractionLocality locality, - const PairlistParams &listParams); - - ~PairlistSet(); - - //! Constructs the pairlists in the set using the coordinates in \p nbat - void constructPairlists(const Nbnxm::GridSet &gridSet, - gmx::ArrayRef searchWork, - nbnxn_atomdata_t *nbat, - const t_blocka *excl, - Nbnxm::KernelType kernelType, - int minimumIlistCountForGpuBalancing, - t_nrnb *nrnb, - SearchCycleCounting *searchCycleCounting); - - //! Dispatch the kernel for dynamic pairlist pruning - void dispatchPruneKernel(const nbnxn_atomdata_t *nbat, - const rvec *shift_vec, - Nbnxm::KernelType kernelType); - - //! Returns the locality - Nbnxm::InteractionLocality locality() const - { - return locality_; - } - - //! Returns the lists of CPU pairlists - gmx::ArrayRef cpuLists() const - { - return cpuLists_; - } - - //! Returns a pointer to the GPU pairlist, nullptr when not present - const NbnxnPairlistGpu *gpuList() const - { - if (!gpuLists_.empty()) - { - return &gpuLists_[0]; - } - else - { - return nullptr; - } - } - - //! Returns the lists of free-energy pairlists, empty when nonbonded interactions are not perturbed - gmx::ArrayRef fepLists() const - { - return fepLists_; - } - - private: - //! The locality of the pairlist set - Nbnxm::InteractionLocality locality_; - //! List of pairlists in CPU layout - std::vector cpuLists_; - //! List of working list for rebalancing CPU lists - std::vector cpuListsWork_; - //! List of pairlists in GPU layout - std::vector gpuLists_; - //! Pairlist parameters describing setup and ranges - 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 - gmx_bool isCpuType_; - //! Lists for perturbed interactions in simple atom-atom layout - std::vector fepLists_; - - public: - /* Pair counts for flop counting */ - //! Total number of atom pairs for LJ+Q kernel - int natpair_ljq_; - //! Total number of atom pairs for LJ kernel - int natpair_lj_; - //! Total number of atom pairs for Q kernel - int natpair_q_; -}; - //! Initializes a free-energy pair-list void nbnxn_init_pairlist_fep(t_nblist *nl); diff --git a/src/gromacs/nbnxm/pairlistset.h b/src/gromacs/nbnxm/pairlistset.h index a35db0f835..1eea57d0e4 100644 --- a/src/gromacs/nbnxm/pairlistset.h +++ b/src/gromacs/nbnxm/pairlistset.h @@ -33,6 +33,19 @@ * the research papers on the package. Check out http://www.gromacs.org. */ +/*! \internal \file + * + * \brief + * Declares the PairlistSet class + * + * There is one PairlistSet object per locality. A PairlistSet + * holds a list of CPU- or GPU-type pairlist objects, one for each thread, + * as well as helper objects to construct each of those pairlists. + * + * \author Berk Hess + * \ingroup module_nbnxm + */ + #ifndef GMX_NBNXM_PAIRLISTSET_H #define GMX_NBNXM_PAIRLISTSET_H @@ -44,9 +57,100 @@ #include "locality.h" -/* Tells if the pair-list corresponding to nb_kernel_type is simple. - * Returns FALSE for super-sub type pair-list. +struct PairlistParams; +struct PairsearchWork; +struct SearchCycleCounting; +struct t_nrnb; + +namespace Nbnxm +{ +class GridSet; +} + +/*! \internal + * \brief An object that holds the local or non-local pairlists */ -gmx_bool nbnxn_kernel_pairlist_simple(int nb_kernel_type); +class PairlistSet +{ + public: + //! Constructor: initializes the pairlist set as empty + PairlistSet(Nbnxm::InteractionLocality locality, + const PairlistParams &listParams); + + ~PairlistSet(); + + //! Constructs the pairlists in the set using the coordinates in \p nbat + void constructPairlists(const Nbnxm::GridSet &gridSet, + gmx::ArrayRef searchWork, + nbnxn_atomdata_t *nbat, + const t_blocka *excl, + Nbnxm::KernelType kernelType, + int minimumIlistCountForGpuBalancing, + t_nrnb *nrnb, + SearchCycleCounting *searchCycleCounting); + + //! Dispatch the kernel for dynamic pairlist pruning + void dispatchPruneKernel(const nbnxn_atomdata_t *nbat, + const rvec *shift_vec, + Nbnxm::KernelType kernelType); + + //! Returns the locality + Nbnxm::InteractionLocality locality() const + { + return locality_; + } + + //! Returns the lists of CPU pairlists + gmx::ArrayRef cpuLists() const + { + return cpuLists_; + } + + //! Returns a pointer to the GPU pairlist, nullptr when not present + const NbnxnPairlistGpu *gpuList() const + { + if (!gpuLists_.empty()) + { + return &gpuLists_[0]; + } + else + { + return nullptr; + } + } + + //! Returns the lists of free-energy pairlists, empty when nonbonded interactions are not perturbed + gmx::ArrayRef fepLists() const + { + return fepLists_; + } + + private: + //! The locality of the pairlist set + Nbnxm::InteractionLocality locality_; + //! List of pairlists in CPU layout + std::vector cpuLists_; + //! List of working list for rebalancing CPU lists + std::vector cpuListsWork_; + //! List of pairlists in GPU layout + std::vector gpuLists_; + //! Pairlist parameters describing setup and ranges + 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 + gmx_bool isCpuType_; + //! Lists for perturbed interactions in simple atom-atom layout + std::vector fepLists_; + + public: + /* Pair counts for flop counting */ + //! Total number of atom pairs for LJ+Q kernel + int natpair_ljq_; + //! Total number of atom pairs for LJ kernel + int natpair_lj_; + //! Total number of atom pairs for Q kernel + int natpair_q_; +}; #endif diff --git a/src/gromacs/nbnxm/pairsearch.h b/src/gromacs/nbnxm/pairsearch.h index 7dcf54712d..f67037058f 100644 --- a/src/gromacs/nbnxm/pairsearch.h +++ b/src/gromacs/nbnxm/pairsearch.h @@ -65,6 +65,7 @@ #include "gridset.h" struct gmx_domdec_zones_t; +struct PairsearchWork; /*! \brief Convenience declaration for an std::vector with aligned memory */ diff --git a/src/gromacs/nbnxm/prunekerneldispatch.cpp b/src/gromacs/nbnxm/prunekerneldispatch.cpp index 76482e1647..2ee9a51861 100644 --- a/src/gromacs/nbnxm/prunekerneldispatch.cpp +++ b/src/gromacs/nbnxm/prunekerneldispatch.cpp @@ -37,9 +37,9 @@ #include "gromacs/mdlib/gmx_omp_nthreads.h" #include "gromacs/nbnxm/nbnxm.h" -#include "gromacs/nbnxm/pairlist.h" #include "gromacs/utility/gmxassert.h" +#include "pairlistset.h" #include "pairlistsets.h" #include "kernels_reference/kernel_ref_prune.h" #include "kernels_simd_2xmm/kernel_prune.h" -- 2.22.0