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/nbnxm/gpu_types_common.h"
52 #include "gromacs/nbnxm/nbnxm.h"
53 #include "gromacs/nbnxm/pairlist.h"
54 #include "gromacs/timing/gpu_timing.h"
55 #include "gromacs/utility/enumerationhelpers.h"
57 class GpuEventSynchronizer;
60 * \brief Main data structure for SYCL nonbonded force calculations.
64 /*! \brief GPU device context.
66 * \todo Make it constant reference, once NbnxmGpu is a proper class.
68 const DeviceContext* deviceContext_;
69 /*! \brief true if doing both local/non-local NB work on GPU */
70 bool bUseTwoStreams = false;
71 /*! \brief true indicates that the nonlocal_done event was marked */
72 bool bNonLocalStreamDoneMarked = false;
73 /*! \brief atom data */
74 NBAtomDataGpu* atdat = nullptr;
76 // Data for GPU-side coordinate conversion between integrator and NBNXM
77 /*! \brief array of atom indices */
78 DeviceBuffer<int> atomIndices;
79 /*! \brief size of atom indices */
80 int atomIndicesSize = 0;
81 /*! \brief size of atom indices allocated in device buffer */
82 int atomIndicesSize_alloc = 0;
83 /*! \brief x buf ops num of atoms */
84 DeviceBuffer<int> cxy_na;
85 /*! \brief number of elements in cxy_na */
87 /*! \brief number of elements allocated allocated in device buffer */
88 int ncxy_na_alloc = 0;
89 /*! \brief x buf ops cell index mapping */
90 DeviceBuffer<int> cxy_ind;
91 /*! \brief number of elements in cxy_ind */
93 /*! \brief number of elements allocated allocated in device buffer */
94 int ncxy_ind_alloc = 0;
96 NBParamGpu* nbparam = nullptr;
97 /*! \brief pair-list data structures (local and non-local) */
98 gmx::EnumerationArray<Nbnxm::InteractionLocality, Nbnxm::gpu_plist*> plist = { { nullptr } };
99 /*! \brief staging area where fshift/energies get downloaded. Will be removed in SYCL. */
101 /*! \brief local and non-local GPU streams */
102 gmx::EnumerationArray<Nbnxm::InteractionLocality, const DeviceStream*> deviceStreams;
104 /*! \brief True if event-based timing is enabled. Always false for SYCL. */
105 bool bDoTime = false;
106 /*! \brief Dummy timers. */
107 Nbnxm::GpuTimers* timers = nullptr;
108 /*! \brief Dummy timing data. */
109 gmx_wallclock_gpu_nbnxn_t* timings = nullptr;
111 //! true when a pair-list transfer has been done at this step
112 gmx::EnumerationArray<Nbnxm::InteractionLocality, bool> didPairlistH2D = { { false } };
113 //! true when we we did pruning on this step
114 gmx::EnumerationArray<Nbnxm::InteractionLocality, bool> didPrune = { { false } };
115 //! true when we did rolling pruning (at the previous step)
116 gmx::EnumerationArray<Nbnxm::InteractionLocality, bool> didRollingPrune = { { false } };
118 /*! \brief Event triggered when the non-local non-bonded
119 * kernel is done (and the local transfer can proceed) */
120 GpuEventSynchronizer nonlocal_done;
121 /*! \brief Event triggered when the tasks issued in the local
122 * stream that need to precede the non-local force or buffer
123 * operation calculations are done (e.g. f buffer 0-ing, local
124 * x/q H2D, buffer op initialization in local stream that is
125 * required also by nonlocal stream ) */
126 GpuEventSynchronizer misc_ops_and_local_H2D_done;
128 /*! \brief True if there is work for the current domain in the
129 * respective locality.
131 * This includes local/nonlocal GPU work, either bonded or
132 * nonbonded, scheduled to be executed in the current
133 * domain. As long as bonded work is not split up into
134 * local/nonlocal, if there is bonded GPU work, both flags
136 gmx::EnumerationArray<Nbnxm::InteractionLocality, bool> haveWork = { { false } };
138 /*! \brief Pointer to event synchronizer triggered when the local
139 * GPU buffer ops / reduction is complete. Would be deprecated in SYCL.
141 * \note That the synchronizer is managed outside of this module
142 * in StatePropagatorDataGpu.
144 GpuEventSynchronizer* localFReductionDone = nullptr;
147 #endif /* NBNXM_SYCL_TYPES_H */