afcl Namespace Reference

- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

afcl Namespace Reference

typedef afcl_device_type | deviceType
typedef afcl_platform | platform
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 the type of the current 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...

## Typedef Documentation

typedef afcl_device_type deviceType

typedef afcl_platform platform

## Function Documentation

static void afcl::addDevice | ( | cl_device_id | dev,
|  | cl_context | ctx,
|  | cl_command_queue | que
| ) |  |
| 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.

Parameters

  [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.

Note
  The cl_* objects are passed onto c++ objects (cl::Device, cl::Context & cl::CommandQueue) that are defined in the `cl.hpp` OpenCL c++ header provided by Khronos Group Inc. Therefore, please be aware of the lifetime of the cl_* objects before passing them to ArrayFire.

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] | 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

Returns
  an array object created from the OpenCL buffer

Note
  Set `retain` to true if the memory originates from a cl::Buffer object

Examples:
  getting_started/convolve.cpp, getting_started/integer.cpp, image_processing/brain_segmentation.cpp, image_processing/image_demo.cpp, image_processing/morphing.cpp, and image_processing/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] | 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

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] | 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

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] | 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

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] | 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

Returns
  an array object created from the OpenCL buffer

Note
  Set `retain` to true if the memory originates from a cl::Buffer object

static void afcl::deleteDevice | ( | cl_device_id | dev,
|  | cl_context | ctx
| ) |  |
| 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.

Parameters

  [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

Note
  Any reference counts incremented for cl_* objects by ArrayFire internally are decremented by this func call and you won't be able to call `afcl_set_device_context` on these objects after this function has been called.

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 deviceType afcl::getDeviceType | ( |  | ) |
| inlinestatic

Get the type of the current device.

static platform afcl::getPlatform | ( |  | ) |
| inlinestatic

Get the type 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] | retain | if 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

static void afcl::setDevice | ( | cl_device_id | dev,
|  | cl_context | ctx
| ) |  |
| inlinestatic

Set active device using cl_context and cl_device_id.

Parameters

  [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

static void afcl::setDeviceId | ( | cl_device_id | id | ) |
| inlinestatic

Set ArrayFire's active device based on `id` of type cl_device_id.

Parameters

  [in] | id | the cl_device_id of the device to be set as active device