Gromacs  2016.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Enumerations | Functions
oclutils.h File Reference
#include <CL/opencl.h>
#include <string>
+ 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

Macros

#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
 Declare to OpenCL SDKs that we intend to use OpenCL API features that were deprecated in 2.0, so that they don't warn about it.
 

Enumerations

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

Functions

cl_int dbg_ocl_kernel_name (const cl_kernel kernel)
 Prints the name of a kernel function pointer. More...
 
cl_int dbg_ocl_kernel_name_address (void *kernel)
 Prints the name of a kernel function pointer. 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_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, 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.
 

Function Documentation

cl_int dbg_ocl_kernel_name ( const cl_kernel  kernel)

Prints the name of a kernel function pointer.

Parameters
[in]kernelOpenCL kernel
Returns
CL_SUCCESS if the operation was successful, an OpenCL error otherwise.
cl_int dbg_ocl_kernel_name_address ( void *  kernel)

Prints the name of a kernel function pointer.

Parameters
[in]kernelOpenCL kernel
Returns
CL_SUCCESS if the operation was successful, an OpenCL error otherwise.
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_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.