11 #ifndef CL_TARGET_OPENCL_VERSION 12 #define CL_TARGET_OPENCL_VERSION 120 14 #if defined(__APPLE__) || defined(__MACOSX) 15 #include <OpenCL/cl.h> 26 #if AF_API_VERSION >= 33 36 #if AF_API_VERSION >= 33 83 #if AF_API_VERSION >= 32 93 #if AF_API_VERSION >= 33 111 #if AF_API_VERSION >= 33 121 #if AF_API_VERSION >= 33 136 #if AF_API_VERSION >= 33 143 #if AF_API_VERSION >= 33 198 static inline cl_command_queue
getQueue(
bool retain =
false)
200 cl_command_queue queue;
219 #if AF_API_VERSION >= 32 232 #if AF_API_VERSION >= 33 247 static inline void addDevice(cl_device_id dev, cl_context ctx, cl_command_queue que)
254 #if AF_API_VERSION >= 33 261 static inline void setDevice(cl_device_id dev, cl_context ctx)
268 #if AF_API_VERSION >= 33 288 #if AF_API_VERSION >= 33 293 #if AF_API_VERSION >= 33 306 #if AF_API_VERSION >= 33 332 const unsigned ndims = (unsigned)idims.
ndims();
336 cl_int clerr = clGetMemObjectInfo(buf, CL_MEM_CONTEXT,
sizeof(cl_context), &context, NULL);
337 if (clerr != CL_SUCCESS) {
338 throw af::exception(
"Failed to get context from cl_mem object \"buf\" ");
342 throw(
af::exception(
"Context mismatch between input \"buf\" and arrayfire"));
346 if (retain) clerr = clRetainMemObject(buf);
351 if (err !=
AF_SUCCESS || clerr != CL_SUCCESS) {
352 if (retain && clerr == CL_SUCCESS) clReleaseMemObject(buf);
371 cl_mem buf,
af::dtype type,
bool retain=
false)
389 cl_mem buf,
af::dtype type,
bool retain=
false)
409 cl_mem buf,
af::dtype type,
bool retain=
false)
430 cl_mem buf,
af::dtype type,
bool retain=
false)
An ArrayFire exception class.
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
The function returned successfully.
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.
static platform getPlatform()
Get a vendor enumeration for the current platform.
afcl_device_type deviceType
static void deleteDevice(cl_device_id dev, cl_context ctx)
Remove the user provided device control constructs from the ArrayFire device manager pool...
A multi dimensional data container.
AFAPI af_err af_device_array(af_array *arr, void *data, const unsigned ndims, const dim_t *const dims, const af_dtype type)
Create array from device memory.
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.
static deviceType getDeviceType()
Get the type of the current device.
dim_t * get()
Returns the underlying pointer to the dim4 object.
static cl_context getContext(bool retain=false)
Get a handle to ArrayFire's OpenCL context
dim_t ndims()
Returns the number of axis whose values are greater than one.
static void setDeviceId(cl_device_id id)
Set ArrayFire's active device based on id of type cl_device_id.
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
AFAPI af_err afcl_get_device_type(afcl_device_type *res)
Get the type of the current device.
AFAPI af_err afcl_set_device_id(cl_device_id id)
Set ArrayFire's active device based on id of type cl_device_id.
Generic object that represents size and shape.
static cl_command_queue getQueue(bool retain=false)
Get a handle to ArrayFire's OpenCL command queue
static void setDevice(cl_device_id dev, cl_context ctx)
Set active device using cl_context and cl_device_id.
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...