11#if defined(__APPLE__) || defined(__MACOSX)
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
197 static inline cl_command_queue
getQueue(
bool retain =
false)
199 cl_command_queue queue;
218#if AF_API_VERSION >= 32
231#if AF_API_VERSION >= 33
246static inline void addDevice(cl_device_id dev, cl_context ctx, cl_command_queue que)
253#if AF_API_VERSION >= 33
260static inline void setDevice(cl_device_id dev, cl_context ctx)
267#if AF_API_VERSION >= 33
287#if AF_API_VERSION >= 33
292#if AF_API_VERSION >= 33
305#if AF_API_VERSION >= 33
331 const unsigned ndims = (unsigned)idims.
ndims();
335 cl_int clerr = clGetMemObjectInfo(buf, CL_MEM_CONTEXT,
sizeof(cl_context), &context, NULL);
336 if (clerr != CL_SUCCESS) {
337 throw af::exception(
"Failed to get context from cl_mem object \"buf\" ");
341 throw(
af::exception(
"Context mismatch between input \"buf\" and arrayfire"));
345 if (retain) clerr = clRetainMemObject(buf);
350 if (err !=
AF_SUCCESS || clerr != CL_SUCCESS) {
351 if (retain && clerr == CL_SUCCESS) clReleaseMemObject(buf);
370 cl_mem buf,
af::dtype type,
bool retain=
false)
388 cl_mem buf,
af::dtype type,
bool retain=
false)
408 cl_mem buf,
af::dtype type,
bool retain=
false)
429 cl_mem buf,
af::dtype type,
bool retain=
false)
442#if !defined(AF_OPENCL)
A multi dimensional data container.
Definition array.h:27
dim_t * get()
Definition dim4.hpp:52
Definition exception.h:20
af_dtype
Definition defines.h:195
long long dim_t
Definition defines.h:50
af_err
Definition defines.h:63
@ AF_SUCCESS
The function returned successfully.
Definition defines.h:67
void * af_array
Definition defines.h:222
#define AFAPI
Definition defines.h:31
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.
AFAPI af_err af_get_device_ptr(void **ptr, const af_array arr)
Get the device pointer and lock the buffer in memory manager.
af_array get()
get the af_array handle
static cl_context getContext(bool retain=false)
Get a handle to ArrayFire's OpenCL context.
Definition opencl.h:181
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.
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.
AFAPI af_err afcl_get_platform(afcl_platform *res)
Get the platform of the current device.
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.
AFAPI af_err afcl_set_device_context(cl_device_id dev, cl_context ctx)
Set active device using cl_context and cl_device_id.
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_context(cl_context *ctx, const bool retain)
Get a handle to ArrayFire's OpenCL context.
AFAPI af_err afcl_get_device_id(cl_device_id *id)
Get the device ID for ArrayFire's current active device.
AFAPI array sum(const array &in, const int dim=-1)
C++ Interface for sum of elements in an array.
Definition algorithm.h:15
afcl_platform platform
Definition opencl.h:289
static void setDeviceId(cl_device_id id)
Set ArrayFire's active device based on id of type cl_device_id.
Definition opencl.h:224
static void setDevice(cl_device_id dev, cl_context ctx)
Set active device using cl_context and cl_device_id.
Definition opencl.h:260
static platform getPlatform()
Get the type of the current device.
Definition opencl.h:309
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:279
static cl_command_queue getQueue(bool retain=false)
Get a handle to ArrayFire's OpenCL command queue.
Definition opencl.h:197
static deviceType getDeviceType()
Get the type of the current device.
Definition opencl.h:296
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:329
static cl_device_id getDeviceId()
Get the device ID for ArrayFire's current active device.
Definition opencl.h:209
afcl_device_type deviceType
Definition opencl.h:288
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:246
afcl_device_type
Definition opencl.h:25
@ AFCL_DEVICE_TYPE_CPU
Definition opencl.h:26
@ AFCL_DEVICE_TYPE_ACC
Definition opencl.h:28
@ AFCL_DEVICE_TYPE_UNKNOWN
Definition opencl.h:29
@ AFCL_DEVICE_TYPE_GPU
Definition opencl.h:27
afcl_platform
Definition opencl.h:35
@ AFCL_PLATFORM_POCL
Definition opencl.h:41
@ AFCL_PLATFORM_BEIGNET
Definition opencl.h:40
@ AFCL_PLATFORM_INTEL
Definition opencl.h:38
@ AFCL_PLATFORM_NVIDIA
Definition opencl.h:39
@ AFCL_PLATFORM_APPLE
Definition opencl.h:37
@ AFCL_PLATFORM_UNKNOWN
Definition opencl.h:42
@ AFCL_PLATFORM_AMD
Definition opencl.h:36