Gromacs  2019
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Functions
devicebuffer_ocl.h File Reference
#include "gromacs/gpu_utils/gpu_utils.h"
#include "gromacs/gpu_utils/gputraits_ocl.h"
#include "gromacs/utility/gmxassert.h"
+ Include dependency graph for devicebuffer_ocl.h:

Description

Implements the DeviceBuffer type and routines for OpenCL. Should only be included directly by the main DeviceBuffer file devicebuffer.h. TODO: the intent is for DeviceBuffer to become a class.

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

Classes

class  TypedClMemory< ValueType >
 A minimal cl_mem wrapper that remembers its allocation type. The only point is making template type deduction possible. More...
 

Typedefs

template<typename ValueType >
using DeviceBuffer = TypedClMemory< ValueType >
 A device-side buffer of ValueTypes.
 

Functions

template<typename ValueType >
void allocateDeviceBuffer (DeviceBuffer< ValueType > *buffer, size_t numValues, Context context)
 Allocates a device-side buffer. It is currently a caller's responsibility to call it only on not-yet allocated buffers. More...
 
template<typename DeviceBuffer >
void freeDeviceBuffer (DeviceBuffer *buffer)
 Frees a device-side buffer. This does not reset separately stored size/capacity integers, as this is planned to be a destructor of DeviceBuffer as a proper class, and no calls on buffer should be made afterwards. More...
 
template<typename ValueType >
void copyToDeviceBuffer (DeviceBuffer< ValueType > *buffer, const ValueType *hostBuffer, size_t startingOffset, size_t numValues, CommandStream stream, GpuApiCallBehavior transferKind, CommandEvent *timingEvent)
 Performs the host-to-device data copy, synchronous or asynchronously on request. More...
 
template<typename ValueType >
void copyFromDeviceBuffer (ValueType *hostBuffer, DeviceBuffer< ValueType > *buffer, size_t startingOffset, size_t numValues, CommandStream stream, GpuApiCallBehavior transferKind, CommandEvent *timingEvent)
 Performs the device-to-host data copy, synchronous or asynchronously on request. More...
 
template<typename ValueType >
void clearDeviceBufferAsync (DeviceBuffer< ValueType > *buffer, size_t startingOffset, size_t numValues, CommandStream stream)
 Clears the device buffer asynchronously. More...
 

Function Documentation

template<typename ValueType >
void allocateDeviceBuffer ( DeviceBuffer< ValueType > *  buffer,
size_t  numValues,
Context  context 
)

Allocates a device-side buffer. It is currently a caller's responsibility to call it only on not-yet allocated buffers.

Template Parameters
ValueTypeRaw value type of the buffer.
Parameters
[in,out]bufferPointer to the device-side buffer.
[in]numValuesNumber of values to accomodate.
[in]contextThe buffer's context-to-be.
template<typename ValueType >
void clearDeviceBufferAsync ( DeviceBuffer< ValueType > *  buffer,
size_t  startingOffset,
size_t  numValues,
CommandStream  stream 
)

Clears the device buffer asynchronously.

Template Parameters
ValueTypeRaw value type of the buffer.
Parameters
[in,out]bufferPointer to the device-side buffer
[in]startingOffsetOffset (in values) at the device-side buffer to start clearing at.
[in]numValuesNumber of values to clear.
[in]streamGPU stream.
template<typename ValueType >
void copyFromDeviceBuffer ( ValueType *  hostBuffer,
DeviceBuffer< ValueType > *  buffer,
size_t  startingOffset,
size_t  numValues,
CommandStream  stream,
GpuApiCallBehavior  transferKind,
CommandEvent timingEvent 
)

Performs the device-to-host data copy, synchronous or asynchronously on request.

TODO: This is meant to gradually replace cu/ocl_copy_d2h.

Template Parameters
ValueTypeRaw value type of the buffer.
Parameters
[in,out]hostBufferPointer to the raw host-side memory, also typed ValueType
[in]bufferPointer to the device-side buffer
[in]startingOffsetOffset (in values) at the device-side buffer to copy from.
[in]numValuesNumber of values to copy.
[in]streamGPU stream to perform asynchronous copy in.
[in]transferKindCopy type: synchronous or asynchronous.
[out]timingEventA pointer to the H2D copy timing event to be filled in. If the pointer is not null, the event can further be used to queue a wait for this operation or to query profiling information.
template<typename ValueType >
void copyToDeviceBuffer ( DeviceBuffer< ValueType > *  buffer,
const ValueType *  hostBuffer,
size_t  startingOffset,
size_t  numValues,
CommandStream  stream,
GpuApiCallBehavior  transferKind,
CommandEvent timingEvent 
)

Performs the host-to-device data copy, synchronous or asynchronously on request.

TODO: This is meant to gradually replace cu/ocl_copy_h2d.

Template Parameters
ValueTypeRaw value type of the buffer.
Parameters
[in,out]bufferPointer to the device-side buffer
[in]hostBufferPointer to the raw host-side memory, also typed ValueType
[in]startingOffsetOffset (in values) at the device-side buffer to copy into.
[in]numValuesNumber of values to copy.
[in]streamGPU stream to perform asynchronous copy in.
[in]transferKindCopy type: synchronous or asynchronous.
[out]timingEventA pointer to the H2D copy timing event to be filled in. If the pointer is not null, the event can further be used to queue a wait for this operation or to query profiling information.
template<typename DeviceBuffer >
void freeDeviceBuffer ( DeviceBuffer buffer)

Frees a device-side buffer. This does not reset separately stored size/capacity integers, as this is planned to be a destructor of DeviceBuffer as a proper class, and no calls on buffer should be made afterwards.

Parameters
[in]bufferPointer to the buffer to free.