.. index:: pair: namespace; dnnl::ocl_interop .. _doxid-namespacednnl_1_1ocl__interop: namespace dnnl::ocl_interop =========================== .. toctree:: :hidden: enum_dnnl_ocl_interop_memory_kind.rst Overview ~~~~~~~~ OpenCL interoperability namespace. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block namespace ocl_interop { // enums enum :ref:`memory_kind`; // global functions :ref:`dnnl_ocl_interop_memory_kind_t` :ref:`convert_to_c`(:ref:`memory_kind` akind); :ref:`engine` :ref:`make_engine`(cl_device_id device, cl_context context); cl_context :ref:`get_context`(const :ref:`engine`& aengine); cl_device_id :ref:`get_device`(const :ref:`engine`& aengine); :ref:`stream` :ref:`make_stream`(const :ref:`engine`& aengine, cl_command_queue queue); cl_command_queue :ref:`get_command_queue`(const :ref:`stream`& astream); cl_mem :ref:`get_mem_object`(const :ref:`memory`& amemory); void :ref:`set_mem_object`(:ref:`memory`& amemory, cl_mem mem_object); :ref:`memory_kind` :ref:`get_memory_kind`(const :ref:`memory`& amemory); :ref:`memory` :ref:`make_memory`( const :ref:`memory::desc`& memory_desc, const :ref:`engine`& aengine, :ref:`memory_kind` kind, void* handle = :ref:`DNNL_MEMORY_ALLOCATE` ); :ref:`memory` :ref:`make_memory`( const :ref:`memory::desc`& memory_desc, const :ref:`engine`& aengine, cl_mem mem_object ); } // namespace ocl_interop .. _details-namespacednnl_1_1ocl__interop: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ OpenCL interoperability namespace. Global Functions ---------------- .. index:: pair: function; convert_to_c .. _doxid-namespacednnl_1_1ocl__interop_1a5dc60a792c457e048fab0b88e69c384f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_ocl_interop_memory_kind_t` convert_to_c(:ref:`memory_kind` akind) Converts a memory allocation kind enum value from C++ API to C API type. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - akind - C++ API memory allocation kind enum value. .. rubric:: Returns: Corresponding C API memory allocation kind enum value. .. index:: pair: function; make_engine .. _doxid-namespacednnl_1_1ocl__interop_1aaa1b1a194ca813f3db12effd29a359d7: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`engine` make_engine(cl_device_id device, cl_context context) Constructs an engine from OpenCL device and context objects. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - device - The OpenCL device that this engine will encapsulate. * - context - The OpenCL context (containing the device) that this engine will use for all operations. .. rubric:: Returns: An engine. .. index:: pair: function; get_context .. _doxid-namespacednnl_1_1ocl__interop_1a248df8106d035e5a7e1ac5fd196c93c3: .. ref-code-block:: cpp :class: doxyrest-title-code-block cl_context get_context(const :ref:`engine`& aengine) Returns OpenCL context associated with the engine. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - aengine - An engine. .. rubric:: Returns: Underlying OpenCL context. .. index:: pair: function; get_device .. _doxid-namespacednnl_1_1ocl__interop_1a37ef1ccb75d09063ed049076fb23b927: .. ref-code-block:: cpp :class: doxyrest-title-code-block cl_device_id get_device(const :ref:`engine`& aengine) Returns OpenCL device associated with the engine. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - aengine - An engine. .. rubric:: Returns: Underlying OpenCL device. .. index:: pair: function; make_stream .. _doxid-namespacednnl_1_1ocl__interop_1ad29aa52fd99fb371018ae6761b0bc8fa: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`stream` make_stream(const :ref:`engine`& aengine, cl_command_queue queue) Constructs an execution stream for the specified engine and OpenCL queue. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - aengine - Engine to create the stream on. * - queue - OpenCL queue to use for the stream. .. rubric:: Returns: An execution stream. .. index:: pair: function; get_command_queue .. _doxid-namespacednnl_1_1ocl__interop_1a14281f69db5178363ff0c971510d0452: .. ref-code-block:: cpp :class: doxyrest-title-code-block cl_command_queue get_command_queue(const :ref:`stream`& astream) Returns OpenCL queue object associated with the execution stream. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - astream - An execution stream. .. rubric:: Returns: Underlying OpenCL queue. .. index:: pair: function; get_mem_object .. _doxid-namespacednnl_1_1ocl__interop_1ac117d62fba9de220fe53b0eedb9671f9: .. ref-code-block:: cpp :class: doxyrest-title-code-block cl_mem get_mem_object(const :ref:`memory`& amemory) Returns the OpenCL memory object associated with the memory object. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - amemory - A memory object. .. rubric:: Returns: Underlying OpenCL memory object. .. index:: pair: function; set_mem_object .. _doxid-namespacednnl_1_1ocl__interop_1abe99da7a9ae3286ba6a950921a07eaf0: .. ref-code-block:: cpp :class: doxyrest-title-code-block void set_mem_object(:ref:`memory`& amemory, cl_mem mem_object) Sets the OpenCL memory object associated with the memory object. For behavioral details see :ref:`memory::set_data_handle() `. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - 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. .. index:: pair: function; get_memory_kind .. _doxid-namespacednnl_1_1ocl__interop_1aa94bfc5feb0de9752012d60f4de1ad2f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`memory_kind` get_memory_kind(const :ref:`memory`& amemory) Returns the memory allocation kind associated with a memory object. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - amemory - A memory object. .. rubric:: Returns: The underlying memory allocation kind of the memory object. .. index:: pair: function; make_memory .. _doxid-namespacednnl_1_1ocl__interop_1acfb8e3d4cdcff9244e9b530b3f4c4a9d: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`memory` make_memory( const :ref:`memory::desc`& memory_desc, const :ref:`engine`& aengine, :ref:`memory_kind` kind, void* handle = :ref:`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: * :ref:`dnnl::memory::set_data_handle() ` had been called, if ``memory_kind`` is equal to :ref:`dnnl::ocl_interop::memory_kind::usm `, or * :ref:`dnnl::ocl_interop::set_mem_object() ` has been called, if ``memory_kind`` is equal to :ref:`dnnl::ocl_interop::memory_kind::buffer `. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - 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. * A USM pointer to the user-allocated buffer. In this case the library doesn't own the buffer. Requires ``memory_kind`` to be equal to :ref:`dnnl::ocl_interop::memory_kind::usm `. * An OpenCL buffer. In this case the library doesn't own the buffer. Requires ``memory_kind`` be equal to be equal to :ref:`dnnl::ocl_interop::memory_kind::buffer `. * The DNNL_MEMORY_ALLOCATE special value. Instructs the library to allocate the buffer that corresponds to the memory allocation kind ``memory_kind`` for the memory object. In this case the library owns the buffer. * The DNNL_MEMORY_NONE specific value. Instructs the library to create memory object without an underlying buffer. .. rubric:: Returns: Created memory object. .. index:: pair: function; make_memory .. _doxid-namespacednnl_1_1ocl__interop_1a8be4eaee886f3d99f154cfe5d2544994: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`memory` make_memory( const :ref:`memory::desc`& memory_desc, const :ref:`engine`& aengine, cl_mem mem_object ) Constructs a memory object from an OpenCL buffer. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - memory_desc - Memory descriptor. * - aengine - Engine to use. * - abuffer - An OpenCL buffer to use. .. rubric:: Returns: Created memory object.