Changed a flat array to array of 1D BB structs.
Changed a macro to a constexpr.
Change-Id: I75bb6792a3e99dc152450398a90f5414ae79fd8c
{
numClusters_.resize(maxNumCells);
}
- bbcz_.resize(maxNumCells*NNBSBB_D);
+ bbcz_.resize(maxNumCells);
/* This resize also zeros the contents, this avoid possible
* floating exceptions in SIMD with the unused bb elements.
{
cellFilled = cell;
}
- bbcz_[cell*NNBSBB_D ] = bb_[cellFilled].lower.z;
- bbcz_[cell*NNBSBB_D + 1] = bb_[cellFilled].upper.z;
+ bbcz_[cell].lower = bb_[cellFilled].lower.z;
+ bbcz_[cell].upper = bb_[cellFilled].upper.z;
}
/* Set the unused atom indices to -1 */
(numAtoms + geometry_.numAtomsICluster - 1)/ geometry_.numAtomsICluster);
/* Store the z-boundaries of the bounding box of the cell */
- bbcz_[cell*NNBSBB_D ] = x[nbs->a[atomOffsetZ]][ZZ];
- bbcz_[cell*NNBSBB_D+1] = x[nbs->a[atomOffsetZ + numAtoms - 1]][ZZ];
+ bbcz_[cell].lower = x[nbs->a[atomOffsetZ]][ZZ];
+ bbcz_[cell].upper = x[nbs->a[atomOffsetZ + numAtoms - 1]][ZZ];
}
if (c_gpuNumClusterPerCellY > 1)
Corner upper; //!< upper, along x and y and z, corner
};
+/*! \internal
+ * \brief Bounding box for one dimension of a grid cell
+ */
+struct BoundingBox1D
+{
+ float lower; //!< lower bound
+ float upper; //!< upper bound
+};
+
+/*! \brief The number of bounds along one dimension of a bounding box */
+static constexpr int c_numBoundingBoxBounds1D = 2;
#ifndef DOXYGEN
// TODO: Convert macros to constexpr int
-/* Pair search box lower and upper bound in z only. */
-#define NNBSBB_D 2
-
/* Bounding box calculations are (currently) always in single precision, so
* we only need to check for single precision support here.
* This uses less (cache-)memory and SIMD is faster, at least on x86.
/* Store bounding boxes corners as quadruplets: xxxxyyyyzzzz */
# define NBNXN_BBXXXX 1
/* Size of a quadruplet of bounding boxes, each 2 corners, stored packed */
-# define NNBSBB_XXXX (2*DIM*STRIDE_PBB)
+# define NNBSBB_XXXX (STRIDE_PBB*DIM*Nbnxm::c_numBoundingBoxBounds1D)
#else /* NBNXN_SEARCH_BB_SIMD4 */
}
//! Returns the bounding boxes along z for all cells on the grid
- gmx::ArrayRef<const float> zBoundingBoxes() const
+ gmx::ArrayRef<const BoundingBox1D> zBoundingBoxes() const
{
return bbcz_;
}
/* Bounding boxes */
//! Bounding boxes in z for the cells
- std::vector<float> bbcz_;
+ std::vector<BoundingBox1D> bbcz_;
//! 3D bounding boxes for the sub cells
std::vector < BoundingBox, gmx::AlignedAllocator < BoundingBox>> bb_;
//! 3D j-bounding boxes for the case where the i- and j-cluster sizes are different
#include "internal.h"
#include "pairlistwork.h"
-using namespace gmx; // TODO: Remove when this file is moved into gmx namespace
+using namespace gmx; // TODO: Remove when this file is moved into gmx namespace
-using nbnxn_bb_t = Nbnxm::BoundingBox; // TODO: Remove when refactoring this file
+using nbnxn_bb_t = Nbnxm::BoundingBox; // TODO: Remove when refactoring this file
+using BoundingBox1D = Nbnxm::BoundingBox1D; // TODO: Remove when refactoring this file
-using Grid = Nbnxm::Grid; // TODO: Remove when refactoring this file
+using Grid = Nbnxm::Grid; // TODO: Remove when refactoring this file
// Convience alias for partial Nbnxn namespace usage
using InteractionLocality = Nbnxm::InteractionLocality;
Simd4Float d2x, d2y, d2z; \
Simd4Float d2s, d2t; \
\
- shi = (si)*NNBSBB_D*DIM; \
+ shi = (si)*Nbnxm::c_numBoundingBoxBounds1D*DIM; \
\
xi_l = load4((bb_i)+shi+0*STRIDE_PBB); \
yi_l = load4((bb_i)+shi+1*STRIDE_PBB); \
/* We use the normal bounding box format for both grid types */
bb_i = iGrid.iBoundingBoxes();
#endif
- gmx::ArrayRef<const float> bbcz_i = iGrid.zBoundingBoxes();
- gmx::ArrayRef<const int> flags_i = iGrid.clusterFlags();
- gmx::ArrayRef<const float> bbcz_j = jGrid.zBoundingBoxes();
- int cell0_i = iGrid.cellOffset();
+ gmx::ArrayRef<const BoundingBox1D> bbcz_i = iGrid.zBoundingBoxes();
+ gmx::ArrayRef<const int> flags_i = iGrid.clusterFlags();
+ gmx::ArrayRef<const BoundingBox1D> bbcz_j = jGrid.zBoundingBoxes();
+ int cell0_i = iGrid.cellOffset();
if (debug)
{
{
const real shz = tz*box[ZZ][ZZ];
- bz0 = bbcz_i[ci*NNBSBB_D ] + shz;
- bz1 = bbcz_i[ci*NNBSBB_D+1] + shz;
+ bz0 = bbcz_i[ci].lower + shz;
+ bz1 = bbcz_i[ci].upper + shz;
if (tz == 0)
{
*/
int downTestCell = midCell;
while (downTestCell >= columnStart &&
- (bbcz_j[downTestCell*NNBSBB_D + 1] >= bz0 ||
- d2xy + gmx::square(bbcz_j[downTestCell*NNBSBB_D + 1] - bz0) < rlist2))
+ (bbcz_j[downTestCell].upper >= bz0 ||
+ d2xy + gmx::square(bbcz_j[downTestCell].upper - bz0) < rlist2))
{
downTestCell--;
}
*/
int upTestCell = midCell + 1;
while (upTestCell < columnEnd &&
- (bbcz_j[upTestCell*NNBSBB_D] <= bz1 ||
- d2xy + gmx::square(bbcz_j[upTestCell*NNBSBB_D] - bz1) < rlist2))
+ (bbcz_j[upTestCell].lower <= bz1 ||
+ d2xy + gmx::square(bbcz_j[upTestCell].lower - bz1) < rlist2))
{
upTestCell++;
}