Accessing ArrayFire's context, queue, and share data with other OpenCL code. More...

static cl_context getContext (bool retain=false)
 Get a handle to ArrayFire's OpenCL context. More...
 
static cl_command_queue getQueue (bool retain=false)
 Get a handle to ArrayFire's OpenCL command queue. More...
 
static cl_device_id getDeviceId ()
 Get the device ID for ArrayFire's current active device. More...
 
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. More...
 
static af::array array (dim_t dim0, cl_mem buf, af::dtype type, bool retain=false)
 Create an af::array object from an OpenCL cl_mem buffer. More...
 
static af::array array (dim_t dim0, dim_t dim1, cl_mem buf, af::dtype type, bool retain=false)
 Create an af::array object from an OpenCL cl_mem buffer. More...
 
static af::array array (dim_t dim0, dim_t dim1, dim_t dim2, cl_mem buf, af::dtype type, bool retain=false)
 Create an af::array object from an OpenCL cl_mem buffer. More...
 
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. More...
 

Detailed Description

Accessing ArrayFire's context, queue, and share data with other OpenCL code.

If your software is using ArrayFire's OpenCL backend, you can also write custom kernels and do custom memory operations using native OpenCL commands. The functions contained in the afcl namespace provide methods to get the context, queue, and device(s) that ArrayFire is using as well as convert cl_mem handles to af::array objects.

Please note: the af::array constructors are not thread safe. You may create and upload data to cl_mem objects from separate threads, but the thread which instantiated ArrayFire must do the cl_mem to af::array conversion.

Function Documentation

static af::array afcl::array ( af::dim4  idims,
cl_mem  buf,
af::dtype  type,
bool  retain = false 
)
inlinestatic

Create an af::array object from an OpenCL cl_mem buffer.

Parameters
[in]idimsthe dimensions of the buffer
[in]bufthe OpenCL memory object
[in]typethe data type contained in the buffer
[in]retainif true, instructs ArrayFire to retain the memory object
Returns
an array object created from the OpenCL buffer
Note
Set retain to true if the memory originates from a cl::Buffer object
Examples:
brain_segmentation.cpp, histogram.cpp, image_demo.cpp, integer.cpp, morphing.cpp, and optical_flow.cpp.
static af::array afcl::array ( dim_t  dim0,
cl_mem  buf,
af::dtype  type,
bool  retain = false 
)
inlinestatic

Create an af::array object from an OpenCL cl_mem buffer.

Parameters
[in]dim0the length of the first dimension of the buffer
[in]bufthe OpenCL memory object
[in]typethe data type contained in the buffer
[in]retainif true, instructs ArrayFire to retain the memory object
Returns
an array object created from the OpenCL buffer
Note
Set retain to true if the memory originates from a cl::Buffer object
static af::array afcl::array ( dim_t  dim0,
dim_t  dim1,
cl_mem  buf,
af::dtype  type,
bool  retain = false 
)
inlinestatic

Create an af::array object from an OpenCL cl_mem buffer.

Parameters
[in]dim0the length of the first dimension of the buffer
[in]dim1the length of the second dimension of the buffer
[in]bufthe OpenCL memory object
[in]typethe data type contained in the buffer
[in]retainif true, instructs ArrayFire to retain the memory object
Returns
an array object created from the OpenCL buffer
Note
Set retain to true if the memory originates from a cl::Buffer object
static af::array afcl::array ( dim_t  dim0,
dim_t  dim1,
dim_t  dim2,
cl_mem  buf,
af::dtype  type,
bool  retain = false 
)
inlinestatic

Create an af::array object from an OpenCL cl_mem buffer.

Parameters
[in]dim0the length of the first dimension of the buffer
[in]dim1the length of the second dimension of the buffer
[in]dim2the length of the third dimension of the buffer
[in]bufthe OpenCL memory object
[in]typethe data type contained in the buffer
[in]retainif true, instructs ArrayFire to retain the memory object
Returns
an array object created from the OpenCL buffer
Note
Set retain to true if the memory originates from a cl::Buffer object
static af::array afcl::array ( dim_t  dim0,
dim_t  dim1,
dim_t  dim2,
dim_t  dim3,
cl_mem  buf,
af::dtype  type,
bool  retain = false 
)
inlinestatic

Create an af::array object from an OpenCL cl_mem buffer.

Parameters
[in]dim0the length of the first dimension of the buffer
[in]dim1the length of the second dimension of the buffer
[in]dim2the length of the third dimension of the buffer
[in]dim3the length of the fourth dimension of the buffer
[in]bufthe OpenCL memory object
[in]typethe data type contained in the buffer
[in]retainif true, instructs ArrayFire to retain the memory object
Returns
an array object created from the OpenCL buffer
Note
Set retain to true if the memory originates from a cl::Buffer object
static cl_context afcl::getContext ( bool  retain = false)
inlinestatic

Get a handle to ArrayFire's OpenCL context.

Parameters
[in]retainif true calls clRetainContext prior to returning the context
Returns
the current context being used by ArrayFire
Note
Set retain to true if this value will be passed to a cl::Context constructor
static cl_device_id afcl::getDeviceId ( )
inlinestatic

Get the device ID for ArrayFire's current active device.

Returns
the cl_device_id of the current device
static cl_command_queue afcl::getQueue ( bool  retain = false)
inlinestatic

Get a handle to ArrayFire's OpenCL command queue.

Parameters
[in]retainif true calls clRetainCommandQueue prior to returning the context
Returns
the current command queue being used by ArrayFire
Note
Set retain to true if this value will be passed to a cl::CommandQueue constructor