17 #ifndef ONEAPI_DNNL_DNNL_OCL_HPP 18 #define ONEAPI_DNNL_DNNL_OCL_HPP 29 #include <unordered_map> 31 #include "oneapi/dnnl/dnnl_ocl.h" 52 namespace ocl_interop {
64 "could not create an engine");
73 cl_context context =
nullptr;
76 "could not get an OpenCL context from an engine");
85 cl_device_id device =
nullptr;
87 "could not get an OpenCL device from an engine");
100 "could not create a stream");
109 cl_command_queue queue =
nullptr;
112 "could not get an OpenCL command queue from a stream");
124 "could not get OpenCL buffer object from a memory object");
139 "could not set OpenCL buffer object from a memory object");
cl_mem get_mem_object(const memory &amemory)
Returns the OpenCL memory object associated with the memory object.
Definition: dnnl_ocl.hpp:120
dnnl_status_t DNNL_API dnnl_ocl_interop_stream_create(dnnl_stream_t *stream, dnnl_engine_t engine, cl_command_queue queue)
Creates an execution stream for a given engine associated with an OpenCL command queue.
oneDNN namespace
Definition: dnnl.hpp:74
dnnl_status_t DNNL_API dnnl_ocl_interop_get_device(dnnl_engine_t engine, cl_device_id *device)
Returns the OpenCL device associated with an engine.
An execution engine.
Definition: dnnl.hpp:885
An opaque structure to describe an engine.
dnnl_status_t DNNL_API dnnl_ocl_interop_engine_create(dnnl_engine_t *engine, cl_device_id device, cl_context context)
Creates an engine associated with an OpenCL device and an OpenCL context.
T get(bool allow_empty=false) const
Returns the underlying C API handle.
Definition: dnnl.hpp:185
void set_mem_object(memory &amemory, cl_mem mem_object)
Sets the OpenCL memory object associated with the memory object.
Definition: dnnl_ocl.hpp:136
static void wrap_c_api(dnnl_status_t status, const char *message)
A convenience function for wrapping calls to C API functions.
Definition: dnnl.hpp:103
Memory object.
Definition: dnnl.hpp:1124
dnnl_status_t DNNL_API dnnl_ocl_interop_memory_get_mem_object(const_dnnl_memory_t memory, cl_mem *mem_object)
Returns an OpenCL memory object associated with a memory object.
dnnl_status_t DNNL_API dnnl_ocl_interop_memory_set_mem_object(dnnl_memory_t memory, cl_mem mem_object)
Sets OpenCL memory object associated with a memory object.
cl_command_queue get_command_queue(const stream &astream)
Returns OpenCL queue object associated with the execution stream.
Definition: dnnl_ocl.hpp:108
dnnl_status_t DNNL_API dnnl_ocl_interop_engine_get_context(dnnl_engine_t engine, cl_context *context)
Returns the OpenCL context associated with an engine.
stream make_stream(const engine &aengine, cl_command_queue queue)
Constructs an execution stream for the specified engine and OpenCL queue.
Definition: dnnl_ocl.hpp:96
An opaque structure to describe an execution stream.
dnnl_status_t DNNL_API dnnl_ocl_interop_stream_get_command_queue(dnnl_stream_t stream, cl_command_queue *queue)
Returns the OpenCL command queue associated with an execution stream.
engine make_engine(cl_device_id device, cl_context context)
Constructs an engine from OpenCL device and context objects.
Definition: dnnl_ocl.hpp:60
cl_device_id get_device(const engine &aengine)
Returns OpenCL device associated with the engine.
Definition: dnnl_ocl.hpp:84
An execution stream.
Definition: dnnl.hpp:1001
cl_context get_context(const engine &aengine)
Returns OpenCL context associated with the engine.
Definition: dnnl_ocl.hpp:72