const interaction_const_t* ic = fr->ic;
// Extract pair list data
- const int nri = nlist->nri;
- const int* iinr = nlist->iinr;
- const int* jindex = nlist->jindex;
- const int* jjnr = nlist->jjnr;
- const int* shift = nlist->shift;
- const int* gid = nlist->gid;
+ const int nri = nlist->nri;
+ gmx::ArrayRef<const int> iinr = nlist->iinr;
+ gmx::ArrayRef<const int> jindex = nlist->jindex;
+ gmx::ArrayRef<const int> jjnr = nlist->jjnr;
+ gmx::ArrayRef<const int> shift = nlist->shift;
+ gmx::ArrayRef<const int> gid = nlist->gid;
const real* shiftvec = fr->shift_vec[0];
const real* chargeA = mdatoms->chargeA;
const RealType rSq = dX * dX + dY * dY + dZ * dZ;
RealType fScalC[NSTATES], fScalV[NSTATES];
/* Check if this pair on the exlusions list.*/
- const bool bPairIncluded = nlist->excl_fep == nullptr || nlist->excl_fep[k];
+ const bool bPairIncluded = nlist->excl_fep.empty() || nlist->excl_fep[k];
if (rSq >= rcutoff_max2 && bPairIncluded)
{
const char* eSwapFixedGrp_names[eSwapFixedGrpNR + 1] = { "Split0", "Split1", "Solvent", nullptr };
-const char* gmx_nblist_geometry_names[GMX_NBLIST_GEOMETRY_NR + 1] = {
- "Particle-Particle", "Water3-Particle", "Water3-Water3", "Water4-Particle",
- "Water4-Water4", "CG-CG", nullptr
-};
-
-const char* gmx_nblist_interaction_names[GMX_NBLIST_INTERACTION_NR + 1] = { "Standard",
- "Free_Energy",
- nullptr };
-
const char* gmx_nbkernel_elec_names[GMX_NBKERNEL_ELEC_NR + 1] = {
"None", "Coulomb", "Reaction-Field", "Cubic-Spline-Table", "Ewald", nullptr
};
//! String for swap group splitting
extern const char* eSwapFixedGrp_names[eSwapFixedGrpNR + 1];
-/*! \brief Neighborlist geometry type.
- *
- * Kernels will compute interactions between two particles,
- * 3-center water, 4-center water or coarse-grained beads.
- */
-enum gmx_nblist_kernel_geometry
-{
- GMX_NBLIST_GEOMETRY_PARTICLE_PARTICLE,
- GMX_NBLIST_GEOMETRY_WATER3_PARTICLE,
- GMX_NBLIST_GEOMETRY_WATER3_WATER3,
- GMX_NBLIST_GEOMETRY_WATER4_PARTICLE,
- GMX_NBLIST_GEOMETRY_WATER4_WATER4,
- GMX_NBLIST_GEOMETRY_CG_CG,
- GMX_NBLIST_GEOMETRY_NR
-};
-//! String corresponding to nblist geometry names
-extern const char* gmx_nblist_geometry_names[GMX_NBLIST_GEOMETRY_NR + 1];
-
/*! \brief Types of electrostatics calculations
*
* Types of electrostatics calculations available inside nonbonded kernels.
//! String corresponding to VdW kernels
extern const char* gmx_nbkernel_vdw_names[GMX_NBKERNEL_VDW_NR + 1];
-//! \brief Types of interactions inside the neighborlist
-enum gmx_nblist_interaction_type
-{
- GMX_NBLIST_INTERACTION_STANDARD,
- GMX_NBLIST_INTERACTION_FREE_ENERGY,
- GMX_NBLIST_INTERACTION_NR
-};
-//! String corresponding to interactions in neighborlist code
-extern const char* gmx_nblist_interaction_names[GMX_NBLIST_INTERACTION_NR + 1];
-
#endif /* GMX_MDTYPES_MD_ENUMS_H */
#include <vector>
#include "gromacs/utility/alignedallocator.h"
-#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
-typedef unsigned long t_excl;
-
/* The interactions contained in a (possibly merged) table
* for computing electrostatic, VDW repulsion and/or VDW dispersion
* contributions.
GMX_TABLE_FORMAT_NR
};
-enum
+struct t_nblist
{
- eNL_VDWQQ,
- eNL_VDW,
- eNL_QQ,
- eNL_VDWQQ_FREE,
- eNL_VDW_FREE,
- eNL_QQ_FREE,
- eNL_VDWQQ_WATER,
- eNL_QQ_WATER,
- eNL_VDWQQ_WATERWATER,
- eNL_QQ_WATERWATER,
- eNL_NR
+ int nri = 0; /* Current number of i particles */
+ int maxnri = 0; /* Max number of i particles */
+ int nrj = 0; /* Current number of j particles */
+ int maxnrj = 0; /* ;Max number of j particles */
+ std::vector<int> iinr; /* The i-elements */
+ std::vector<int> gid; /* Index in energy arrays */
+ std::vector<int> shift; /* Shift vector index */
+ std::vector<int> jindex; /* Index in jjnr */
+ std::vector<int> jjnr; /* The j-atom list */
+ std::vector<int> excl_fep; /* Exclusions for FEP with Verlet scheme */
};
-#define MAX_CG 1024
-
-typedef struct
-{
- int ncg;
- int nj;
- int jcg[MAX_CG];
-} t_ns_buf;
-
-
-/* The maximum charge group size because of minimum size of t_excl
- * could be 32 bits.
- */
-#define MAX_CHARGEGROUP_SIZE 32
-
-/* The maximum charge group size for CG-CG nblists.
- * The excl entry in t_nblist uses blocks of this size.
- */
-#define MAX_CGCGSIZE 32
-
-typedef struct t_nblist
-{
- int igeometry; /* The type of list (atom, water, etc.) */
- int ielec; /* Coulomb loop type index for kernels */
- int ielecmod; /* Coulomb modifier (e.g. switch/shift) */
- int ivdw; /* VdW loop type index for kernels */
- int ivdwmod; /* VdW modifier (e.g. switch/shift) */
- int type; /* Type of interaction, listed in
- gmx_nblist_interaction_type */
-
- int nri, maxnri; /* Current/max number of i particles */
- int nrj, maxnrj; /* Current/max number of j particles */
- int* iinr; /* The i-elements */
- int* iinr_end; /* The end atom, only with enlistCG */
- int* gid; /* Index in energy arrays */
- int* shift; /* Shift vector index */
- int* jindex; /* Index in jjnr */
- int* jjnr; /* The j-atom list */
- int* jjnr_end; /* The end atom, only with enltypeCG */
- char* excl_fep; /* Exclusions for FEP with Verlet scheme */
- t_excl* excl; /* Exclusions, only with enltypeCG */
-
- /* We use separate pointers for kernels that compute both potential
- * and force (vf suffix), only potential (v) or only force (f)
- */
- void* kernelptr_vf;
- void* kernelptr_v;
- void* kernelptr_f;
-
- /* Pad the list of neighbors for each i atom with "-1" entries up to the
- * simd_padding_width, if it is larger than 0. This is necessary for many
- * accelerated kernels using single-instruction multiple-data operations
- * internally.
- */
- int simd_padding_width;
-
-} t_nblist;
-
-/* For atom I = nblist->iinr[N] (0 <= N < nblist->nri) there can be
- * several neighborlists (N's), for different energy groups (gid) and
- * different shifts (shift).
- * For corresponding J atoms for each list start at:
- * nblist->jjnr[JI]
- * with nblist->jindex[N] <= JI < nblist->jindex[N+1]
- *
- * enlist is of the form enlistUNIT1_UNIT2:
- * UNIT ATOM: there is one atom: iinr[N] or jjnr[JI]
- * UNIT SPC: there are 3 atoms: iinr[N],iinr[N]+1,iinr[N]+2, jjnr analog.
- * UNIT TIP4P: there are 4 atoms: iinr[N],...,iinr[N]+3, jjnr analog.
- * UNIT CG: there are N atoms: iinr[N],...,iinr_end[N]-1, jjnr analog.
- *
- * Clear?
- */
-
/* Structure describing the data in a single table */
struct t_forcetable
{
int stride; /* Distance to next table point (number of fp variables per table point in total) */
};
-struct gmx_ns_t
-{
- gmx_bool bCGlist;
- int* simple_aaj;
- t_excl* bexcl;
- gmx_bool* bHaveVdW;
- t_ns_buf** ns_buf;
- gmx_bool* bExcludeAlleg;
- int nra_alloc;
- int cg_alloc;
- int** nl_sr;
- int* nsr;
- int** nl_lr_ljc;
- int** nl_lr_one;
- int* nlr_ljc;
- int* nlr_one;
- /* the nblists should probably go in here */
- gmx_bool nblist_initialized; /* has the nblist been initialized? */
- int dump_nl; /* neighbour list dump level (from env. var. GMX_DUMP_NL)*/
-};
-
#endif /* GMX_MDTYPES_NBLIST_H */
}
#endif // defined(GMX_NBNXN_SIMD_4XN) || defined(GMX_NBNXN_SIMD_2XNN)
-
-void nbnxn_init_pairlist_fep(t_nblist* nl)
-{
- nl->type = GMX_NBLIST_INTERACTION_FREE_ENERGY;
- nl->igeometry = GMX_NBLIST_GEOMETRY_PARTICLE_PARTICLE;
- /* The interaction functions are set in the free energy kernel function */
- nl->ivdw = -1;
- nl->ivdwmod = -1;
- nl->ielec = -1;
- nl->ielecmod = -1;
-
- nl->maxnri = 0;
- nl->maxnrj = 0;
- nl->nri = 0;
- nl->nrj = 0;
- nl->iinr = nullptr;
- nl->gid = nullptr;
- nl->shift = nullptr;
- nl->jindex = nullptr;
- nl->jjnr = nullptr;
- nl->excl_fep = nullptr;
-}
-
static constexpr int sizeNeededForBufferFlags(const int numAtoms)
{
return (numAtoms + NBNXN_BUFFERFLAG_SIZE - 1) / NBNXN_BUFFERFLAG_SIZE;
* impacts performance.
*/
fepLists_[i] = std::make_unique<t_nblist>();
- nbnxn_init_pairlist_fep(fepLists_[i].get());
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
}
/* Rellocate FEP list for size nl->maxnri, TODO: replace by C++ */
static void reallocate_nblist(t_nblist* nl)
{
- if (gmx_debug_at)
- {
- fprintf(debug,
- "reallocating neigborlist (ielec=%d, ivdw=%d, igeometry=%d, type=%d), maxnri=%d\n",
- nl->ielec,
- nl->ivdw,
- nl->igeometry,
- nl->type,
- nl->maxnri);
- }
- srenew(nl->iinr, nl->maxnri);
- srenew(nl->gid, nl->maxnri);
- srenew(nl->shift, nl->maxnri);
- srenew(nl->jindex, nl->maxnri + 1);
+ nl->iinr.resize(nl->maxnri);
+ nl->gid.resize(nl->maxnri);
+ nl->shift.resize(nl->maxnri);
+ nl->jindex.resize(nl->maxnri + 1);
}
/* For load balancing of the free-energy lists over threads, we set
if (nlist->nrj + (cj_ind_end - cj_ind_start) * nbl->na_cj > nlist->maxnrj)
{
nlist->maxnrj = over_alloc_small(nlist->nrj + (cj_ind_end - cj_ind_start) * nbl->na_cj);
- srenew(nlist->jjnr, nlist->maxnrj);
- srenew(nlist->excl_fep, nlist->maxnrj);
+ nlist->jjnr.resize(nlist->maxnrj);
+ nlist->excl_fep.resize(nlist->maxnrj);
}
if (ngid > 1)
if (nrjMax > nlist->maxnrj)
{
nlist->maxnrj = over_alloc_small(nrjMax);
- srenew(nlist->jjnr, nlist->maxnrj);
- srenew(nlist->excl_fep, nlist->maxnrj);
+ nlist->jjnr.resize(nlist->maxnrj);
+ nlist->excl_fep.resize(nlist->maxnrj);
}
for (int cj4_ind = cj4_ind_start; cj4_ind < cj4_ind_end; cj4_ind++)
{
nl->nri = 0;
nl->nrj = 0;
- if (nl->jindex == nullptr)
+ if (nl->jindex.empty())
{
- snew(nl->jindex, 1);
+ nl->jindex.resize(1);
}
nl->jindex[0] = 0;
}
if (nri_tot > nbl->maxnri || nrj_tot > nbl->maxnrj)
{
nbl->maxnrj = over_alloc_small(nrj_tot);
- srenew(nbl->jjnr, nbl->maxnrj);
- srenew(nbl->excl_fep, nbl->maxnrj);
+ nbl->jjnr.resize(nbl->maxnrj);
+ nbl->excl_fep.resize(nbl->maxnrj);
}
clear_pairlist_fep(nbl);
* This file is part of the GROMACS molecular simulation package.
*
* 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.
gmx_cache_protect_t cp1;
};
-//! Initializes a free-energy pair-list
-void nbnxn_init_pairlist_fep(t_nblist* nl);
-
#endif
/*
* This file is part of the GROMACS molecular simulation package.
*
- * 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 "pairsearch.h"
#include "gromacs/mdtypes/nblist.h"
-#include "gromacs/utility/smalloc.h"
#include "pairlist.h"
fprintf(fp, "\n");
}
-/*! \brief Frees the contents of a legacy t_nblist struct */
-static void free_nblist(t_nblist* nl)
-{
- sfree(nl->iinr);
- sfree(nl->gid);
- sfree(nl->shift);
- sfree(nl->jindex);
- sfree(nl->jjnr);
- sfree(nl->excl_fep);
-}
-
#ifndef DOXYGEN
-PairsearchWork::PairsearchWork() : cp0({ { 0 } }), ndistc(0), nbl_fep(new t_nblist), cp1({ { 0 } })
+PairsearchWork::PairsearchWork() :
+ cp0({ { 0 } }),
+ ndistc(0),
+ nbl_fep(std::make_unique<t_nblist>()),
+ cp1({ { 0 } })
{
- nbnxn_init_pairlist_fep(nbl_fep.get());
}
#endif // !DOXYGEN
-PairsearchWork::~PairsearchWork()
-{
- free_nblist(nbl_fep.get());
-}
+PairsearchWork::~PairsearchWork() = default;
PairSearch::PairSearch(const PbcType pbcType,
const bool doTestParticleInsertion,