From 4048a70e28546601469d1daa1aa51f30009f1fee Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Thu, 15 Aug 2019 14:49:30 +0200 Subject: [PATCH] Stop nbnxm/grid.h depending on SIMD module Only part of the NBNXM module has a SIMD dependence, and this reduces the size of it. Change-Id: I1376e9f1b30b436453582bdabc65efd185a66b33 --- docs/doxygen/suppressions.txt | 2 +- src/gromacs/nbnxm/boundingboxes.h | 110 ++++++++++++++++++++++++++++++ src/gromacs/nbnxm/grid.cpp | 1 + src/gromacs/nbnxm/grid.h | 57 ---------------- src/gromacs/nbnxm/pairlist.cpp | 1 + src/gromacs/nbnxm/pairlistwork.h | 1 + 6 files changed, 114 insertions(+), 58 deletions(-) create mode 100644 src/gromacs/nbnxm/boundingboxes.h diff --git a/docs/doxygen/suppressions.txt b/docs/doxygen/suppressions.txt index b055948a41..ed336d10c8 100644 --- a/docs/doxygen/suppressions.txt +++ b/docs/doxygen/suppressions.txt @@ -19,7 +19,7 @@ src/gromacs/ewald/pme_simd4.h: warning: should include "pme_simd.h" src/gromacs/ewald/pme_spline_work.cpp: warning: includes "simd.h" unnecessarily src/gromacs/ewald/pme_spline_work.h: warning: includes "simd.h" unnecessarily src/gromacs/ewald/pme_spread.cpp: warning: includes "simd.h" unnecessarily -src/gromacs/nbnxm/grid.h: warning: includes "simd.h" unnecessarily +src/gromacs/nbnxm/boundingboxes.h: warning: includes "simd.h" unnecessarily src/gromacs/nbnxm/kernels_simd_2xmm/kernel_inner.h: warning: should include "simd.h" src/gromacs/nbnxm/kernels_simd_2xmm/kernel_outer.h: warning: should include "simd.h" src/gromacs/nbnxm/kernels_simd_4xm/kernel_inner.h: warning: should include "simd.h" diff --git a/src/gromacs/nbnxm/boundingboxes.h b/src/gromacs/nbnxm/boundingboxes.h new file mode 100644 index 0000000000..6ebba22700 --- /dev/null +++ b/src/gromacs/nbnxm/boundingboxes.h @@ -0,0 +1,110 @@ +/* + * 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 constants and helper functions used when handling + * bounding boxes for clusters of particles. + * + * \author Berk Hess + * \ingroup module_nbnxm + */ + +#ifndef GMX_NBNXM_BOUNDINGBOXES_H +#define GMX_NBNXM_BOUNDINGBOXES_H + +#include "gromacs/simd/simd.h" + +namespace Nbnxm +{ + +/*! \brief The number of bounds along one dimension of a bounding box */ +static constexpr int c_numBoundingBoxBounds1D = 2; + +} // namespace Nbnxm + +#ifndef DOXYGEN + +/* 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. + */ +#if GMX_SIMD4_HAVE_FLOAT +# define NBNXN_SEARCH_BB_SIMD4 1 +#else +# define NBNXN_SEARCH_BB_SIMD4 0 +#endif + + +#if NBNXN_SEARCH_BB_SIMD4 +/* Always use 4-wide SIMD for bounding box calculations */ + +# if !GMX_DOUBLE +/* Single precision BBs + coordinates, we can also load coordinates with SIMD */ +# define NBNXN_SEARCH_SIMD4_FLOAT_X_BB 1 +# else +# define NBNXN_SEARCH_SIMD4_FLOAT_X_BB 0 +# endif + +/* Store bounding boxes corners as quadruplets: xxxxyyyyzzzz + * + * The packed bounding box coordinate stride is always set to 4. + * With AVX we could use 8, but that turns out not to be faster. + */ +# define NBNXN_BBXXXX 1 + +//! The number of bounding boxes in a pack, also the size of a pack along one dimension +static constexpr int c_packedBoundingBoxesDimSize = GMX_SIMD4_WIDTH; + +//! Total number of corners (floats) in a pack of bounding boxes +static constexpr int c_packedBoundingBoxesSize = + c_packedBoundingBoxesDimSize*DIM*Nbnxm::c_numBoundingBoxBounds1D; + +//! Returns the starting index of the bounding box pack that contains the given cluster +static constexpr inline int packedBoundingBoxesIndex(int clusterIndex) +{ + return (clusterIndex/c_packedBoundingBoxesDimSize)*c_packedBoundingBoxesSize; +} + +#else /* NBNXN_SEARCH_BB_SIMD4 */ + +# define NBNXN_SEARCH_SIMD4_FLOAT_X_BB 0 +# define NBNXN_BBXXXX 0 + +#endif /* NBNXN_SEARCH_BB_SIMD4 */ + +#endif // !DOXYGEN + +#endif diff --git a/src/gromacs/nbnxm/grid.cpp b/src/gromacs/nbnxm/grid.cpp index c69a9e8ac4..a20cf1249e 100644 --- a/src/gromacs/nbnxm/grid.cpp +++ b/src/gromacs/nbnxm/grid.cpp @@ -61,6 +61,7 @@ #include "gromacs/simd/simd.h" #include "gromacs/simd/vector_operations.h" +#include "boundingboxes.h" #include "gridsetdata.h" #include "pairlistparams.h" diff --git a/src/gromacs/nbnxm/grid.h b/src/gromacs/nbnxm/grid.h index a57d3ad684..5387b8c271 100644 --- a/src/gromacs/nbnxm/grid.h +++ b/src/gromacs/nbnxm/grid.h @@ -58,11 +58,9 @@ #include "gromacs/gpu_utils/hostallocator.h" #include "gromacs/math/vectypes.h" -#include "gromacs/simd/simd.h" #include "gromacs/utility/alignedallocator.h" #include "gromacs/utility/arrayref.h" - struct gmx_domdec_zones_t; struct nbnxn_atomdata_t; struct nbnxn_search; @@ -153,63 +151,8 @@ struct BoundingBox1D float upper; //!< upper bound }; -/*! \brief The number of bounds along one dimension of a bounding box */ -static constexpr int c_numBoundingBoxBounds1D = 2; - } // namespace Nbnxm -#ifndef DOXYGEN - -/* 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. - */ -#if GMX_SIMD4_HAVE_FLOAT -# define NBNXN_SEARCH_BB_SIMD4 1 -#else -# define NBNXN_SEARCH_BB_SIMD4 0 -#endif - - -#if NBNXN_SEARCH_BB_SIMD4 -/* Always use 4-wide SIMD for bounding box calculations */ - -# if !GMX_DOUBLE -/* Single precision BBs + coordinates, we can also load coordinates with SIMD */ -# define NBNXN_SEARCH_SIMD4_FLOAT_X_BB 1 -# else -# define NBNXN_SEARCH_SIMD4_FLOAT_X_BB 0 -# endif - -/* Store bounding boxes corners as quadruplets: xxxxyyyyzzzz - * - * The packed bounding box coordinate stride is always set to 4. - * With AVX we could use 8, but that turns out not to be faster. - */ -# define NBNXN_BBXXXX 1 - -//! The number of bounding boxes in a pack, also the size of a pack along one dimension -static constexpr int c_packedBoundingBoxesDimSize = GMX_SIMD4_WIDTH; - -//! Total number of corners (floats) in a pack of bounding boxes -static constexpr int c_packedBoundingBoxesSize = - c_packedBoundingBoxesDimSize*DIM*Nbnxm::c_numBoundingBoxBounds1D; - -//! Returns the starting index of the bouding box pack that contains the given cluster -static constexpr inline int packedBoundingBoxesIndex(int clusterIndex) -{ - return (clusterIndex/c_packedBoundingBoxesDimSize)*c_packedBoundingBoxesSize; -} - -#else /* NBNXN_SEARCH_BB_SIMD4 */ - -# define NBNXN_SEARCH_SIMD4_FLOAT_X_BB 0 -# define NBNXN_BBXXXX 0 - -#endif /* NBNXN_SEARCH_BB_SIMD4 */ - -#endif // !DOXYGEN - namespace Nbnxm { diff --git a/src/gromacs/nbnxm/pairlist.cpp b/src/gromacs/nbnxm/pairlist.cpp index de0a081d51..6059f15766 100644 --- a/src/gromacs/nbnxm/pairlist.cpp +++ b/src/gromacs/nbnxm/pairlist.cpp @@ -67,6 +67,7 @@ #include "gromacs/utility/gmxomp.h" #include "gromacs/utility/smalloc.h" +#include "boundingboxes.h" #include "clusterdistancekerneltype.h" #include "gridset.h" #include "pairlistset.h" diff --git a/src/gromacs/nbnxm/pairlistwork.h b/src/gromacs/nbnxm/pairlistwork.h index 8716632010..77dc96e7c1 100644 --- a/src/gromacs/nbnxm/pairlistwork.h +++ b/src/gromacs/nbnxm/pairlistwork.h @@ -51,6 +51,7 @@ #include "gromacs/nbnxm/pairlist.h" #include "gromacs/simd/simd.h" +#include "boundingboxes.h" #include "grid.h" /* Working data for the actual i-supercell during pair search */ -- 2.22.0