namespace dnnl::ocl_interop¶
Overview¶
OpenCL interoperability namespace. More…
namespace ocl_interop { // enums enum memory_kind; // global functions dnnl_ocl_interop_memory_kind_t convert_to_c(memory_kind akind); engine make_engine(cl_device_id device, cl_context context); cl_context get_context(const engine& aengine); cl_device_id get_device(const engine& aengine); stream make_stream(const engine& aengine, cl_command_queue queue); cl_command_queue get_command_queue(const stream& astream); cl_mem get_mem_object(const memory& amemory); void set_mem_object(memory& amemory, cl_mem mem_object); memory_kind get_memory_kind(const memory& amemory); memory make_memory( const memory::desc& memory_desc, const engine& aengine, memory_kind kind, void* handle = DNNL_MEMORY_ALLOCATE ); memory make_memory( const memory::desc& memory_desc, const engine& aengine, cl_mem mem_object ); } // namespace ocl_interop
Detailed Documentation¶
OpenCL interoperability namespace.
Global Functions¶
dnnl_ocl_interop_memory_kind_t convert_to_c(memory_kind akind)
Converts a memory allocation kind enum value from C++ API to C API type.
Parameters:
akind |
C++ API memory allocation kind enum value. |
Returns:
Corresponding C API memory allocation kind enum value.
engine make_engine(cl_device_id device, cl_context context)
Constructs an engine from OpenCL device and context objects.
Parameters:
device |
The OpenCL device that this engine will encapsulate. |
context |
The OpenCL context (containing the device) that this engine will use for all operations. |
Returns:
An engine.
cl_context get_context(const engine& aengine)
Returns OpenCL context associated with the engine.
Parameters:
aengine |
An engine. |
Returns:
Underlying OpenCL context.
cl_device_id get_device(const engine& aengine)
Returns OpenCL device associated with the engine.
Parameters:
aengine |
An engine. |
Returns:
Underlying OpenCL device.
stream make_stream(const engine& aengine, cl_command_queue queue)
Constructs an execution stream for the specified engine and OpenCL queue.
Parameters:
aengine |
Engine to create the stream on. |
queue |
OpenCL queue to use for the stream. |
Returns:
An execution stream.
cl_command_queue get_command_queue(const stream& astream)
Returns OpenCL queue object associated with the execution stream.
Parameters:
astream |
An execution stream. |
Returns:
Underlying OpenCL queue.
cl_mem get_mem_object(const memory& amemory)
Returns the OpenCL memory object associated with the memory object.
Parameters:
amemory |
A memory object. |
Returns:
Underlying OpenCL memory object.
void set_mem_object(memory& amemory, cl_mem mem_object)
Sets the OpenCL memory object associated with the memory object.
For behavioral details see memory::set_data_handle().
Parameters:
amemory |
A memory object. |
mem_object |
OpenCL cl_mem object to use as the underlying storage. It must have at least get_desc().get_size() bytes allocated. |
memory_kind get_memory_kind(const memory& amemory)
Returns the memory allocation kind associated with a memory object.
Parameters:
amemory |
A memory object. |
Returns:
The underlying memory allocation kind of the memory object.
memory make_memory( const memory::desc& memory_desc, const engine& aengine, memory_kind kind, void* handle = DNNL_MEMORY_ALLOCATE )
Creates a memory object.
Unless handle
is equal to DNNL_MEMORY_NONE or DNNL_MEMORY_ALLOCATE, the constructed memory object will have the underlying buffer set. In this case, the buffer will be initialized as if:
dnnl::memory::set_data_handle() had been called, if
memory_kind
is equal to dnnl::ocl_interop::memory_kind::usm, ordnnl::ocl_interop::set_mem_object() has been called, if
memory_kind
is equal to dnnl::ocl_interop::memory_kind::buffer.
Parameters:
memory_desc |
Memory descriptor. |
aengine |
Engine to use. |
kind |
Memory allocation kind to specify the type of handle. |
handle |
Handle of the memory buffer to use as an underlying storage.
|
Returns:
Created memory object.
memory make_memory( const memory::desc& memory_desc, const engine& aengine, cl_mem mem_object )
Constructs a memory object from an OpenCL buffer.
Parameters:
memory_desc |
Memory descriptor. |
aengine |
Engine to use. |
abuffer |
An OpenCL buffer to use. |
Returns:
Created memory object.