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 * Stubs of functions that must be defined by nbnxm sycl implementation.
40 * \ingroup module_nbnxm
44 #include "gromacs/gpu_utils/pmalloc.h"
45 #include "gromacs/hardware/device_information.h"
46 #include "gromacs/mdtypes/interaction_const.h"
47 #include "gromacs/nbnxm/atomdata.h"
48 #include "gromacs/nbnxm/gpu_data_mgmt.h"
49 #include "gromacs/nbnxm/nbnxm_gpu.h"
50 #include "gromacs/nbnxm/nbnxm_gpu_data_mgmt.h"
51 #include "gromacs/pbcutil/ishift.h"
52 #include "gromacs/utility/exceptions.h"
54 #include "nbnxm_sycl_types.h"
59 void gpu_init_platform_specific(NbnxmGpu* /* nb */)
61 // Nothing specific in SYCL
64 void gpu_upload_shiftvec(NbnxmGpu* nb, const nbnxn_atomdata_t* nbatom)
66 NBAtomData* adat = nb->atdat;
67 const DeviceStream& localStream = *nb->deviceStreams[InteractionLocality::Local];
69 /* only if we have a dynamic box */
70 if (nbatom->bDynamicBox || !adat->shiftVecUploaded)
72 GMX_ASSERT(adat->shiftVec.elementSize() == sizeof(nbatom->shift_vec[0]),
73 "Sizes of host- and device-side shift vectors should be the same.");
74 copyToDeviceBuffer(&adat->shiftVec,
75 reinterpret_cast<const Float3*>(nbatom->shift_vec.data()),
79 GpuApiCallBehavior::Async,
81 adat->shiftVecUploaded = true;
85 void gpu_free(NbnxmGpu* nb)
95 NBAtomData* atdat = nb->atdat;
96 NBParamGpu* nbparam = nb->nbparam;
98 if (nbparam->elecType == ElecType::EwaldTab || nbparam->elecType == ElecType::EwaldTabTwin)
100 destroyParamLookupTable(&nbparam->coulomb_tab, nbparam->coulomb_tab_texobj);
103 if (!useLjCombRule(nb->nbparam->vdwType))
105 destroyParamLookupTable(&nbparam->nbfp, nbparam->nbfp_texobj);
108 if (nbparam->vdwType == VdwType::EwaldGeom || nbparam->vdwType == VdwType::EwaldLB)
110 destroyParamLookupTable(&nbparam->nbfp_comb, nbparam->nbfp_comb_texobj);
114 auto* plist = nb->plist[InteractionLocality::Local];
116 if (nb->bUseTwoStreams)
118 auto* plist_nl = nb->plist[InteractionLocality::NonLocal];
124 nb->nbst.eLJ = nullptr;
126 pfree(nb->nbst.eElec);
127 nb->nbst.eElec = nullptr;
129 pfree(nb->nbst.fShift);
130 nb->nbst.fShift = nullptr;
137 int gpu_min_ci_balanced(NbnxmGpu* nb)
139 // SYCL-TODO: Logic and magic values taken from OpenCL
140 static constexpr unsigned int balancedFactor = 50;
145 const cl::sycl::device device = nb->deviceContext_->deviceInfo().syclDevice;
146 const int numComputeUnits = device.get_info<cl::sycl::info::device::max_compute_units>();
147 return balancedFactor * numComputeUnits;