Gromacs  2022.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
devicebuffer.h File Reference
#include "config.h"
#include "gromacs/gpu_utils/devicebuffer_datatype.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
+ Include dependency graph for devicebuffer.h:
+ This graph shows which files directly or indirectly include this file:

Description

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.

Author
Aleksei Iupinov a.yup.nosp@m.inov.nosp@m.@gmai.nosp@m.l.co.nosp@m.m

Functions

template<typename ValueType >
void reallocateDeviceBuffer (DeviceBuffer< ValueType > *buffer, size_t numValues, int *currentNumValues, int *currentMaxNumValues, const DeviceContext &deviceContext)
 Reallocates the device-side buffer. More...
 

Function Documentation

template<typename ValueType >
void reallocateDeviceBuffer ( DeviceBuffer< ValueType > *  buffer,
size_t  numValues,
int *  currentNumValues,
int *  currentMaxNumValues,
const DeviceContext &  deviceContext 
)

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.

Template Parameters
ValueTypeRaw value type of the buffer.
Parameters
[in,out]bufferPointer to the device-side buffer
[in]numValuesNumber of values to accommodate.
[in,out]currentNumValuesThe pointer to the buffer's number of values.
[in,out]currentMaxNumValuesThe pointer to the buffer's capacity.
[in]deviceContextThe buffer's device context.