/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \ingroup module_gpu_utils
*/
#include <cuda_runtime.h>
+#include "gromacs/math/vectypes.h"
//! Device texture for fast read-only data fetching
using DeviceTexture = cudaTextureObject_t;
//! \brief Single GPU call timing event - meaningless in CUDA
using CommandEvent = void;
+//! Convenience alias for 2-wide float
+using Float2 = float2;
+
+//! Convenience alias for 3-wide float
+using Float3 = gmx::RVec;
+
+//! Convenience alias for 4-wide float.
+using Float4 = float4;
+
/*! \internal \brief
* GPU kernels scheduling description. This is same in OpenCL/CUDA.
* Provides reasonable defaults, one typically only needs to set the GPU stream
adat_len = adat->natoms - adat->natoms_local;
}
- /* HtoD x, q */
/* beginning of timed HtoD section */
if (bDoTime)
{
t->xf[atomLocality].nb_h2d.openTimingRegion(deviceStream);
}
- static_assert(sizeof(adat->xq[0]) == sizeof(float4),
+ /* HtoD x, q */
+ static_assert(sizeof(adat->xq[0]) == sizeof(Float4),
"The size of the xyzq buffer element should be equal to the size of float4.");
copyToDeviceBuffer(&adat->xq,
- reinterpret_cast<const float4*>(nbatom->x().data()) + adat_begin,
+ reinterpret_cast<const Float4*>(nbatom->x().data()) + adat_begin,
adat_begin,
adat_len,
deviceStream,
if (!stepWork.useGpuFBufferOps)
{
static_assert(
- sizeof(adat->f[0]) == sizeof(float3),
+ sizeof(adat->f[0]) == sizeof(Float3),
"The size of the force buffer element should be equal to the size of float3.");
- copyFromDeviceBuffer(reinterpret_cast<float3*>(nbatom->out[0].f.data()) + adat_begin,
+ copyFromDeviceBuffer(reinterpret_cast<Float3*>(nbatom->out[0].f.data()) + adat_begin,
&adat->f,
adat_begin,
adat_len,
static_assert(sizeof(adat->shift_vec[0]) == sizeof(nbatom->shift_vec[0]),
"Sizes of host- and device-side shift vectors should be the same.");
copyToDeviceBuffer(&adat->shift_vec,
- reinterpret_cast<const float3*>(nbatom->shift_vec.data()),
+ reinterpret_cast<const Float3*>(nbatom->shift_vec.data()),
0,
SHIFTS,
localStream,
if (useLjCombRule(nb->nbparam->vdwType))
{
- static_assert(sizeof(d_atdat->lj_comb[0]) == sizeof(float2),
+ static_assert(sizeof(d_atdat->lj_comb[0]) == sizeof(Float2),
"Size of the LJ parameters element should be equal to the size of float2.");
copyToDeviceBuffer(&d_atdat->lj_comb,
- reinterpret_cast<const float2*>(nbat->params().lj_comb.data()),
+ reinterpret_cast<const Float2*>(nbat->params().lj_comb.data()),
0,
natoms,
localStream,
#include "gromacs/gpu_utils/cuda_arch_utils.cuh"
#include "gromacs/gpu_utils/cuda_kernel_utils.cuh"
+#include "gromacs/gpu_utils/typecasts.cuh"
#include "gromacs/math/utilities.h"
#include "gromacs/pbcutil/ishift.h"
/* Note that floating-point constants in CUDA code should be suffixed
float2 ljcp_i, ljcp_j;
# endif
const float4* xq = atdat.xq;
- float3* f = atdat.f;
- const float3* shift_vec = atdat.shift_vec;
+ float3* f = asFloat3(atdat.f);
+ const float3* shift_vec = asFloat3(atdat.shift_vec);
float rcoulomb_sq = nbparam.rcoulomb_sq;
# ifdef VDW_CUTOFF_CHECK
float rvdw_sq = nbparam.rvdw_sq;
/* add up local shift forces into global mem, tidxj indexes x,y,z */
if (bCalcFshift && (tidxj & 3) < 3)
{
- atomicAdd(&(atdat.fshift[nb_sci.shift].x) + (tidxj & 3), fshift_buf);
+ float3* fshift = asFloat3(atdat.fshift);
+ atomicAdd(&(fshift[nb_sci.shift].x) + (tidxj & 3), fshift_buf);
}
# ifdef CALC_ENERGIES
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gmxpre.h"
#include "gromacs/gpu_utils/cuda_arch_utils.cuh"
+#include "gromacs/gpu_utils/typecasts.cuh"
#include "gromacs/math/utilities.h"
#include "gromacs/pbcutil/ishift.h"
const nbnxn_sci_t* pl_sci = plist.sci;
nbnxn_cj4_t* pl_cj4 = plist.cj4;
const float4* xq = atdat.xq;
- const float3* shift_vec = atdat.shift_vec;
+ const float3* shift_vec = asFloat3(atdat.shift_vec);
float rlistOuter_sq = nbparam.rlistOuter_sq;
float rlistInner_sq = nbparam.rlistInner_sq;
//! electrostatic energy
float* e_el = nullptr;
//! shift forces
- float3* fshift = nullptr;
+ Float3* fshift = nullptr;
};
/** \internal
int nalloc;
//! atom coordinates + charges, size natoms
- DeviceBuffer<float4> xq;
+ DeviceBuffer<Float4> xq;
//! force output array, size natoms
- DeviceBuffer<float3> f;
+ DeviceBuffer<Float3> f;
//! LJ energy output, size 1
DeviceBuffer<float> e_lj;
DeviceBuffer<float> e_el;
//! shift forces
- DeviceBuffer<float3> fshift;
+ DeviceBuffer<Float3> fshift;
//! number of atom types
int ntypes;
//! atom type indices, size natoms
DeviceBuffer<int> atom_types;
//! sqrt(c6),sqrt(c12) size natoms
- DeviceBuffer<float2> lj_comb;
+ DeviceBuffer<Float2> lj_comb;
//! shifts
- DeviceBuffer<float3> shift_vec;
+ DeviceBuffer<Float3> shift_vec;
//! true if the shift vector has been uploaded
bool bShiftVecUploaded;
};