Clearing of empty buffer can cause the OpenCL/CUDA API failure.
Early return when requested size to clear is zero allows to
avoid this failure not calling the API for empty buffers.
This also makes the definition of the clearDeviceBuffer(...) in
OpenCL, CUDA similar to its definition in SYCL, where the early
return is already present.
Fixes #4002.
size_t numValues,
const DeviceStream& deviceStream)
{
+ if (numValues == 0)
+ {
+ return;
+ }
GMX_ASSERT(buffer, "needs a buffer pointer");
const size_t bytes = numValues * sizeof(ValueType);
const char pattern = 0;
size_t numValues,
const DeviceStream& deviceStream)
{
+ if (numValues == 0)
+ {
+ return;
+ }
GMX_ASSERT(buffer, "needs a buffer pointer");
const size_t offset = startingOffset * sizeof(ValueType);
const size_t bytes = numValues * sizeof(ValueType);