.. 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 cl::sycl::device& adevice, const cl::sycl::context& acontext ); cl::sycl::context :ref:`get_context`(const :ref:`engine`& aengine); cl::sycl::device :ref:`get_device`(const :ref:`engine`& aengine); :ref:`stream` :ref:`make_stream`(const :ref:`engine`& aengine, cl::sycl::queue& aqueue); cl::sycl::queue :ref:`get_queue`(const :ref:`stream`& astream); template cl::sycl::buffer :ref:`get_buffer`(const :ref:`memory`& amemory); template void :ref:`set_buffer`( :ref:`memory`& amemory, cl::sycl::buffer& abuffer ); template void :ref:`set_buffer`( :ref:`memory`& amemory, cl::sycl::buffer& abuffer, const :ref:`stream`& astream ); :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, cl::sycl::buffer& abuffer ); cl::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_1a38a3e5df773eac0eca657c210e3bb937: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`engine` make_engine( const cl::sycl::device& adevice, const cl::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_1a351bee0c0076334dd0eb211720448d7e: .. ref-code-block:: cpp :class: doxyrest-title-code-block cl::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_1ac4198f877f40ff0d037b0f8b88611207: .. ref-code-block:: cpp :class: doxyrest-title-code-block cl::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_1a21b76da69a016e68eae8036f16cc51b8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`stream` make_stream(const :ref:`engine`& aengine, cl::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_1a1e01cd09b687a1698d229705493c6acd: .. ref-code-block:: cpp :class: doxyrest-title-code-block cl::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_1aa79e54806e23001f638483f5cd3319b4: .. ref-code-block:: cpp :class: doxyrest-title-code-block template cl::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_1aa0d461dded1b8dee57c6ad7bf5ee3069: .. ref-code-block:: cpp :class: doxyrest-title-code-block template void set_buffer( :ref:`memory`& amemory, cl::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; set_buffer .. _doxid-namespacednnl_1_1sycl__interop_1aa5afe32f087d20f85bdfdb418386c35d: .. ref-code-block:: cpp :class: doxyrest-title-code-block template void set_buffer( :ref:`memory`& amemory, cl::sycl::buffer& abuffer, const :ref:`stream`& astream ) Sets SYCL buffer associated with a memory object in a specified stream. .. 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. * - astream - Stream to use to execute padding in. .. 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_1adc40aabb36c9343ec3e2e5913b57090d: .. ref-code-block:: cpp :class: doxyrest-title-code-block template :ref:`memory` make_memory( const :ref:`memory::desc`& memory_desc, const :ref:`engine`& aengine, cl::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_1afc6c83e27a688e120b72e5355786d4c9: .. ref-code-block:: cpp :class: doxyrest-title-code-block cl::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 ``cl::sycl::event`` dependencies. .. rubric:: Returns: Output event.