namespace Nbnxm
{
-//! Returns the number of DD zones or 1 when \p numDDCells = nullptr
-static int numDDZones(const ivec *numDDCells)
+//! Returns the number of DD zones
+static int numDDZones(const std::array<bool, DIM> &haveDomDecPerDim)
{
int numDDZones = 1;
- bool haveDomDec = (numDDCells != nullptr);
- if (haveDomDec)
+ for (auto haveDD : haveDomDecPerDim)
{
- for (int d = 0; d < DIM; d++)
+ if (haveDD)
{
- if ((*numDDCells)[d] > 1)
- {
- numDDZones *= 2;
- }
+ numDDZones *= 2;
}
}
return numDDZones;
}
-GridSet::GridSet(const ivec *numDDCells,
- const PairlistType pairlistType,
- const bool haveFep,
- const int numThreads) :
- grids_(numDDZones(numDDCells), pairlistType),
+GridSet::GridSet(const std::array<bool, DIM> &haveDomDecPerDim,
+ const PairlistType pairlistType,
+ const bool haveFep,
+ const int numThreads) :
+ grids_(numDDZones(haveDomDecPerDim), pairlistType),
haveFep_(haveFep),
numRealAtomsLocal_(0),
numRealAtomsTotal_(0),
/* Main pair-search struct, contains the grid(s), not the pair-list(s) */
struct nbnxn_search
{
+ /*! \internal
+ * \brief Description of the domain setup: PBC and the connections between domains
+ */
+ struct DomainSetup
+ {
+ //! Constructor, without DD \p numDDCells and \p ddZones should be nullptr
+ DomainSetup(int ePBC,
+ const ivec *numDDCells,
+ const gmx_domdec_zones_t *ddZones);
+
+ //! The type of PBC
+ int ePBC;
+ //! Tells whether we are using domain decomposition
+ bool haveDomDec;
+ //! Tells whether we are using domain decomposition per dimension
+ std::array<bool, DIM> haveDomDecPerDim;
+ //! The domain decomposition zone setup
+ const gmx_domdec_zones_t *zones;
+ };
+
/* \brief Constructor
*
* \param[in] ePBC The periodic boundary conditions
- * \param[in] n_dd_cells The number of domain decomposition cells per dimension, without DD nullptr should be passed
+ * \param[in] numDDCells The number of domain decomposition cells per dimension, without DD nullptr should be passed
* \param[in] zones The domain decomposition zone setup, without DD nullptr should be passed
* \param[in] haveFep Tells whether non-bonded interactions are perturbed
* \param[in] maxNumThreads The maximum number of threads used in the search
*/
nbnxn_search(int ePBC,
- const ivec *n_dd_cells,
+ const ivec *numDDCells,
const gmx_domdec_zones_t *zones,
PairlistType pairlistType,
bool haveFep,
int maxNumthreads);
+ const DomainSetup &domainSetup() const
+ {
+ return domainSetup_;
+ }
+
const Nbnxm::GridSet &gridSet() const
{
return gridSet_;
}
- int ePBC; /* PBC type enum */
- gmx_bool DomDec; /* Are we doing domain decomposition? */
- ivec dd_dim; /* Are we doing DD in x,y,z? */
- const gmx_domdec_zones_t *zones; /* The domain decomposition zones */
+ //! The domain setup
+ DomainSetup domainSetup_;
//! The local and non-local grids
Nbnxm::GridSet gridSet_;
free_nblist(nbl_fep.get());
}
+nbnxn_search::DomainSetup::DomainSetup(const int ePBC,
+ const ivec *numDDCells,
+ const gmx_domdec_zones_t *ddZones) :
+ ePBC(ePBC),
+ haveDomDec(numDDCells != nullptr),
+ zones(ddZones)
+{
+ for (int d = 0; d < DIM; d++)
+ {
+ haveDomDecPerDim[d] = (numDDCells != nullptr && (*numDDCells)[d] > 1);
+ }
+}
+
nbnxn_search::nbnxn_search(const int ePBC,
- const ivec *n_dd_cells,
- const gmx_domdec_zones_t *zones,
+ const ivec *numDDCells,
+ const gmx_domdec_zones_t *ddZones,
const PairlistType pairlistType,
const bool haveFep,
const int maxNumThreads) :
- ePBC(ePBC),
- zones(zones),
- gridSet_(n_dd_cells, pairlistType, haveFep, maxNumThreads),
+ domainSetup_(ePBC, numDDCells, ddZones),
+ gridSet_(domainSetup_.haveDomDecPerDim, pairlistType, haveFep, maxNumThreads),
search_count(0),
work(maxNumThreads)
{
- clear_ivec(dd_dim);
- DomDec = n_dd_cells != nullptr;
- if (DomDec)
- {
- for (int d = 0; d < DIM; d++)
- {
- if ((*n_dd_cells)[d] > 1)
- {
- dd_dim[d] = 1;
- }
- }
- }
-
- /* Initialize detailed nbsearch cycle counting */
print_cycles = (getenv("GMX_NBNXN_CYCLE") != nullptr);
nbs_cycle_clear(cc);
}
/* The formulas below are a heuristic estimate of the average nsj per si*/
r_eff_sup = rlist + nbnxn_get_rlist_effective_inc(numAtomsCluster, ls);
- if (!nbs->DomDec || nbs->zones->n == 1)
+ if (!nbs->domainSetup().haveDomDec || nbs->domainSetup().zones->n == 1)
{
nsp_est_nl = 0;
}
{
nsp_est_nl =
gmx::square(dims.atomDensity/numAtomsCluster)*
- nonlocal_vol2(nbs->zones, ls, r_eff_sup);
+ nonlocal_vol2(nbs->domainSetup().zones, ls, r_eff_sup);
}
if (iloc == InteractionLocality::Local)
/* Check if we need periodicity shifts.
* Without PBC or with domain decomposition we don't need them.
*/
- if (d >= ePBC2npbcdim(nbs->ePBC) || nbs->dd_dim[d])
+ if (d >= ePBC2npbcdim(nbs->domainSetup().ePBC) ||
+ nbs->domainSetup().haveDomDecPerDim[d])
{
shp[d] = 0;
}
}
else
{
- nzi = nbs->zones->nizone;
+ nzi = nbs->domainSetup().zones->nizone;
}
if (!nbl_list->bSimple && minimumIlistCountForGpuBalancing_ > 0)
}
}
+ const gmx_domdec_zones_t *ddZones = nbs->domainSetup().zones;
+
for (int zi = 0; zi < nzi; zi++)
{
const Grid &iGrid = nbs->gridSet().grids()[zi];
}
else
{
- zj0 = nbs->zones->izone[zi].j0;
- zj1 = nbs->zones->izone[zi].j1;
+ zj0 = ddZones->izone[zi].j0;
+ zj1 = ddZones->izone[zi].j1;
if (zi == 0)
{
zj0++;
nbs_cycle_start(&nbs->cc[enbsCCsearch]);
- ci_block = get_ci_block_size(iGrid, nbs->DomDec, nnbl);
+ ci_block = get_ci_block_size(iGrid, nbs->domainSetup().haveDomDec, nnbl);
/* With GPU: generate progressively smaller lists for
* load balancing for local only or non-local with 2 zones.
*/
- progBal = (iLocality == InteractionLocality::Local || nbs->zones->n <= 2);
+ progBal = (iLocality == InteractionLocality::Local || ddZones->n <= 2);
#pragma omp parallel for num_threads(nnbl) schedule(static)
for (int th = 0; th < nnbl; th++)
nbs->search_count++;
}
if (nbs->print_cycles &&
- (!nbs->DomDec || iLocality == InteractionLocality::NonLocal) &&
+ (!nbs->domainSetup().haveDomDec || iLocality == InteractionLocality::NonLocal) &&
nbs->search_count % 100 == 0)
{
nbs_cycle_print(stderr, nbs);