Gromacs
2026.0-dev-20241106-9ba7f4d
|
#include "config.h"
#include "gromacs/gpu_utils/devicebuffer_datatype.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
Implements the logic for handling of DeviceBuffer types in OpenCL, CUDA and SYCL.
Can only be included on GPU build paths.
Note that most of the buffer operations have an early return, if the requested operation size is zero. This allows for calling these functions with zero operation size even when the underlying buffers were not properly initialized.
Functions | |
template<typename ValueType > | |
void | reallocateDeviceBuffer (DeviceBuffer< ValueType > *buffer, size_t numValues, int *currentNumValues, int *currentMaxNumValues, const DeviceContext &deviceContext, const bool symmetricAlloc=false) |
Reallocates the device-side buffer. More... | |
void reallocateDeviceBuffer | ( | DeviceBuffer< ValueType > * | buffer, |
size_t | numValues, | ||
int * | currentNumValues, | ||
int * | currentMaxNumValues, | ||
const DeviceContext & | deviceContext, | ||
const bool | symmetricAlloc = false |
||
) |
Reallocates the device-side buffer.
Reallocates the device-side memory pointed by buffer
. Allocation is buffered and therefore freeing is only needed if the previously allocated space is not enough. currentNumValues
and currentMaxNumValues
are updated. TODO: currentNumValues
, currentMaxNumValues
, deviceContext
should all be encapsulated in a host-side class together with the buffer.
ValueType | Raw value type of the buffer . |
[in,out] | buffer | Pointer to the device-side buffer |
[in] | numValues | Number of values to accommodate. |
[in,out] | currentNumValues | The pointer to the buffer's number of values. |
[in,out] | currentMaxNumValues | The pointer to the buffer's capacity. |
[in] | deviceContext | The buffer's device context. |
[in] | symmetricAlloc | Allocate symmetric buffer with NVSHMEM. This is a collective call when true. |