namespace dnnl::ocl_interop

Overview

OpenCL interoperability namespace. More…

namespace ocl_interop {

// global functions

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);

} // namespace ocl_interop

Detailed Documentation

OpenCL interoperability namespace.

Global Functions

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.