Introduce SimulatorBuilder
[gromacs.git] / src / gromacs / nbnxm / pairlistwork.h
blob8716632010d19fa82321800e00cdd62dcd9a6050
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2019, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 /*! \internal \file
38 * \brief Declares working data structures for the CPU and GPU pairlists
40 * \author Berk Hess <hess@kth.se>
42 * \ingroup module_nbnxn
45 #ifndef GMX_NBNXM_PAIRLISTWORK_H
46 #define GMX_NBNXM_PAIRLISTWORK_H
48 #include <memory>
49 #include <vector>
51 #include "gromacs/nbnxm/pairlist.h"
52 #include "gromacs/simd/simd.h"
54 #include "grid.h"
56 /* Working data for the actual i-supercell during pair search */
57 struct NbnxnPairlistCpuWork
59 // Struct for storing coordinats and bounding box for an i-entry during search
60 struct IClusterData
62 IClusterData() :
63 bb(1),
64 x(c_nbnxnCpuIClusterSize*DIM),
65 xSimd(c_nbnxnCpuIClusterSize*DIM*GMX_REAL_MAX_SIMD_WIDTH)
69 // The bounding boxes, pbc shifted, for each cluster
70 AlignedVector<Nbnxm::BoundingBox> bb;
71 // The coordinates, pbc shifted, for each atom
72 std::vector<real> x;
73 // Aligned list for storing 4*DIM*GMX_SIMD_REAL_WIDTH reals
74 AlignedVector<real> xSimd;
77 // Protect data from cache pollution between threads
78 gmx_cache_protect_t cp0;
80 // Work data for generating an IEntry in the pairlist
81 IClusterData iClusterData;
82 // The current cj_ind index for the current list
83 int cj_ind;
84 // Temporary j-cluster list, used for sorting on exclusions
85 std::vector<nbnxn_cj_t> cj;
87 // Nr. of cluster pairs without Coulomb for flop counting
88 int ncj_noq;
89 // Nr. of cluster pairs with 1/2 LJ for flop count
90 int ncj_hlj;
92 // Protect data from cache pollution between threads
93 gmx_cache_protect_t cp1;
96 /* Working data for the actual i-supercell during pair search */
97 struct NbnxnPairlistGpuWork
99 struct ISuperClusterData
101 ISuperClusterData() :
102 bb(c_gpuNumClusterPerCell),
103 #if NBNXN_SEARCH_BB_SIMD4
104 bbPacked(c_gpuNumClusterPerCell/c_packedBoundingBoxesDimSize*c_packedBoundingBoxesSize),
105 #endif
106 x(c_gpuNumClusterPerCell*c_nbnxnGpuClusterSize*DIM),
107 xSimd(c_gpuNumClusterPerCell*c_nbnxnGpuClusterSize*DIM)
111 // The bounding boxes, pbc shifted, for each cluster
112 AlignedVector<Nbnxm::BoundingBox> bb;
113 // As bb, but in packed xxxx format
114 AlignedVector<float> bbPacked;
115 // The coordinates, pbc shifted, for each atom
116 AlignedVector<real> x;
117 // Aligned coordinate list used for 4*DIM*GMX_SIMD_REAL_WIDTH floats
118 AlignedVector<real> xSimd;
121 NbnxnPairlistGpuWork() :
122 distanceBuffer(c_gpuNumClusterPerCell),
123 sci_sort({}, {gmx::PinningPolicy::PinnedIfSupported})
127 // Protect data from cache pollution between threads
128 gmx_cache_protect_t cp0;
130 // Work data for generating an i-entry in the pairlist
131 ISuperClusterData iSuperClusterData;
132 // The current j-cluster index for the current list
133 int cj_ind;
134 // Bounding box distance work array
135 AlignedVector<float> distanceBuffer;
137 // Buffer for sorting list entries
138 std::vector<int> sortBuffer;
140 // Second sci array, for sorting
141 gmx::HostVector<nbnxn_sci_t> sci_sort;
143 // Protect data from cache pollution between threads
144 gmx_cache_protect_t cp1;
147 #endif