Gromacs  2018.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Enumerations | Functions
oclutils.h File Reference
#include <string>
#include "gromacs/gpu_utils/gmxopencl.h"
#include "gromacs/utility/gmxassert.h"
+ Include dependency graph for oclutils.h:
+ This graph shows which files directly or indirectly include this file:

Description

Declare utility routines for OpenCL.

Author
Anca Hamuraru anca@.nosp@m.stre.nosp@m.amcom.nosp@m.puti.nosp@m.ng.eu

Classes

struct  ocl_gpu_id_t
 OpenCL GPU device identificator. More...
 
struct  gmx_device_info_t
 OpenCL device information. More...
 
struct  gmx_device_runtime_data_t
 OpenCL GPU runtime data. More...
 

Enumerations

enum  ocl_vendor_id_t { OCL_VENDOR_NVIDIA = 0, OCL_VENDOR_AMD, OCL_VENDOR_INTEL, OCL_VENDOR_UNKNOWN }
 OpenCL vendor IDs.
 

Functions

int ocl_copy_D2H (void *h_dest, cl_mem d_src, size_t offset, size_t bytes, GpuApiCallBehavior transferKind, cl_command_queue command_queue, cl_event *copy_event)
 Launches synchronous or asynchronous device to host memory copy. More...
 
int ocl_copy_D2H_async (void *h_dest, cl_mem d_src, size_t offset, size_t bytes, cl_command_queue command_queue, cl_event *copy_event)
 Launches asynchronous device to host memory copy. More...
 
int ocl_copy_H2D (cl_mem d_dest, void *h_src, size_t offset, size_t bytes, GpuApiCallBehavior transferKind, cl_command_queue command_queue, cl_event *copy_event)
 Launches synchronous or asynchronous host to device memory copy. More...
 
int ocl_copy_H2D_async (cl_mem d_dest, void *h_src, size_t offset, size_t bytes, cl_command_queue command_queue, cl_event *copy_event)
 Launches asynchronous host to device memory copy. More...
 
int ocl_copy_H2D_sync (cl_mem d_dest, void *h_src, size_t offset, size_t bytes, cl_command_queue command_queue)
 Launches synchronous host to device memory copy.
 
void ocl_pmalloc (void **h_ptr, size_t nbytes)
 Allocate host memory in malloc style. More...
 
void ocl_pfree (void *h_ptr)
 Free host memory in malloc style. More...
 
std::string ocl_get_error_string (cl_int error)
 Convert error code to diagnostic string.
 
static void gpuStreamSynchronize (cl_command_queue s)
 Calls clFinish() in the stream s. More...
 
static bool haveStreamTasksCompleted (cl_command_queue s)
 Pretend to synchronize an OpenCL stream (dummy implementation). More...
 

Function Documentation

static void gpuStreamSynchronize ( cl_command_queue  s)
inlinestatic

Calls clFinish() in the stream s.

Parameters
[in]sstream to synchronize with
static bool haveStreamTasksCompleted ( cl_command_queue  s)
inlinestatic

Pretend to synchronize an OpenCL stream (dummy implementation).

Parameters
[in]squeue to check
Returns
True if all tasks enqueued in the stream s (at the time of this call) have completed.
int ocl_copy_D2H ( void *  h_dest,
cl_mem  d_src,
size_t  offset,
size_t  bytes,
GpuApiCallBehavior  transferKind,
cl_command_queue  command_queue,
cl_event *  copy_event 
)

Launches synchronous or asynchronous device to host memory copy.

If copy_event is not NULL, on return it will contain an event object identifying this particular device to host operation. The event can further be used to queue a wait for this operation or to query profiling information.

int ocl_copy_D2H_async ( void *  h_dest,
cl_mem  d_src,
size_t  offset,
size_t  bytes,
cl_command_queue  command_queue,
cl_event *  copy_event 
)

Launches asynchronous device to host memory copy.

If copy_event is not NULL, on return it will contain an event object identifying this particular host to device operation. The event can further be used to queue a wait for this operation or to query profiling information.

int ocl_copy_H2D ( cl_mem  d_dest,
void *  h_src,
size_t  offset,
size_t  bytes,
GpuApiCallBehavior  transferKind,
cl_command_queue  command_queue,
cl_event *  copy_event 
)

Launches synchronous or asynchronous host to device memory copy.

If copy_event is not NULL, on return it will contain an event object identifying this particular host to device operation. The event can further be used to queue a wait for this operation or to query profiling information.

int ocl_copy_H2D_async ( cl_mem  d_dest,
void *  h_src,
size_t  offset,
size_t  bytes,
cl_command_queue  command_queue,
cl_event *  copy_event 
)

Launches asynchronous host to device memory copy.

If copy_event is not NULL, on return it will contain an event object identifying this particular host to device operation. The event can further be used to queue a wait for this operation or to query profiling information.

void ocl_pfree ( void *  h_ptr)

Free host memory in malloc style.

Free host memory in malloc style.

Parameters
[in]h_ptrBuffer allocated with ocl_pmalloc that needs to be freed.
void ocl_pmalloc ( void **  h_ptr,
size_t  nbytes 
)

Allocate host memory in malloc style.

Allocate host memory in malloc style.

Todo:
This function should allocate page-locked memory to help reduce D2H and H2D transfer times, similar with pmalloc from pmalloc_cuda.cu.
Parameters
[in,out]h_ptrPointer where to store the address of the newly allocated buffer.
[in]nbytesSize in bytes of the buffer to be allocated.