1. Use AtomLocality:Local instead of AtomLocality::All in PME-only ranks
and in PME tests.
2. Assert on using AtomLocality::All for positions and velocities transfers,
print verbose message on assert.
This reduces the number of possible streams used in StatePropagatoerData, hence
reduces its complexity. In preparation for buffer state tracking.
Refs. #3323
Refs. #3020
pme_gpu_prepare_computation(pme, box, wcycle, stepWork);
if (!pme_pp->useGpuDirectComm)
{
pme_gpu_prepare_computation(pme, box, wcycle, stepWork);
if (!pme_pp->useGpuDirectComm)
{
- stateGpu->copyCoordinatesToGpu(gmx::ArrayRef<gmx::RVec>(pme_pp->x), gmx::AtomLocality::All);
+ stateGpu->copyCoordinatesToGpu(gmx::ArrayRef<gmx::RVec>(pme_pp->x),
+ gmx::AtomLocality::Local);
}
// On the separate PME rank we do not need a synchronizer as we schedule everything in a single stream
// TODO: with pme on GPU the receive should make a list of synchronizers and pass it here #3157
}
// On the separate PME rank we do not need a synchronizer as we schedule everything in a single stream
// TODO: with pme on GPU the receive should make a list of synchronizers and pass it here #3157
stateGpu->reinit(atomCount, atomCount);
stateGpu->copyCoordinatesToGpu(arrayRefFromArray(coordinates.data(), coordinates.size()),
stateGpu->reinit(atomCount, atomCount);
stateGpu->copyCoordinatesToGpu(arrayRefFromArray(coordinates.data(), coordinates.size()),
- gmx::AtomLocality::All);
+ gmx::AtomLocality::Local);
pme_gpu_set_kernelparam_coordinates(pme->gpu, stateGpu->getCoordinates());
break;
pme_gpu_set_kernelparam_coordinates(pme->gpu, stateGpu->getCoordinates());
break;
Count = 3 //!< The number of atom locality types
};
Count = 3 //!< The number of atom locality types
};
-/*! \brief Descriptive strings for atom localities */
-static const EnumerationArray<AtomLocality, const char*> c_atomLocalityNames = {
- { "local", "non-local", "all" }
-};
-
+/*! \brief Get the human-friendly name for atom localities.
+ *
+ * \param[in] enumValue The enum value to get the name for.
+ */
+[[maybe_unused]] static const char* enumValueToString(AtomLocality enumValue)
+{
+ static constexpr gmx::EnumerationArray<AtomLocality, const char*> atomLocalityNames = {
+ "Local", "Non-local", "All"
+ };
+ return atomLocalityNames[enumValue];
+}
/*! \brief Interaction locality indicator: local, non-local, all.
*
* Used for calls to:
/*! \brief Interaction locality indicator: local, non-local, all.
*
* Used for calls to:
Count = 2 //!< The number of interaction locality types
};
Count = 2 //!< The number of interaction locality types
};
-/*! \brief Descriptive strings for interaction localities */
-static const EnumerationArray<InteractionLocality, const char*> c_interactionLocalityNames = {
- { "local", "non-local" }
-};
+/*! \brief Get the human-friendly name for interaction localities.
+ *
+ * \param[in] enumValue The enum value to get the name for.
+ */
+[[maybe_unused]] static const char* enumValueToString(InteractionLocality enumValue)
+{
+ static constexpr gmx::EnumerationArray<InteractionLocality, const char*> interactionLocalityNames = {
+ "Local", "Non-local"
+ };
+ return interactionLocalityNames[enumValue];
+}
/*! \brief Convert atom locality to interaction locality.
*
/*! \brief Convert atom locality to interaction locality.
*
// Note, that nullptr stream is used here to indicate that the copy is not supported.
xCopyStreams_[AtomLocality::Local] = updateStream_;
xCopyStreams_[AtomLocality::NonLocal] = nonLocalStream_;
// Note, that nullptr stream is used here to indicate that the copy is not supported.
xCopyStreams_[AtomLocality::Local] = updateStream_;
xCopyStreams_[AtomLocality::NonLocal] = nonLocalStream_;
- xCopyStreams_[AtomLocality::All] = updateStream_;
+ xCopyStreams_[AtomLocality::All] = nullptr;
vCopyStreams_[AtomLocality::Local] = updateStream_;
vCopyStreams_[AtomLocality::NonLocal] = nullptr;
vCopyStreams_[AtomLocality::Local] = updateStream_;
vCopyStreams_[AtomLocality::NonLocal] = nullptr;
- vCopyStreams_[AtomLocality::All] = updateStream_;
+ vCopyStreams_[AtomLocality::All] = nullptr;
fCopyStreams_[AtomLocality::Local] = localStream_;
fCopyStreams_[AtomLocality::NonLocal] = nonLocalStream_;
fCopyStreams_[AtomLocality::Local] = localStream_;
fCopyStreams_[AtomLocality::NonLocal] = nonLocalStream_;
// This it temporary measure to make it safe to use this class in those cases.
xCopyStreams_[AtomLocality::Local] = pmeStream_;
xCopyStreams_[AtomLocality::NonLocal] = nullptr;
// This it temporary measure to make it safe to use this class in those cases.
xCopyStreams_[AtomLocality::Local] = pmeStream_;
xCopyStreams_[AtomLocality::NonLocal] = nullptr;
- xCopyStreams_[AtomLocality::All] = pmeStream_;
+ xCopyStreams_[AtomLocality::All] = nullptr;
vCopyStreams_[AtomLocality::Local] = nullptr;
vCopyStreams_[AtomLocality::NonLocal] = nullptr;
vCopyStreams_[AtomLocality::Local] = nullptr;
vCopyStreams_[AtomLocality::NonLocal] = nullptr;
void StatePropagatorDataGpu::Impl::copyCoordinatesToGpu(const gmx::ArrayRef<const gmx::RVec> h_x,
AtomLocality atomLocality)
{
void StatePropagatorDataGpu::Impl::copyCoordinatesToGpu(const gmx::ArrayRef<const gmx::RVec> h_x,
AtomLocality atomLocality)
{
- GMX_ASSERT(atomLocality < AtomLocality::Count, "Wrong atom locality.");
+ GMX_ASSERT(atomLocality < AtomLocality::All,
+ formatString("Wrong atom locality. Only Local and NonLocal are allowed for "
+ "coordinate transfers, passed value is \"%s\"",
+ enumValueToString(atomLocality))
+ .c_str());
+
const DeviceStream* deviceStream = xCopyStreams_[atomLocality];
GMX_ASSERT(deviceStream != nullptr,
"No stream is valid for copying positions with given atom locality.");
const DeviceStream* deviceStream = xCopyStreams_[atomLocality];
GMX_ASSERT(deviceStream != nullptr,
"No stream is valid for copying positions with given atom locality.");
void StatePropagatorDataGpu::Impl::copyCoordinatesFromGpu(gmx::ArrayRef<gmx::RVec> h_x, AtomLocality atomLocality)
{
void StatePropagatorDataGpu::Impl::copyCoordinatesFromGpu(gmx::ArrayRef<gmx::RVec> h_x, AtomLocality atomLocality)
{
- GMX_ASSERT(atomLocality < AtomLocality::Count, "Wrong atom locality.");
+ GMX_ASSERT(atomLocality < AtomLocality::All,
+ formatString("Wrong atom locality. Only Local and NonLocal are allowed for "
+ "coordinate transfers, passed value is \"%s\"",
+ enumValueToString(atomLocality))
+ .c_str());
const DeviceStream* deviceStream = xCopyStreams_[atomLocality];
GMX_ASSERT(deviceStream != nullptr,
"No stream is valid for copying positions with given atom locality.");
const DeviceStream* deviceStream = xCopyStreams_[atomLocality];
GMX_ASSERT(deviceStream != nullptr,
"No stream is valid for copying positions with given atom locality.");
void StatePropagatorDataGpu::Impl::copyVelocitiesToGpu(const gmx::ArrayRef<const gmx::RVec> h_v,
AtomLocality atomLocality)
{
void StatePropagatorDataGpu::Impl::copyVelocitiesToGpu(const gmx::ArrayRef<const gmx::RVec> h_v,
AtomLocality atomLocality)
{
- GMX_ASSERT(atomLocality < AtomLocality::Count, "Wrong atom locality.");
+ GMX_ASSERT(atomLocality == AtomLocality::Local,
+ formatString("Wrong atom locality. Only Local is allowed for "
+ "velocity transfers, passed value is \"%s\"",
+ enumValueToString(atomLocality))
+ .c_str());
const DeviceStream* deviceStream = vCopyStreams_[atomLocality];
GMX_ASSERT(deviceStream != nullptr,
"No stream is valid for copying velocities with given atom locality.");
const DeviceStream* deviceStream = vCopyStreams_[atomLocality];
GMX_ASSERT(deviceStream != nullptr,
"No stream is valid for copying velocities with given atom locality.");
void StatePropagatorDataGpu::Impl::copyVelocitiesFromGpu(gmx::ArrayRef<gmx::RVec> h_v, AtomLocality atomLocality)
{
void StatePropagatorDataGpu::Impl::copyVelocitiesFromGpu(gmx::ArrayRef<gmx::RVec> h_v, AtomLocality atomLocality)
{
- GMX_ASSERT(atomLocality < AtomLocality::Count, "Wrong atom locality.");
+ GMX_ASSERT(atomLocality == AtomLocality::Local,
+ formatString("Wrong atom locality. Only Local is allowed for "
+ "velocity transfers, passed value is \"%s\"",
+ enumValueToString(atomLocality))
+ .c_str());
const DeviceStream* deviceStream = vCopyStreams_[atomLocality];
GMX_ASSERT(deviceStream != nullptr,
"No stream is valid for copying velocities with given atom locality.");
const DeviceStream* deviceStream = vCopyStreams_[atomLocality];
GMX_ASSERT(deviceStream != nullptr,
"No stream is valid for copying velocities with given atom locality.");