Gromacs
2018.7
|
#include "gmxpre.h"
#include "oclutils.h"
#include <stdlib.h>
#include <cassert>
#include <cstdio>
#include <string>
#include "gromacs/gpu_utils/gpu_utils.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
Define utility routines for OpenCL.
Functions | |
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. | |
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... | |
void | ocl_pmalloc (void **h_ptr, size_t nbytes) |
Allocates nbytes of host memory. Use ocl_free to free memory allocated with this function. More... | |
void | ocl_pfree (void *h_ptr) |
Frees memory allocated with ocl_pmalloc. More... | |
std::string | ocl_get_error_string (cl_int error) |
Convert error code to diagnostic string. | |
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 | ) |
Frees memory allocated with ocl_pmalloc.
Free host memory in malloc style.
[in] | h_ptr | Buffer allocated with ocl_pmalloc that needs to be freed. |
void ocl_pmalloc | ( | void ** | h_ptr, |
size_t | nbytes | ||
) |
Allocates nbytes of host memory. Use ocl_free to free memory allocated with this function.
Allocate host memory in malloc style.
[in,out] | h_ptr | Pointer where to store the address of the newly allocated buffer. |
[in] | nbytes | Size in bytes of the buffer to be allocated. |