Accessing ArrayFire's context, queue, and share data with other OpenCL code. More...
Typedefs | |
typedef afcl_device_type | deviceType |
typedef afcl_platform | platform |
Functions | |
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 void | setDeviceId (cl_device_id id) |
Set ArrayFire's active device based on id of type cl_device_id. More... | |
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. More... | |
static void | setDevice (cl_device_id dev, cl_context ctx) |
Set active device using cl_context and cl_device_id. More... | |
static void | deleteDevice (cl_device_id dev, cl_context ctx) |
Remove the user provided device control constructs from the ArrayFire device manager pool. More... | |
static deviceType | getDeviceType () |
Get the type of the current device. More... | |
static platform | getPlatform () |
Get a vendor enumeration for the current platform. 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... | |
AFAPI af_err | afcl_get_context (cl_context *ctx, const bool retain) |
Get a handle to ArrayFire's OpenCL context. More... | |
AFAPI af_err | afcl_get_queue (cl_command_queue *queue, const bool retain) |
Get a handle to ArrayFire's OpenCL command queue. More... | |
AFAPI af_err | afcl_get_device_id (cl_device_id *id) |
Get the device ID for ArrayFire's current active device. More... | |
AFAPI af_err | afcl_set_device_id (cl_device_id id) |
Set ArrayFire's active device based on id of type cl_device_id. More... | |
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. More... | |
AFAPI af_err | afcl_set_device_context (cl_device_id dev, cl_context ctx) |
Set active device using cl_context and cl_device_id. More... | |
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. More... | |
AFAPI af_err | afcl_get_device_type (afcl_device_type *res) |
Get the type of the current device. More... | |
AFAPI af_err | afcl_get_platform (afcl_platform *res) |
Get the platform of the current device. More... | |
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.
typedef afcl_device_type deviceType |
typedef afcl_platform platform |
|
inlinestatic |
Push user provided device control constructs into the ArrayFire device manager pool.
This function should be used only when the user would like ArrayFire to use an user generated OpenCL context and related objects for ArrayFire operations.
[in] | dev | is the OpenCL device for which user provided context will be used by ArrayFire |
[in] | ctx | is the user provided OpenCL cl_context to be used by ArrayFire |
[in] | que | is the user provided OpenCL cl_command_queue to be used by ArrayFire. If this parameter is NULL, then we create a command queue for the user using the OpenCL context they provided us. |
Definition at line 247 of file opencl.h.
Push user provided device control constructs into the ArrayFire device manager pool.
This function should be used only when the user would like ArrayFire to use an user generated OpenCL context and related objects for ArrayFire operations.
[in] | dev | is the OpenCL device for which user provided context will be used by ArrayFire |
[in] | ctx | is the user provided OpenCL cl_context to be used by ArrayFire |
[in] | que | is the user provided OpenCL cl_command_queue to be used by ArrayFire. If this parameter is NULL, then we create a command queue for the user using the OpenCL context they provided us. |
Remove the user provided device control constructs from the ArrayFire device manager pool.
This function should be used only when the user would like ArrayFire to remove an already pushed user generated OpenCL context and related objects.
[in] | dev | is the OpenCL device id that has to be popped |
[in] | ctx | is the cl_context object to be removed from ArrayFire pool |
Get a handle to ArrayFire's OpenCL context.
[out] | ctx | the current context being used by ArrayFire |
[in] | retain | if true calls clRetainContext prior to returning the context |
retain
to true if this value will be passed to a cl::Context constructor Get the device ID for ArrayFire's current active device.
[out] | id | the cl_device_id 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_get_platform | ( | afcl_platform * | res | ) |
Get the platform of the current device.
Get a handle to ArrayFire's OpenCL command queue.
[out] | queue | the current command queue being used by ArrayFire |
[in] | retain | if true calls clRetainCommandQueue prior to returning the context |
retain
to true if this value will be passed to a cl::CommandQueue constructor Set active device using cl_context and cl_device_id.
[in] | dev | is the OpenCL device id that is to be set as Active device inside ArrayFire |
[in] | ctx | is the OpenCL cl_context being used by ArrayFire |
Set ArrayFire's active device based on id
of type cl_device_id.
[in] | id | the cl_device_id of the device to be set as active device |
|
inlinestatic |
Create an af::array object from an OpenCL cl_mem buffer.
[in] | idims | the dimensions of the buffer |
[in] | buf | the OpenCL memory object |
[in] | type | the data type contained in the buffer |
[in] | retain | if true, instructs ArrayFire to retain the memory object |
retain
to true if the memory originates from a cl::Buffer object Definition at line 330 of file opencl.h.
Create an af::array object from an OpenCL cl_mem buffer.
[in] | dim0 | the length of the first dimension of the buffer |
[in] | buf | the OpenCL memory object |
[in] | type | the data type contained in the buffer |
[in] | retain | if true, instructs ArrayFire to retain the memory object |
retain
to true if the memory originates from a cl::Buffer object Definition at line 370 of file opencl.h.
|
inlinestatic |
Create an af::array object from an OpenCL cl_mem buffer.
[in] | dim0 | the length of the first dimension of the buffer |
[in] | dim1 | the length of the second dimension of the buffer |
[in] | buf | the OpenCL memory object |
[in] | type | the data type contained in the buffer |
[in] | retain | if true, instructs ArrayFire to retain the memory object |
retain
to true if the memory originates from a cl::Buffer object
|
inlinestatic |
Create an af::array object from an OpenCL cl_mem buffer.
[in] | dim0 | the length of the first dimension of the buffer |
[in] | dim1 | the length of the second dimension of the buffer |
[in] | dim2 | the length of the third dimension of the buffer |
[in] | buf | the OpenCL memory object |
[in] | type | the data type contained in the buffer |
[in] | retain | if true, instructs ArrayFire to retain the memory object |
retain
to true if the memory originates from a cl::Buffer object
|
inlinestatic |
Create an af::array object from an OpenCL cl_mem buffer.
[in] | dim0 | the length of the first dimension of the buffer |
[in] | dim1 | the length of the second dimension of the buffer |
[in] | dim2 | the length of the third dimension of the buffer |
[in] | dim3 | the length of the fourth dimension of the buffer |
[in] | buf | the OpenCL memory object |
[in] | type | the data type contained in the buffer |
[in] | retain | if true, instructs ArrayFire to retain the memory object |
retain
to true if the memory originates from a cl::Buffer object
|
inlinestatic |
Remove the user provided device control constructs from the ArrayFire device manager pool.
This function should be used only when the user would like ArrayFire to remove an already pushed user generated OpenCL context and related objects.
[in] | dev | is the OpenCL device id that has to be popped |
[in] | ctx | is the cl_context object to be removed from ArrayFire pool |
Definition at line 280 of file opencl.h.
|
inlinestatic |
Get a handle to ArrayFire's OpenCL context.
[in] | retain | if true calls clRetainContext prior to returning the context |
retain
to true if this value will be passed to a cl::Context constructor Definition at line 182 of file opencl.h.
|
inlinestatic |
Get the device ID for ArrayFire's current active device.
Definition at line 210 of file opencl.h.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Get a handle to ArrayFire's OpenCL command queue.
[in] | retain | if true calls clRetainCommandQueue prior to returning the context |
retain
to true if this value will be passed to a cl::CommandQueue constructor Definition at line 198 of file opencl.h.
|
inlinestatic |
Set active device using cl_context and cl_device_id.
[in] | dev | is the OpenCL device id that is to be set as Active device inside ArrayFire |
[in] | ctx | is the OpenCL cl_context being used by ArrayFire |
Definition at line 261 of file opencl.h.
|
inlinestatic |
Set ArrayFire's active device based on id
of type cl_device_id.
[in] | id | the cl_device_id of the device to be set as active device |
Definition at line 225 of file opencl.h.