// forceatoms
for (int ftype : ftypesOnGpu)
{
- const InteractionList &iList = gpuBondedLists->iLists[ftype];
+ const auto &iList = gpuBondedLists->iLists[ftype];
if (iList.size() > 0)
{
copyToDeviceBuffer(&iListDevice.iatoms, iList.iatoms.data(),
0, iList.size(),
- *stream, GpuApiCallBehavior::Sync, nullptr);
+ *stream, GpuApiCallBehavior::Async, nullptr);
}
}
}
for (int ftype : ftypesOnGpu)
{
- const InteractionList &iList = gpuBondedLists->iLists[ftype];
+ const auto &iList = gpuBondedLists->iLists[ftype];
if (iList.size() > 0)
{
for (int ftype : ftypesOnGpu)
{
- const InteractionList &iList = fr->gpuBondedLists->iLists[ftype];
+ const auto &iList = fr->gpuBondedLists->iLists[ftype];
if (iList.size() > 0)
{
float *vtot = gpuBondedLists->vtot.data();
copyFromDeviceBuffer(vtot, &gpuBondedLists->vtotDevice,
0, F_NRE,
- *stream, GpuApiCallBehavior::Sync, nullptr);
+ *stream, GpuApiCallBehavior::Async, nullptr);
cudaError_t stat = cudaStreamSynchronize(*stream);
CU_RET_ERR(stat, "D2H transfer failed");
#include <string>
+#include "gromacs/gpu_utils/hostallocator.h"
#include "gromacs/topology/idef.h"
#include "gromacs/utility/arrayref.h"
struct gmx_mtop_t;
struct t_inputrec;
-/*! \brief List of all bonded function types supported on a GPUs
+/*! \brief The number on bonded function types supported on GPUs */
+constexpr int c_numFtypesOnGpu = 8;
+
+/*! \brief List of all bonded function types supported on GPUs
*
* \note This list should be in sync with the actual GPU code.
* \note Perturbed interactions are not supported on GPUs.
* \note The function types in the list are ordered on increasing value.
* \note Currently bonded are only supported with CUDA, not with OpenCL.
*/
-constexpr std::array<int, 8> ftypesOnGpu =
+constexpr std::array<int, c_numFtypesOnGpu> ftypesOnGpu =
{
F_BONDS,
F_ANGLES,
F_LJ14
};
+/*! \libinternal \brief Version of InteractionList that supports pinning */
+struct HostInteractionList
+{
+ /*! \brief Returns the total number of elements in iatoms */
+ int size() const
+ {
+ return iatoms.size();
+ }
+
+ /*! \brief List of interactions, see explanation further down */
+ std::vector < int, gmx::HostAllocator < int>> iatoms = {{}, gmx::HostAllocationPolicy(gmx::PinningPolicy::PinnedIfSupported)};
+};
+
+/*! \brief Convenience alias for set of pinned interaction lists */
+using HostInteractionLists = std::array<HostInteractionList, F_NRE>;
+
/*! \internal \brief Struct for storing lists of bonded interaction for evaluation on a GPU */
struct GpuBondedLists
{
}
#endif
- InteractionLists iLists; /**< The interaction lists */
- bool haveInteractions; /**< Tells whether there are any interaction in iLists */
+ HostInteractionLists iLists; /**< The interaction lists */
+ bool haveInteractions; /**< Tells whether there are any interaction in iLists */
+
+ t_iparams *forceparamsDevice = nullptr; /**< Bonded parameters for device-side use */
+ t_ilist iListsDevice[F_NRE]; /**< Interaction lists on the device */
- t_iparams *forceparamsDevice = nullptr; /**< Bonded parameters for device-side use */
- t_ilist iListsDevice[F_NRE]; /**< Interaction lists on the device */
- std::vector<float> vtot; /**< Host-side virial buffer */
- float *vtotDevice = nullptr; /**< Device-side total virial */
+ //! \brief Host-side virial buffer
+ std::vector < float, gmx::HostAllocator < float>> vtot = {{}, gmx::HostAllocationPolicy(gmx::PinningPolicy::PinnedIfSupported)};
+ //! \brief Device-side total virial
+ float *vtotDevice = nullptr;
- void *stream; /**< Bonded GPU stream */
+ //! \brief Bonded GPU stream
+ void *stream;
};