2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2018,2019,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.
37 * \brief Implements CUDA bonded functionality
39 * \author Jon Vincent <jvincent@nvidia.com>
40 * \author Magnus Lundborg <lundborg.magnus@gmail.com>
41 * \author Berk Hess <hess@kth.se>
42 * \author Szilárd Páll <pall.szilard@gmail.com>
43 * \author Alan Gray <alang@nvidia.com>
44 * \author Mark Abraham <mark.j.abraham@gmail.com>
46 * \ingroup module_listed_forces
53 #include <math_constants.h>
55 #include "gromacs/gpu_utils/cudautils.cuh"
56 #include "gromacs/gpu_utils/typecasts.cuh"
57 #include "gromacs/gpu_utils/vectype_ops.cuh"
58 #include "gromacs/listed_forces/gpubonded.h"
59 #include "gromacs/math/units.h"
60 #include "gromacs/mdlib/force_flags.h"
61 #include "gromacs/mdtypes/interaction_const.h"
62 #include "gromacs/mdtypes/simulation_workload.h"
63 #include "gromacs/pbcutil/pbc_aiuc_cuda.cuh"
64 #include "gromacs/timing/wallcycle.h"
65 #include "gromacs/utility/gmxassert.h"
67 #include "gpubonded_impl.h"
73 /*-------------------------------- CUDA kernels-------------------------------- */
74 /*------------------------------------------------------------------------------*/
76 #define CUDA_DEG2RAD_F (CUDART_PI_F / 180.0f)
78 /*---------------- BONDED CUDA kernels--------------*/
81 __device__ __forceinline__ static void
82 harmonic_gpu(const float kA, const float xA, const float x, float* V, float* F)
84 constexpr float half = 0.5f;
94 template<bool calcVir, bool calcEner>
95 __device__ void bonds_gpu(const int i,
98 const t_iatom d_forceatoms[],
99 const t_iparams d_forceparams[],
100 const float4 gm_xq[],
102 float3 sm_fShiftLoc[],
103 const PbcAiuc pbcAiuc)
107 int3 bondData = *(int3*)(d_forceatoms + 3 * i);
108 int type = bondData.x;
112 /* dx = xi - xj, corrected for periodic boundary conditions. */
114 int ki = pbcDxAiuc<calcVir>(pbcAiuc, gm_xq[ai], gm_xq[aj], dx);
116 float dr2 = norm2(dx);
117 float dr = sqrt(dr2);
121 harmonic_gpu(d_forceparams[type].harmonic.krA, d_forceparams[type].harmonic.rA, dr, &vbond, &fbond);
130 fbond *= rsqrtf(dr2);
132 float3 fij = fbond * dx;
133 atomicAdd(&gm_f[ai], fij);
134 atomicAdd(&gm_f[aj], -fij);
135 if (calcVir && ki != CENTRAL)
137 atomicAdd(&sm_fShiftLoc[ki], fij);
138 atomicAdd(&sm_fShiftLoc[CENTRAL], -fij);
144 template<bool returnShift>
145 __device__ __forceinline__ static float bond_angle_gpu(const float4 xi,
148 const PbcAiuc& pbcAiuc,
154 /* Return value is the angle between the bonds i-j and j-k */
156 *t1 = pbcDxAiuc<returnShift>(pbcAiuc, xi, xj, *r_ij);
157 *t2 = pbcDxAiuc<returnShift>(pbcAiuc, xk, xj, *r_kj);
159 *costh = cos_angle(*r_ij, *r_kj);
160 float th = acosf(*costh);
165 template<bool calcVir, bool calcEner>
166 __device__ void angles_gpu(const int i,
169 const t_iatom d_forceatoms[],
170 const t_iparams d_forceparams[],
171 const float4 gm_xq[],
173 float3 sm_fShiftLoc[],
174 const PbcAiuc pbcAiuc)
178 int4 angleData = *(int4*)(d_forceatoms + 4 * i);
179 int type = angleData.x;
180 int ai = angleData.y;
181 int aj = angleData.z;
182 int ak = angleData.w;
189 float theta = bond_angle_gpu<calcVir>(
190 gm_xq[ai], gm_xq[aj], gm_xq[ak], pbcAiuc, &r_ij, &r_kj, &cos_theta, &t1, &t2);
194 harmonic_gpu(d_forceparams[type].harmonic.krA,
195 d_forceparams[type].harmonic.rA * CUDA_DEG2RAD_F,
205 float cos_theta2 = cos_theta * cos_theta;
206 if (cos_theta2 < 1.0f)
208 float st = dVdt * rsqrtf(1.0f - cos_theta2);
209 float sth = st * cos_theta;
210 float nrij2 = norm2(r_ij);
211 float nrkj2 = norm2(r_kj);
213 float nrij_1 = rsqrtf(nrij2);
214 float nrkj_1 = rsqrtf(nrkj2);
216 float cik = st * nrij_1 * nrkj_1;
217 float cii = sth * nrij_1 * nrij_1;
218 float ckk = sth * nrkj_1 * nrkj_1;
220 float3 f_i = cii * r_ij - cik * r_kj;
221 float3 f_k = ckk * r_kj - cik * r_ij;
222 float3 f_j = -f_i - f_k;
224 atomicAdd(&gm_f[ai], f_i);
225 atomicAdd(&gm_f[aj], f_j);
226 atomicAdd(&gm_f[ak], f_k);
230 atomicAdd(&sm_fShiftLoc[t1], f_i);
231 atomicAdd(&sm_fShiftLoc[CENTRAL], f_j);
232 atomicAdd(&sm_fShiftLoc[t2], f_k);
238 template<bool calcVir, bool calcEner>
239 __device__ void urey_bradley_gpu(const int i,
242 const t_iatom d_forceatoms[],
243 const t_iparams d_forceparams[],
244 const float4 gm_xq[],
246 float3 sm_fShiftLoc[],
247 const PbcAiuc pbcAiuc)
251 int4 ubData = *(int4*)(d_forceatoms + 4 * i);
257 float th0A = d_forceparams[type].u_b.thetaA * CUDA_DEG2RAD_F;
258 float kthA = d_forceparams[type].u_b.kthetaA;
259 float r13A = d_forceparams[type].u_b.r13A;
260 float kUBA = d_forceparams[type].u_b.kUBA;
267 float theta = bond_angle_gpu<calcVir>(
268 gm_xq[ai], gm_xq[aj], gm_xq[ak], pbcAiuc, &r_ij, &r_kj, &cos_theta, &t1, &t2);
272 harmonic_gpu(kthA, th0A, theta, &va, &dVdt);
280 int ki = pbcDxAiuc<calcVir>(pbcAiuc, gm_xq[ai], gm_xq[ak], r_ik);
282 float dr2 = norm2(r_ik);
283 float dr = dr2 * rsqrtf(dr2);
287 harmonic_gpu(kUBA, r13A, dr, &vbond, &fbond);
289 float cos_theta2 = cos_theta * cos_theta;
290 if (cos_theta2 < 1.0f)
292 float st = dVdt * rsqrtf(1.0f - cos_theta2);
293 float sth = st * cos_theta;
295 float nrkj2 = norm2(r_kj);
296 float nrij2 = norm2(r_ij);
298 float cik = st * rsqrtf(nrkj2 * nrij2);
299 float cii = sth / nrij2;
300 float ckk = sth / nrkj2;
302 float3 f_i = cii * r_ij - cik * r_kj;
303 float3 f_k = ckk * r_kj - cik * r_ij;
304 float3 f_j = -f_i - f_k;
306 atomicAdd(&gm_f[ai], f_i);
307 atomicAdd(&gm_f[aj], f_j);
308 atomicAdd(&gm_f[ak], f_k);
312 atomicAdd(&sm_fShiftLoc[t1], f_i);
313 atomicAdd(&sm_fShiftLoc[CENTRAL], f_j);
314 atomicAdd(&sm_fShiftLoc[t2], f_k);
318 /* Time for the bond calculations */
326 fbond *= rsqrtf(dr2);
328 float3 fik = fbond * r_ik;
329 atomicAdd(&gm_f[ai], fik);
330 atomicAdd(&gm_f[ak], -fik);
332 if (calcVir && ki != CENTRAL)
334 atomicAdd(&sm_fShiftLoc[ki], fik);
335 atomicAdd(&sm_fShiftLoc[CENTRAL], -fik);
341 template<bool returnShift, typename T>
342 __device__ __forceinline__ static float dih_angle_gpu(const T xi,
346 const PbcAiuc& pbcAiuc,
356 *t1 = pbcDxAiuc<returnShift>(pbcAiuc, xi, xj, *r_ij);
357 *t2 = pbcDxAiuc<returnShift>(pbcAiuc, xk, xj, *r_kj);
358 *t3 = pbcDxAiuc<returnShift>(pbcAiuc, xk, xl, *r_kl);
360 *m = cprod(*r_ij, *r_kj);
361 *n = cprod(*r_kj, *r_kl);
362 float phi = gmx_angle(*m, *n);
363 float ipr = iprod(*r_ij, *n);
364 float sign = (ipr < 0.0f) ? -1.0f : 1.0f;
371 __device__ __forceinline__ static void
372 dopdihs_gpu(const float cpA, const float phiA, const int mult, const float phi, float* v, float* f)
376 mdphi = mult * phi - phiA * CUDA_DEG2RAD_F;
378 *v = cpA * (1.0f + cosf(mdphi));
379 *f = -cpA * mult * sdphi;
382 template<bool calcVir>
383 __device__ static void do_dih_fup_gpu(const int i,
394 float3 sm_fShiftLoc[],
395 const PbcAiuc& pbcAiuc,
396 const float4 gm_xq[],
399 const int gmx_unused t3)
401 float iprm = norm2(m);
402 float iprn = norm2(n);
403 float nrkj2 = norm2(r_kj);
404 float toler = nrkj2 * GMX_REAL_EPS;
405 if ((iprm > toler) && (iprn > toler))
407 float nrkj_1 = rsqrtf(nrkj2); // replacing std::invsqrt call
408 float nrkj_2 = nrkj_1 * nrkj_1;
409 float nrkj = nrkj2 * nrkj_1;
410 float a = -ddphi * nrkj / iprm;
412 float b = ddphi * nrkj / iprn;
414 float p = iprod(r_ij, r_kj);
416 float q = iprod(r_kl, r_kj);
418 float3 uvec = p * f_i;
419 float3 vvec = q * f_l;
420 float3 svec = uvec - vvec;
421 float3 f_j = f_i - svec;
422 float3 f_k = f_l + svec;
424 atomicAdd(&gm_f[i], f_i);
425 atomicAdd(&gm_f[j], -f_j);
426 atomicAdd(&gm_f[k], -f_k);
427 atomicAdd(&gm_f[l], f_l);
432 int t3 = pbcDxAiuc<calcVir>(pbcAiuc, gm_xq[l], gm_xq[j], dx_jl);
434 atomicAdd(&sm_fShiftLoc[t1], f_i);
435 atomicAdd(&sm_fShiftLoc[CENTRAL], -f_j);
436 atomicAdd(&sm_fShiftLoc[t2], -f_k);
437 atomicAdd(&sm_fShiftLoc[t3], f_l);
442 template<bool calcVir, bool calcEner>
443 __device__ void pdihs_gpu(const int i,
446 const t_iatom d_forceatoms[],
447 const t_iparams d_forceparams[],
448 const float4 gm_xq[],
450 float3 sm_fShiftLoc[],
451 const PbcAiuc pbcAiuc)
455 int type = d_forceatoms[5 * i];
456 int ai = d_forceatoms[5 * i + 1];
457 int aj = d_forceatoms[5 * i + 2];
458 int ak = d_forceatoms[5 * i + 3];
459 int al = d_forceatoms[5 * i + 4];
469 float phi = dih_angle_gpu<calcVir>(
470 gm_xq[ai], gm_xq[aj], gm_xq[ak], gm_xq[al], pbcAiuc, &r_ij, &r_kj, &r_kl, &m, &n, &t1, &t2, &t3);
474 dopdihs_gpu(d_forceparams[type].pdihs.cpA,
475 d_forceparams[type].pdihs.phiA,
476 d_forceparams[type].pdihs.mult,
486 do_dih_fup_gpu<calcVir>(
487 ai, aj, ak, al, ddphi, r_ij, r_kj, r_kl, m, n, gm_f, sm_fShiftLoc, pbcAiuc, gm_xq, t1, t2, t3);
491 template<bool calcVir, bool calcEner>
492 __device__ void rbdihs_gpu(const int i,
495 const t_iatom d_forceatoms[],
496 const t_iparams d_forceparams[],
497 const float4 gm_xq[],
499 float3 sm_fShiftLoc[],
500 const PbcAiuc pbcAiuc)
502 constexpr float c0 = 0.0f, c1 = 1.0f, c2 = 2.0f, c3 = 3.0f, c4 = 4.0f, c5 = 5.0f;
506 int type = d_forceatoms[5 * i];
507 int ai = d_forceatoms[5 * i + 1];
508 int aj = d_forceatoms[5 * i + 2];
509 int ak = d_forceatoms[5 * i + 3];
510 int al = d_forceatoms[5 * i + 4];
520 float phi = dih_angle_gpu<calcVir>(
521 gm_xq[ai], gm_xq[aj], gm_xq[ak], gm_xq[al], pbcAiuc, &r_ij, &r_kj, &r_kl, &m, &n, &t1, &t2, &t3);
523 /* Change to polymer convention */
532 float cos_phi = cosf(phi);
533 /* Beware of accuracy loss, cannot use 1-sqrt(cos^2) ! */
534 float sin_phi = sinf(phi);
536 float parm[NR_RBDIHS];
537 for (int j = 0; j < NR_RBDIHS; j++)
539 parm[j] = d_forceparams[type].rbdihs.rbcA[j];
541 /* Calculate cosine powers */
542 /* Calculate the energy */
543 /* Calculate the derivative */
549 ddphi += rbp * cosfac;
556 ddphi += c2 * rbp * cosfac;
563 ddphi += c3 * rbp * cosfac;
570 ddphi += c4 * rbp * cosfac;
577 ddphi += c5 * rbp * cosfac;
584 ddphi = -ddphi * sin_phi;
586 do_dih_fup_gpu<calcVir>(
587 ai, aj, ak, al, ddphi, r_ij, r_kj, r_kl, m, n, gm_f, sm_fShiftLoc, pbcAiuc, gm_xq, t1, t2, t3);
595 __device__ __forceinline__ static void make_dp_periodic_gpu(float* dp)
597 /* dp cannot be outside (-pi,pi) */
598 if (*dp >= CUDART_PI_F)
600 *dp -= 2.0f * CUDART_PI_F;
602 else if (*dp < -CUDART_PI_F)
604 *dp += 2.0f * CUDART_PI_F;
608 template<bool calcVir, bool calcEner>
609 __device__ void idihs_gpu(const int i,
612 const t_iatom d_forceatoms[],
613 const t_iparams d_forceparams[],
614 const float4 gm_xq[],
616 float3 sm_fShiftLoc[],
617 const PbcAiuc pbcAiuc)
621 int type = d_forceatoms[5 * i];
622 int ai = d_forceatoms[5 * i + 1];
623 int aj = d_forceatoms[5 * i + 2];
624 int ak = d_forceatoms[5 * i + 3];
625 int al = d_forceatoms[5 * i + 4];
635 float phi = dih_angle_gpu<calcVir>(
636 gm_xq[ai], gm_xq[aj], gm_xq[ak], gm_xq[al], pbcAiuc, &r_ij, &r_kj, &r_kl, &m, &n, &t1, &t2, &t3);
638 /* phi can jump if phi0 is close to Pi/-Pi, which will cause huge
639 * force changes if we just apply a normal harmonic.
640 * Instead, we first calculate phi-phi0 and take it modulo (-Pi,Pi).
641 * This means we will never have the periodicity problem, unless
642 * the dihedral is Pi away from phiO, which is very unlikely due to
645 float kA = d_forceparams[type].harmonic.krA;
646 float pA = d_forceparams[type].harmonic.rA;
648 float phi0 = pA * CUDA_DEG2RAD_F;
650 float dp = phi - phi0;
652 make_dp_periodic_gpu(&dp);
654 float ddphi = -kA * dp;
656 do_dih_fup_gpu<calcVir>(
657 ai, aj, ak, al, -ddphi, r_ij, r_kj, r_kl, m, n, gm_f, sm_fShiftLoc, pbcAiuc, gm_xq, t1, t2, t3);
661 *vtot_loc += -0.5f * ddphi * dp;
666 template<bool calcVir, bool calcEner>
667 __device__ void pairs_gpu(const int i,
669 const t_iatom d_forceatoms[],
670 const t_iparams iparams[],
671 const float4 gm_xq[],
673 float3 sm_fShiftLoc[],
674 const PbcAiuc pbcAiuc,
675 const float scale_factor,
681 // TODO this should be made into a separate type, the GPU and CPU sizes should be compared
682 int3 pairData = *(int3*)(d_forceatoms + 3 * i);
683 int type = pairData.x;
687 float qq = gm_xq[ai].w * gm_xq[aj].w;
688 float c6 = iparams[type].lj14.c6A;
689 float c12 = iparams[type].lj14.c12A;
691 /* Do we need to apply full periodic boundary conditions? */
693 int fshift_index = pbcDxAiuc<calcVir>(pbcAiuc, gm_xq[ai], gm_xq[aj], dr);
695 float r2 = norm2(dr);
696 float rinv = rsqrtf(r2);
697 float rinv2 = rinv * rinv;
698 float rinv6 = rinv2 * rinv2 * rinv2;
700 /* Calculate the Coulomb force * r */
701 float velec = scale_factor * qq * rinv;
703 /* Calculate the LJ force * r and add it to the Coulomb part */
704 float fr = (12.0f * c12 * rinv6 - 6.0f * c6) * rinv6 + velec;
706 float finvr = fr * rinv2;
707 float3 f = finvr * dr;
710 atomicAdd(&gm_f[ai], f);
711 atomicAdd(&gm_f[aj], -f);
712 if (calcVir && fshift_index != CENTRAL)
714 atomicAdd(&sm_fShiftLoc[fshift_index], f);
715 atomicAdd(&sm_fShiftLoc[CENTRAL], -f);
720 *vtotVdw_loc += (c12 * rinv6 - c6) * rinv6;
721 *vtotElec_loc += velec;
729 template<bool calcVir, bool calcEner>
730 __global__ void exec_kernel_gpu(BondedCudaKernelParameters kernelParams)
732 assert(blockDim.y == 1 && blockDim.z == 1);
733 const int tid = blockIdx.x * blockDim.x + threadIdx.x;
735 float vtotVdw_loc = 0;
736 float vtotElec_loc = 0;
738 extern __shared__ char sm_dynamicShmem[];
739 char* sm_nextSlotPtr = sm_dynamicShmem;
740 float3* sm_fShiftLoc = (float3*)sm_nextSlotPtr;
741 sm_nextSlotPtr += SHIFTS * sizeof(float3);
745 if (threadIdx.x < SHIFTS)
747 sm_fShiftLoc[threadIdx.x] = make_float3(0.0f, 0.0f, 0.0f);
753 bool threadComputedPotential = false;
755 for (int j = 0; j < numFTypesOnGpu; j++)
757 if (tid >= kernelParams.fTypeRangeStart[j] && tid <= kernelParams.fTypeRangeEnd[j])
759 const int numBonds = kernelParams.numFTypeBonds[j];
760 int fTypeTid = tid - kernelParams.fTypeRangeStart[j];
761 const t_iatom* iatoms = kernelParams.d_iatoms[j];
762 fType = kernelParams.fTypesOnGpu[j];
765 threadComputedPotential = true;
771 bonds_gpu<calcVir, calcEner>(fTypeTid,
775 kernelParams.d_forceParams,
779 kernelParams.pbcAiuc);
782 angles_gpu<calcVir, calcEner>(fTypeTid,
786 kernelParams.d_forceParams,
790 kernelParams.pbcAiuc);
793 urey_bradley_gpu<calcVir, calcEner>(fTypeTid,
797 kernelParams.d_forceParams,
801 kernelParams.pbcAiuc);
805 pdihs_gpu<calcVir, calcEner>(fTypeTid,
809 kernelParams.d_forceParams,
813 kernelParams.pbcAiuc);
816 rbdihs_gpu<calcVir, calcEner>(fTypeTid,
820 kernelParams.d_forceParams,
824 kernelParams.pbcAiuc);
827 idihs_gpu<calcVir, calcEner>(fTypeTid,
831 kernelParams.d_forceParams,
835 kernelParams.pbcAiuc);
838 pairs_gpu<calcVir, calcEner>(fTypeTid,
841 kernelParams.d_forceParams,
845 kernelParams.pbcAiuc,
846 kernelParams.electrostaticsScaleFactor,
855 if (threadComputedPotential)
857 float* vtotVdw = kernelParams.d_vTot + F_LJ14;
858 float* vtotElec = kernelParams.d_vTot + F_COUL14;
860 // Stage atomic accumulation through shared memory:
861 // each warp will accumulate its own partial sum
862 // and then a single thread per warp will accumulate this to the global sum
864 int numWarps = blockDim.x / warpSize;
865 int warpId = threadIdx.x / warpSize;
867 // Shared memory variables to hold block-local partial sum
868 float* sm_vTot = (float*)sm_nextSlotPtr;
869 sm_nextSlotPtr += numWarps * sizeof(float);
870 float* sm_vTotVdw = (float*)sm_nextSlotPtr;
871 sm_nextSlotPtr += numWarps * sizeof(float);
872 float* sm_vTotElec = (float*)sm_nextSlotPtr;
874 if (threadIdx.x % warpSize == 0)
876 // One thread per warp initializes to zero
877 sm_vTot[warpId] = 0.;
878 sm_vTotVdw[warpId] = 0.;
879 sm_vTotElec[warpId] = 0.;
881 __syncwarp(); // All threads in warp must wait for initialization
883 // Perform warp-local accumulation in shared memory
884 atomicAdd(sm_vTot + warpId, vtot_loc);
885 atomicAdd(sm_vTotVdw + warpId, vtotVdw_loc);
886 atomicAdd(sm_vTotElec + warpId, vtotElec_loc);
888 __syncwarp(); // Ensure all threads in warp have completed
889 if (threadIdx.x % warpSize == 0)
890 { // One thread per warp accumulates partial sum into global sum
891 atomicAdd(kernelParams.d_vTot + fType, sm_vTot[warpId]);
892 atomicAdd(vtotVdw, sm_vTotVdw[warpId]);
893 atomicAdd(vtotElec, sm_vTotElec[warpId]);
896 /* Accumulate shift vectors from shared memory to global memory on the first SHIFTS threads of the block. */
900 if (threadIdx.x < SHIFTS)
902 atomicAdd(kernelParams.d_fShift[threadIdx.x], sm_fShiftLoc[threadIdx.x]);
908 /*-------------------------------- End CUDA kernels-----------------------------*/
911 template<bool calcVir, bool calcEner>
912 void GpuBonded::Impl::launchKernel()
914 GMX_ASSERT(haveInteractions_,
915 "Cannot launch bonded GPU kernels unless bonded GPU work was scheduled");
917 wallcycle_start_nocount(wcycle_, ewcLAUNCH_GPU);
918 wallcycle_sub_start(wcycle_, ewcsLAUNCH_GPU_BONDED);
920 int fTypeRangeEnd = kernelParams_.fTypeRangeEnd[numFTypesOnGpu - 1];
922 if (fTypeRangeEnd < 0)
927 auto kernelPtr = exec_kernel_gpu<calcVir, calcEner>;
929 const auto kernelArgs = prepareGpuKernelArguments(kernelPtr, kernelLaunchConfig_, &kernelParams_);
931 launchGpuKernel(kernelPtr,
935 "exec_kernel_gpu<calcVir, calcEner>",
938 wallcycle_sub_stop(wcycle_, ewcsLAUNCH_GPU_BONDED);
939 wallcycle_stop(wcycle_, ewcLAUNCH_GPU);
942 void GpuBonded::launchKernel(const gmx::StepWorkload& stepWork)
944 if (stepWork.computeEnergy)
946 // When we need the energy, we also need the virial
947 impl_->launchKernel<true, true>();
949 else if (stepWork.computeVirial)
951 impl_->launchKernel<true, false>();
955 impl_->launchKernel<false, false>();