/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
return;
}
-LeapFrogGpu::LeapFrogGpu(const DeviceContext& deviceContext, const DeviceStream& deviceStream) :
+LeapFrogGpu::LeapFrogGpu(const DeviceContext& deviceContext,
+ const DeviceStream& deviceStream,
+ const int numTempScaleValues) :
deviceContext_(deviceContext),
- deviceStream_(deviceStream)
+ deviceStream_(deviceStream),
+ numTempScaleValues_(numTempScaleValues)
{
numAtoms_ = 0;
kernelLaunchConfig_.blockSize[1] = 1;
kernelLaunchConfig_.blockSize[2] = 1;
kernelLaunchConfig_.sharedMemorySize = 0;
+
+ // If the temperature coupling is enabled, we need to make space for scaling factors
+ if (numTempScaleValues_ > 0)
+ {
+ h_lambdas_.resize(numTempScaleValues_);
+ reallocateDeviceBuffer(
+ &d_lambdas_, numTempScaleValues_, &numLambdas_, &numLambdasAlloc_, deviceContext_);
+ }
}
LeapFrogGpu::~LeapFrogGpu()
freeDeviceBuffer(&d_inverseMasses_);
}
-void LeapFrogGpu::set(const int numAtoms,
- const real* inverseMasses,
- const int numTempScaleValues,
- const unsigned short* tempScaleGroups)
+void LeapFrogGpu::set(const int numAtoms, const real* inverseMasses, const unsigned short* tempScaleGroups)
{
numAtoms_ = numAtoms;
kernelLaunchConfig_.gridSize[0] = (numAtoms_ + c_threadsPerBlock - 1) / c_threadsPerBlock;
- numTempScaleValues_ = numTempScaleValues;
-
reallocateDeviceBuffer(
&d_inverseMasses_, numAtoms_, &numInverseMasses_, &numInverseMassesAlloc_, deviceContext_);
copyToDeviceBuffer(
&d_inverseMasses_, (float*)inverseMasses, 0, numAtoms_, deviceStream_, GpuApiCallBehavior::Sync, nullptr);
// Temperature scale group map only used if there are more then one group
- if (numTempScaleValues > 1)
+ if (numTempScaleValues_ > 1)
{
reallocateDeviceBuffer(
&d_tempScaleGroups_, numAtoms_, &numTempScaleGroups_, &numTempScaleGroupsAlloc_, deviceContext_);
copyToDeviceBuffer(
&d_tempScaleGroups_, tempScaleGroups, 0, numAtoms_, deviceStream_, GpuApiCallBehavior::Sync, nullptr);
}
-
- // If the temperature coupling is enabled, we need to make space for scaling factors
- if (numTempScaleValues_ > 0)
- {
- h_lambdas_.resize(numTempScaleValues);
- reallocateDeviceBuffer(
- &d_lambdas_, numTempScaleValues_, &numLambdas_, &numLambdasAlloc_, deviceContext_);
- }
}
} // namespace gmx
public:
/*! \brief Constructor.
*
- * \param[in] deviceContext Device context (dummy in CUDA).
- * \param[in] deviceStream Device stream to use.
+ * \param[in] deviceContext Device context (dummy in CUDA).
+ * \param[in] deviceStream Device stream to use.
+ * \param[in] numTempScaleValues Number of temperature scale groups.
*/
- LeapFrogGpu(const DeviceContext& deviceContext, const DeviceStream& deviceStream);
+ LeapFrogGpu(const DeviceContext& deviceContext, const DeviceStream& deviceStream, int numTempScaleValues);
~LeapFrogGpu();
/*! \brief Integrate
* and temperature coupling groups. Copies inverse masses and temperature coupling groups
* to the GPU.
*
- * \param[in] numAtoms Number of atoms in the system.
- * \param[in] inverseMasses Inverse masses of atoms.
- * \param[in] numTempScaleValues Number of temperature scale groups.
- * \param[in] tempScaleGroups Maps the atom index to temperature scale value.
+ * \param[in] numAtoms Number of atoms in the system.
+ * \param[in] inverseMasses Inverse masses of atoms.
+ * \param[in] tempScaleGroups Maps the atom index to temperature scale value.
*/
- void set(const int numAtoms,
- const real* inverseMasses,
- int numTempScaleValues,
- const unsigned short* tempScaleGroups);
+ void set(const int numAtoms, const real* inverseMasses, const unsigned short* tempScaleGroups);
/*! \brief Class with hardware-specific interfaces and implementations.*/
class Impl;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
prVelocityScalingMatrixDiagonal_);
}
-LeapFrogGpu::LeapFrogGpu(const DeviceContext& deviceContext, const DeviceStream& deviceStream) :
+LeapFrogGpu::LeapFrogGpu(const DeviceContext& deviceContext,
+ const DeviceStream& deviceStream,
+ const int numTempScaleValues) :
deviceContext_(deviceContext),
deviceStream_(deviceStream),
- numAtoms_(0)
+ numAtoms_(0),
+ numTempScaleValues_(numTempScaleValues)
{
+ // If the temperature coupling is enabled, we need to make space for scaling factors
+ if (numTempScaleValues_ > 0)
+ {
+ reallocateDeviceBuffer(
+ &d_lambdas_, numTempScaleValues_, &numLambdas_, &numLambdasAlloc_, deviceContext_);
+ }
}
LeapFrogGpu::~LeapFrogGpu()
freeDeviceBuffer(&d_inverseMasses_);
}
-void LeapFrogGpu::set(const int numAtoms,
- const real* inverseMasses,
- const int numTempScaleValues,
- const unsigned short* tempScaleGroups)
+void LeapFrogGpu::set(const int numAtoms, const real* inverseMasses, const unsigned short* tempScaleGroups)
{
- numAtoms_ = numAtoms;
- numTempScaleValues_ = numTempScaleValues;
+ numAtoms_ = numAtoms;
reallocateDeviceBuffer(
&d_inverseMasses_, numAtoms_, &numInverseMasses_, &numInverseMassesAlloc_, deviceContext_);
copyToDeviceBuffer(
&d_tempScaleGroups_, tempScaleGroups, 0, numAtoms_, deviceStream_, GpuApiCallBehavior::Sync, nullptr);
}
-
- // If the temperature coupling is enabled, we need to make space for scaling factors
- if (numTempScaleValues_ > 0)
- {
- reallocateDeviceBuffer(
- &d_lambdas_, numTempScaleValues_, &numLambdas_, &numLambdasAlloc_, deviceContext_);
- }
}
} // namespace gmx
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
copyToDeviceBuffer(&d_v, h_v, 0, numAtoms, deviceStream, GpuApiCallBehavior::Sync, nullptr);
copyToDeviceBuffer(&d_f, h_f, 0, numAtoms, deviceStream, GpuApiCallBehavior::Sync, nullptr);
- auto integrator = std::make_unique<LeapFrogGpu>(deviceContext, deviceStream);
+ auto integrator =
+ std::make_unique<LeapFrogGpu>(deviceContext, deviceStream, testData->numTCoupleGroups_);
- integrator->set(testData->numAtoms_,
- testData->inverseMasses_.data(),
- testData->numTCoupleGroups_,
- testData->mdAtoms_.cTC);
+ integrator->set(testData->numAtoms_, testData->inverseMasses_.data(), testData->mdAtoms_.cTC);
bool doTempCouple = testData->numTCoupleGroups_ > 0;
for (int step = 0; step < numSteps; step++)
* any) consumers of the updated coordinates. The \p xUpdatedOnDevice also can not be a nullptr
* because the markEvent(...) method is called unconditionally.
*
- * \param[in] ir Input record data: LINCS takes number of iterations and order of
- * projection from it.
- * \param[in] mtop Topology of the system: SETTLE gets the masses for O and H atoms
- * and target O-H and H-H distances from this object.
- * \param[in] deviceContext GPU device context.
- * \param[in] deviceStream GPU stream to use.
- * \param[in] xUpdatedOnDevice The event synchronizer to use to mark that update is done
- * on the GPU.
- * \param[in] wcycle The wallclock counter
+ * \param[in] ir Input record data: LINCS takes number of iterations and order of
+ * projection from it.
+ * \param[in] mtop Topology of the system: SETTLE gets the masses for O and H atoms
+ * and target O-H and H-H distances from this object.
+ * \param[in] numTempScaleValues Number of temperature scaling groups. Zero for no temperature scaling.
+ * \param[in] deviceContext GPU device context.
+ * \param[in] deviceStream GPU stream to use.
+ * \param[in] xUpdatedOnDevice The event synchronizer to use to mark that update is done
+ * on the GPU.
+ * \param[in] wcycle The wallclock counter
*/
UpdateConstrainGpu(const t_inputrec& ir,
const gmx_mtop_t& mtop,
+ int numTempScaleValues,
const DeviceContext& deviceContext,
const DeviceStream& deviceStream,
GpuEventSynchronizer* xUpdatedOnDevice,
* \param[in] d_f Device buffer with forces.
* \param[in] idef System topology
* \param[in] md Atoms data.
- * \param[in] numTempScaleValues Number of temperature scaling groups. Zero for no temperature scaling.
*/
void set(DeviceBuffer<RVec> d_x,
DeviceBuffer<RVec> d_v,
DeviceBuffer<RVec> d_f,
const InteractionDefinitions& idef,
- const t_mdatoms& md,
- int numTempScaleValues);
+ const t_mdatoms& md);
/*! \brief
* Update PBC data.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
UpdateConstrainGpu::UpdateConstrainGpu(const t_inputrec& /* ir */,
const gmx_mtop_t& /* mtop */,
+ const int /* numTempScaleValues */,
const DeviceContext& /* deviceContext */,
const DeviceStream& /* deviceStream */,
GpuEventSynchronizer* /* xUpdatedOnDevice */,
DeviceBuffer<RVec> /* d_v */,
const DeviceBuffer<RVec> /* d_f */,
const InteractionDefinitions& /* idef */,
- const t_mdatoms& /* md */,
- const int /* numTempScaleValues */)
+ const t_mdatoms& /* md */)
{
GMX_ASSERT(!impl_,
"A CPU stub for UpdateConstrain was called instead of the correct implementation.");
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
UpdateConstrainGpu::Impl::Impl(const t_inputrec& ir,
const gmx_mtop_t& mtop,
+ const int numTempScaleValues,
const DeviceContext& deviceContext,
const DeviceStream& deviceStream,
GpuEventSynchronizer* xUpdatedOnDevice,
GMX_ASSERT(xUpdatedOnDevice != nullptr, "The event synchronizer can not be nullptr.");
- integrator_ = std::make_unique<LeapFrogGpu>(deviceContext_, deviceStream_);
+ integrator_ = std::make_unique<LeapFrogGpu>(deviceContext_, deviceStream_, numTempScaleValues);
lincsGpu_ = std::make_unique<LincsGpu>(ir.nLincsIter, ir.nProjOrder, deviceContext_, deviceStream_);
settleGpu_ = std::make_unique<SettleGpu>(mtop, deviceContext_, deviceStream_);
DeviceBuffer<RVec> d_v,
const DeviceBuffer<RVec> d_f,
const InteractionDefinitions& idef,
- const t_mdatoms& md,
- const int numTempScaleValues)
+ const t_mdatoms& md)
{
// TODO wallcycle
wallcycle_start_nocount(wcycle_, ewcLAUNCH_GPU);
&d_inverseMasses_, numAtoms_, &numInverseMasses_, &numInverseMassesAlloc_, deviceContext_);
// Integrator should also update something, but it does not even have a method yet
- integrator_->set(numAtoms_, md.invmass, numTempScaleValues, md.cTC);
+ integrator_->set(numAtoms_, md.invmass, md.cTC);
lincsGpu_->set(idef, numAtoms_, md.invmass);
settleGpu_->set(idef);
UpdateConstrainGpu::UpdateConstrainGpu(const t_inputrec& ir,
const gmx_mtop_t& mtop,
+ const int numTempScaleValues,
const DeviceContext& deviceContext,
const DeviceStream& deviceStream,
GpuEventSynchronizer* xUpdatedOnDevice,
gmx_wallcycle* wcycle) :
- impl_(new Impl(ir, mtop, deviceContext, deviceStream, xUpdatedOnDevice, wcycle))
+ impl_(new Impl(ir, mtop, numTempScaleValues, deviceContext, deviceStream, xUpdatedOnDevice, wcycle))
{
}
DeviceBuffer<RVec> d_v,
const DeviceBuffer<RVec> d_f,
const InteractionDefinitions& idef,
- const t_mdatoms& md,
- const int numTempScaleValues)
+ const t_mdatoms& md)
{
- impl_->set(d_x, d_v, d_f, idef, md, numTempScaleValues);
+ impl_->set(d_x, d_v, d_f, idef, md);
}
void UpdateConstrainGpu::setPbc(const PbcType pbcType, const matrix box)
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 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.
* any) consumers of the updated coordinates. The \p xUpdatedOnDevice also can not be a nullptr
* because the markEvent(...) method is called unconditionally.
*
- * \param[in] ir Input record data: LINCS takes number of iterations and order of
- * projection from it.
- * \param[in] mtop Topology of the system: SETTLE gets the masses for O and H atoms
- * and target O-H and H-H distances from this object.
- * \param[in] deviceContext GPU device context.
- * \param[in] deviceStream GPU stream to use.
- * \param[in] xUpdatedOnDevice The event synchronizer to use to mark that
- * update is done on the GPU.
- * \param[in] wcycle The wallclock counter
+ * \param[in] ir Input record data: LINCS takes number of iterations and order of
+ * projection from it.
+ * \param[in] mtop Topology of the system: SETTLE gets the masses for O and H atoms
+ * and target O-H and H-H distances from this object.
+ * \param[in] numTempScaleValues Number of temperature scaling groups. Set zero for no temperature coupling.
+ * \param[in] deviceContext GPU device context.
+ * \param[in] deviceStream GPU stream to use.
+ * \param[in] xUpdatedOnDevice The event synchronizer to use to mark that
+ * update is done on the GPU.
+ * \param[in] wcycle The wallclock counter
*/
Impl(const t_inputrec& ir,
const gmx_mtop_t& mtop,
+ int numTempScaleValues,
const DeviceContext& deviceContext,
const DeviceStream& deviceStream,
GpuEventSynchronizer* xUpdatedOnDevice,
* \param[in] d_f Device buffer with forces.
* \param[in] idef System topology
* \param[in] md Atoms data.
- * \param[in] numTempScaleValues Number of temperature scaling groups. Set zero for no temperature coupling.
*/
void set(DeviceBuffer<RVec> d_x,
DeviceBuffer<RVec> d_v,
const DeviceBuffer<RVec> d_f,
const InteractionDefinitions& idef,
- const t_mdatoms& md,
- const int numTempScaleValues);
+ const t_mdatoms& md);
/*! \brief
* Update PBC data.
integrator = std::make_unique<UpdateConstrainGpu>(
*ir,
*top_global,
+ ekind->ngtc,
fr->deviceStreamManager->context(),
fr->deviceStreamManager->stream(gmx::DeviceStreamType::UpdateAndConstraints),
stateGpu->xUpdatedOnDevice(),
stateGpu->getVelocities(),
stateGpu->getForces(),
top.idef,
- *mdatoms,
- ekind->ngtc);
+ *mdatoms);
// Copy data to the GPU after buffers might have being reinitialized
stateGpu->copyVelocitiesToGpu(state->v, AtomLocality::Local);