.. index:: pair: namespace; dnnl::sycl_interop .. _doxid-namespacednnl_1_1sycl__interop: namespace dnnl::sycl_interop ============================ .. toctree:: :hidden: enum_dnnl_sycl_interop_memory_kind.rst Overview ~~~~~~~~ SYCL interoperability namespace. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block namespace sycl_interop { // enums enum :ref:`memory_kind`; // global functions :ref:`dnnl_sycl_interop_memory_kind_t` :ref:`convert_to_c`(:ref:`memory_kind` akind); :ref:`engine` :ref:`make_engine`(const sycl::device& adevice, const sycl::context& acontext); sycl::context :ref:`get_context`(const :ref:`engine`& aengine); sycl::device :ref:`get_device`(const :ref:`engine`& aengine); :ref:`stream` :ref:`make_stream`(const :ref:`engine`& aengine, sycl::queue& aqueue); sycl::queue :ref:`get_queue`(const :ref:`stream`& astream); template :ref:`sycl::buffer` :ref:`get_buffer`(const :ref:`memory`& amemory); template void :ref:`set_buffer`( :ref:`memory`& amemory, :ref:`sycl::buffer`& abuffer ); :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` ); template :ref:`memory` :ref:`make_memory`( const :ref:`memory::desc`& memory_desc, const :ref:`engine`& aengine, :ref:`sycl::buffer`& abuffer ); sycl::event :ref:`execute`( const :ref:`dnnl::primitive`& aprimitive, const :ref:`stream`& astream, const std::unordered_map`>& args, const std::vector& deps = {} ); } // namespace sycl_interop .. _details-namespacednnl_1_1sycl__interop: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ SYCL interoperability namespace. Global Functions ---------------- .. index:: pair: function; convert_to_c .. _doxid-namespacednnl_1_1sycl__interop_1a61c88b2b3dd997b5e99232c218a8ac8f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`dnnl_sycl_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_1sycl__interop_1a683783e1493808bd6ac2204d5efa63a8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`engine` make_engine(const sycl::device& adevice, const sycl::context& acontext) Constructs an engine from SYCL device and context objects. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - adevice - SYCL device. * - acontext - SYCL context. .. rubric:: Returns: Created engine. .. index:: pair: function; get_context .. _doxid-namespacednnl_1_1sycl__interop_1a5227caa35295b41dcdd57f8abaa7551b: .. ref-code-block:: cpp :class: doxyrest-title-code-block sycl::context get_context(const :ref:`engine`& aengine) Returns the SYCL context associated with an engine. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - aengine - Engine to query. .. rubric:: Returns: The underlying SYCL device of the engine. .. index:: pair: function; get_device .. _doxid-namespacednnl_1_1sycl__interop_1adddf805d923929f373fb6233f1fd4a27: .. ref-code-block:: cpp :class: doxyrest-title-code-block sycl::device get_device(const :ref:`engine`& aengine) Returns the SYCL device associated with an engine. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - aengine - Engine to query. .. rubric:: Returns: The underlying SYCL context of the engine. .. index:: pair: function; make_stream .. _doxid-namespacednnl_1_1sycl__interop_1a170bddd16d53869fc18412894400ccab: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`stream` make_stream(const :ref:`engine`& aengine, sycl::queue& aqueue) Creates an execution stream for a given engine associated with a SYCL queue. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - aengine - Engine object to use for the stream. * - aqueue - SYCL queue to use for the stream. .. rubric:: Returns: An execution stream. .. index:: pair: function; get_queue .. _doxid-namespacednnl_1_1sycl__interop_1a59a9e92e8ff59c1282270fc6edad4274: .. ref-code-block:: cpp :class: doxyrest-title-code-block sycl::queue get_queue(const :ref:`stream`& astream) Returns the SYCL queue associated with an execution stream. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - astream - Execution stream to query. .. rubric:: Returns: SYCL queue object. .. index:: pair: function; get_buffer .. _doxid-namespacednnl_1_1sycl__interop_1a3a982d9d12f29f0856cba970b470d4d0: .. ref-code-block:: cpp :class: doxyrest-title-code-block template :ref:`sycl::buffer` get_buffer(const :ref:`memory`& amemory) Returns the SYCL buffer associated with a memory object. Throws an exception if the memory allocation kind associated with the memory object is not equal to :ref:`dnnl::sycl_interop::memory_kind::buffer `. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - T - Type of the requested buffer. * - ndims - Number of dimensions of the requested buffer. * - amemory - Memory object. .. rubric:: Returns: SYCL buffer associated with the memory object. .. index:: pair: function; set_buffer .. _doxid-namespacednnl_1_1sycl__interop_1abc037ad6dca6da72275911e1d4a21473: .. ref-code-block:: cpp :class: doxyrest-title-code-block template void set_buffer( :ref:`memory`& amemory, :ref:`sycl::buffer`& abuffer ) Sets SYCL buffer associated with a memory object. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - T - Type of the buffer. * - ndims - Number of dimensions of the buffer. * - amemory - Memory object to change. * - abuffer - SYCL buffer. .. index:: pair: function; get_memory_kind .. _doxid-namespacednnl_1_1sycl__interop_1a9859fd3ed9a833cc88cb02882051cffb: .. 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_1sycl__interop_1ac4f19c86efba789310d287ad1edfb657: .. 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::sycl_interop::memory_kind::usm `, or * :ref:`dnnl::sycl_interop::set_buffer() ` has been called, if ``memory_kind`` is equal to :ref:`dnnl::sycl_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::sycl_interop::memory_kind::usm `. * A pointer to SYCL buffer. In this case the library doesn't own the buffer. Requires ``memory_kind`` be equal to be equal to :ref:`dnnl::sycl_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_1sycl__interop_1a58de74caadf2b2bc3d22cb557682ef47: .. ref-code-block:: cpp :class: doxyrest-title-code-block template :ref:`memory` make_memory( const :ref:`memory::desc`& memory_desc, const :ref:`engine`& aengine, :ref:`sycl::buffer`& abuffer ) Constructs a memory object from a SYCL buffer. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - memory_desc - Memory descriptor. * - aengine - Engine to use. * - abuffer - A SYCL buffer to use. .. rubric:: Returns: Created memory object. .. index:: pair: function; execute .. _doxid-namespacednnl_1_1sycl__interop_1a30c5c906dfba71774528710613165c14: .. ref-code-block:: cpp :class: doxyrest-title-code-block sycl::event execute( const :ref:`dnnl::primitive`& aprimitive, const :ref:`stream`& astream, const std::unordered_map`>& args, const std::vector& deps = {} ) Executes computations specified by the primitive in a specified stream and returns a SYCL event. Arguments are passed via an arguments map containing pairs. The index must be one of the ``DNNL_ARG_*`` values such as ``DNNL_ARG_SRC``, and the memory must have a memory descriptor matching the one returned by :ref:`dnnl::primitive_desc::query_md ` (:ref:`query::exec_arg_md `, index) unless using dynamic shapes (see :ref:`DNNL_RUNTIME_DIM_VAL `). .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - aprimitive - Primitive to execute. * - astream - Stream object. The stream must belong to the same engine as the primitive. * - args - Arguments map. * - deps - Optional vector with ``sycl::event`` dependencies. .. rubric:: Returns: Output event.