11 #if defined(__APPLE__) || defined(__MACOSX) 12 #include <OpenCL/cl.h> 23 #if AF_API_VERSION >= 33 33 #if AF_API_VERSION >= 33 80 #if AF_API_VERSION >= 32 90 #if AF_API_VERSION >= 33 108 #if AF_API_VERSION >= 33 118 #if AF_API_VERSION >= 33 133 #if AF_API_VERSION >= 33 140 #if AF_API_VERSION >= 33 195 static inline cl_command_queue
getQueue(
bool retain =
false)
197 cl_command_queue queue;
216 #if AF_API_VERSION >= 32 229 #if AF_API_VERSION >= 33 244 static inline void addDevice(cl_device_id dev, cl_context ctx, cl_command_queue que)
251 #if AF_API_VERSION >= 33 258 static inline void setDevice(cl_device_id dev, cl_context ctx)
265 #if AF_API_VERSION >= 33 285 #if AF_API_VERSION >= 33 290 #if AF_API_VERSION >= 33 303 #if AF_API_VERSION >= 33 329 const unsigned ndims = (unsigned)idims.
ndims();
333 cl_int clerr = clGetMemObjectInfo(buf, CL_MEM_CONTEXT,
sizeof(cl_context), &context, NULL);
334 if (clerr != CL_SUCCESS) {
335 throw af::exception(
"Failed to get context from cl_mem object \"buf\" ");
339 throw(
af::exception(
"Context mismatch between input \"buf\" and arrayfire"));
343 if (retain) clerr = clRetainMemObject(buf);
348 if (err !=
AF_SUCCESS || clerr != CL_SUCCESS) {
349 if (retain && clerr == CL_SUCCESS) clReleaseMemObject(buf);
368 cl_mem buf,
af::dtype type,
bool retain=
false)
386 cl_mem buf,
af::dtype type,
bool retain=
false)
406 cl_mem buf,
af::dtype type,
bool retain=
false)
427 cl_mem buf,
af::dtype type,
bool retain=
false)
Definition: exception.h:19
AFAPI af_err afcl_set_device_context(cl_device_id dev, cl_context ctx)
Set active device using cl_context and cl_device_id.
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:425
The function returned successfully.
Definition: defines.h:67
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.
AFAPI af_err afcl_add_device_context(cl_device_id dev, cl_context ctx, cl_command_queue que)
Push user provided device control constructs into the ArrayFire device manager pool.
static cl_device_id getDeviceId()
Get the device ID for ArrayFire's current active device.
Definition: opencl.h:207
static platform getPlatform()
Get a vendor enumeration for the current platform.
Definition: opencl.h:307
afcl_device_type deviceType
Definition: opencl.h:286
static void deleteDevice(cl_device_id dev, cl_context ctx)
Remove the user provided device control constructs from the ArrayFire device manager pool...
Definition: opencl.h:277
A multi dimensional data container.
Definition: array.h:27
afcl_platform
Definition: opencl.h:34
AFAPI af_err afcl_get_platform(afcl_platform *res)
Get the platform of the current device.
AFAPI af_err afcl_get_context(cl_context *ctx, const bool retain)
Get a handle to ArrayFire's OpenCL context.
static void addDevice(cl_device_id dev, cl_context ctx, cl_command_queue que)
Push user provided device control constructs into the ArrayFire device manager pool.
Definition: opencl.h:244
af_err
Definition: defines.h:63
static deviceType getDeviceType()
Get the type of the current device.
Definition: opencl.h:294
afcl_platform platform
Definition: opencl.h:287
dim_t * get()
Definition: dim4.hpp:46
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:179
#define AFAPI
Definition: defines.h:31
afcl_device_type
Definition: opencl.h:24
static void setDeviceId(cl_device_id id)
Set ArrayFire's active device based on id of type cl_device_id.
Definition: opencl.h:222
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:327
AFAPI af_err afcl_get_device_type(afcl_device_type *res)
Get the type of the current device.
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:222
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:195
static void setDevice(cl_device_id dev, cl_context ctx)
Set active device using cl_context and cl_device_id.
Definition: opencl.h:258
af_dtype
Definition: defines.h:195
AFAPI af_err afcl_delete_device_context(cl_device_id dev, cl_context ctx)
Remove the user provided device control constructs from the ArrayFire device manager pool...