2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2020,2021, 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.
38 * Data types used internally in the nbnxm_sycl module.
40 * \ingroup module_nbnxm
43 #ifndef NBNXM_SYCL_TYPES_H
44 #define NBNXM_SYCL_TYPES_H
46 #include "gromacs/gpu_utils/devicebuffer.h"
47 #include "gromacs/gpu_utils/devicebuffer_sycl.h"
48 #include "gromacs/gpu_utils/gmxsycl.h"
49 #include "gromacs/gpu_utils/gpueventsynchronizer.h"
50 #include "gromacs/gpu_utils/gputraits.h"
51 #include "gromacs/gpu_utils/syclutils.h"
52 #include "gromacs/nbnxm/gpu_types_common.h"
53 #include "gromacs/nbnxm/nbnxm.h"
54 #include "gromacs/nbnxm/pairlist.h"
55 #include "gromacs/timing/gpu_timing.h"
56 #include "gromacs/utility/enumerationhelpers.h"
58 class GpuEventSynchronizer;
61 * \brief Main data structure for SYCL nonbonded force calculations.
65 /*! \brief GPU device context.
67 * \todo Make it constant reference, once NbnxmGpu is a proper class.
69 const DeviceContext* deviceContext_;
70 /*! \brief true if doing both local/non-local NB work on GPU */
71 bool bUseTwoStreams = false;
72 /*! \brief true indicates that the nonlocal_done event was marked */
73 bool bNonLocalStreamDoneMarked = false;
74 /*! \brief atom data */
75 NBAtomDataGpu* atdat = nullptr;
77 // Data for GPU-side coordinate conversion between integrator and NBNXM
78 /*! \brief array of atom indices */
79 DeviceBuffer<int> atomIndices;
80 /*! \brief size of atom indices */
81 int atomIndicesSize = 0;
82 /*! \brief size of atom indices allocated in device buffer */
83 int atomIndicesSize_alloc = 0;
84 /*! \brief x buf ops num of atoms */
85 DeviceBuffer<int> cxy_na;
86 /*! \brief number of elements in cxy_na */
88 /*! \brief number of elements allocated allocated in device buffer */
89 int ncxy_na_alloc = 0;
90 /*! \brief x buf ops cell index mapping */
91 DeviceBuffer<int> cxy_ind;
92 /*! \brief number of elements in cxy_ind */
94 /*! \brief number of elements allocated allocated in device buffer */
95 int ncxy_ind_alloc = 0;
97 NBParamGpu* nbparam = nullptr;
98 /*! \brief pair-list data structures (local and non-local) */
99 gmx::EnumerationArray<Nbnxm::InteractionLocality, Nbnxm::gpu_plist*> plist = { { nullptr } };
100 /*! \brief staging area where fshift/energies get downloaded. Will be removed in SYCL. */
102 /*! \brief local and non-local GPU streams */
103 gmx::EnumerationArray<Nbnxm::InteractionLocality, const DeviceStream*> deviceStreams;
105 /*! \brief True if event-based timing is enabled. Always false for SYCL. */
106 bool bDoTime = false;
107 /*! \brief Dummy timers. */
108 Nbnxm::GpuTimers* timers = nullptr;
109 /*! \brief Dummy timing data. */
110 gmx_wallclock_gpu_nbnxn_t* timings = nullptr;
112 //! true when a pair-list transfer has been done at this step
113 gmx::EnumerationArray<Nbnxm::InteractionLocality, bool> didPairlistH2D = { { false } };
114 //! true when we we did pruning on this step
115 gmx::EnumerationArray<Nbnxm::InteractionLocality, bool> didPrune = { { false } };
116 //! true when we did rolling pruning (at the previous step)
117 gmx::EnumerationArray<Nbnxm::InteractionLocality, bool> didRollingPrune = { { false } };
119 /*! \brief Event triggered when the non-local non-bonded
120 * kernel is done (and the local transfer can proceed) */
121 GpuEventSynchronizer nonlocal_done;
122 /*! \brief Event triggered when the tasks issued in the local
123 * stream that need to precede the non-local force or buffer
124 * operation calculations are done (e.g. f buffer 0-ing, local
125 * x/q H2D, buffer op initialization in local stream that is
126 * required also by nonlocal stream ) */
127 GpuEventSynchronizer misc_ops_and_local_H2D_done;
129 /*! \brief True if there is work for the current domain in the
130 * respective locality.
132 * This includes local/nonlocal GPU work, either bonded or
133 * nonbonded, scheduled to be executed in the current
134 * domain. As long as bonded work is not split up into
135 * local/nonlocal, if there is bonded GPU work, both flags
137 gmx::EnumerationArray<Nbnxm::InteractionLocality, bool> haveWork = { { false } };
139 /*! \brief Pointer to event synchronizer triggered when the local
140 * GPU buffer ops / reduction is complete. Would be deprecated in SYCL.
142 * \note That the synchronizer is managed outside of this module
143 * in StatePropagatorDataGpu.
145 GpuEventSynchronizer* localFReductionDone = nullptr;
148 #endif /* NBNXM_SYCL_TYPES_H */