10 #if defined(__APPLE__) || defined(__MACOSX)
11 #include <OpenCL/cl.h>
56 #if AF_API_VERSION >= 32
116 static inline cl_command_queue
getQueue(
bool retain =
false)
118 cl_command_queue queue;
137 #if AF_API_VERSION >= 32
163 const unsigned ndims = (unsigned)idims.
ndims();
167 cl_int clerr = clGetMemObjectInfo(buf, CL_MEM_CONTEXT,
sizeof(cl_context), &context, NULL);
168 if (clerr != CL_SUCCESS) {
169 throw af::exception(
"Failed to get context from cl_mem object \"buf\" ");
173 throw(
af::exception(
"Context mismatch between input \"buf\" and arrayfire"));
177 if (retain) clerr = clRetainMemObject(buf);
182 if (err !=
AF_SUCCESS || clerr != CL_SUCCESS) {
183 if (retain && clerr == CL_SUCCESS) clReleaseMemObject(buf);
202 cl_mem buf,
af::dtype type,
bool retain=
false)
220 cl_mem buf,
af::dtype type,
bool retain=
false)
240 cl_mem buf,
af::dtype type,
bool retain=
false)
261 cl_mem buf,
af::dtype type,
bool retain=
false)
277 cl_mem *mem =
new cl_mem;
Definition: exception.h:19
static af::array array(dim_t dim0, dim_t dim1, dim_t dim2, dim_t dim3, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:259
Definition: algorithm.h:14
AFAPI af_err af_get_device_ptr(void **ptr, const af_array arr)
Get the device pointer and lock the buffer in memory manager.
The function returned successfully.
Definition: defines.h:71
AFAPI af_err afcl_get_queue(cl_command_queue *queue, const bool retain)
Get a handle to ArrayFire's OpenCL command queue.
AFAPI af_err afcl_get_device_id(cl_device_id *id)
Get the device ID for ArrayFire's current active device.
static cl_device_id getDeviceId()
Get the device ID for ArrayFire's current active device.
Definition: opencl.h:128
A multi dimensional data container.
Definition: array.h:27
AFAPI af_err afcl_get_context(cl_context *ctx, const bool retain)
Get a handle to ArrayFire's OpenCL context.
af_err
Definition: defines.h:67
dim_t * get()
Definition: dim4.hpp:52
long long dim_t
Definition: defines.h:50
static cl_context getContext(bool retain=false)
Get a handle to ArrayFire's OpenCL context.
Definition: opencl.h:100
#define AFAPI
Definition: defines.h:31
static void setDeviceId(cl_device_id id)
Set ArrayFire's active device based on id of type cl_device_id.
Definition: opencl.h:143
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:161
AFAPI af_err af_device_array(af_array *arr, const void *data, const unsigned ndims, const dim_t *const dims, const af_dtype type)
Create array from device memory.
void * af_array
Definition: defines.h:219
AFAPI af_err afcl_set_device_id(cl_device_id id)
Set ArrayFire's active device based on id of type cl_device_id.
static cl_command_queue getQueue(bool retain=false)
Get a handle to ArrayFire's OpenCL command queue.
Definition: opencl.h:116
af_dtype
Definition: defines.h:192