DPC++ Runtime
Runtime libraries for oneAPI DPC++
backend_traits_level_zero.hpp
Go to the documentation of this file.
1 //===---- backend_traits_level_zero.hpp - Backend traits for Level Zero ---===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the specializations of the sycl::detail::interop,
10 // sycl::detail::BackendInput, sycl::detail::BackendReturn and
11 // sycl::detail::InteropFeatureSupportMap class templates for the Level Zero
12 // backend.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #pragma once
17 
18 #include <sycl/accessor.hpp>
19 #include <sycl/context.hpp>
21 #include <sycl/detail/defines.hpp>
22 #include <sycl/device.hpp>
23 #include <sycl/event.hpp>
26 #include <sycl/kernel_bundle.hpp>
27 #include <sycl/queue.hpp>
28 
29 typedef struct _ze_command_queue_handle_t *ze_command_queue_handle_t;
30 typedef struct _ze_context_handle_t *ze_context_handle_t;
31 typedef struct _ze_device_handle_t *ze_device_handle_t;
32 typedef struct _ze_driver_handle_t *ze_driver_handle_t;
33 typedef struct _ze_event_handle_t *ze_event_handle_t;
34 typedef struct _ze_image_handle_t *ze_image_handle_t;
35 typedef struct _ze_kernel_handle_t *ze_kernel_handle_t;
36 typedef struct _ze_module_handle_t *ze_module_handle_t;
37 
38 namespace sycl {
40 namespace detail {
41 
42 // Forward declarations
43 class device_impl;
44 
45 // TODO the interops for context, device, event, platform and program
46 // may be removed after removing the deprecated 'get_native()' methods
47 // from the corresponding classes. The interop<backend, queue> specialization
48 // is also used in the get_queue() method of the deprecated class
49 // interop_handler and also can be removed after API cleanup.
52 };
53 
56 };
57 
58 template <> struct interop<backend::ext_oneapi_level_zero, event> {
60 };
61 
62 template <> struct interop<backend::ext_oneapi_level_zero, queue> {
64 };
65 
68 };
69 
70 // TODO the interops for accessor is used in the already deprecated class
71 // interop_handler and can be removed after API cleanup.
72 template <typename DataT, int Dimensions, access::mode AccessMode>
74  accessor<DataT, Dimensions, AccessMode, access::target::device,
75  access::placeholder::false_t>> {
76  using type = char *;
77 };
78 
79 template <typename DataT, int Dimensions, access::mode AccessMode>
80 struct interop<
82  accessor<DataT, Dimensions, AccessMode, access::target::constant_buffer,
83  access::placeholder::false_t>> {
84  using type = char *;
85 };
86 
87 template <typename DataT, int Dimensions, access::mode AccessMode>
89  accessor<DataT, Dimensions, AccessMode, access::target::image,
90  access::placeholder::false_t>> {
92 };
93 
96 };
97 
99  struct type {
101  std::vector<device> DeviceList;
103  ext::oneapi::level_zero::ownership::transfer};
104  };
105 };
106 
109 };
110 
113 };
114 
117 };
118 
120  struct type {
123  ext::oneapi::level_zero::ownership::transfer};
124  };
125 };
126 
129 };
130 
132  struct type {
135 
137 
139  : Ownership(ext::oneapi::level_zero::ownership::transfer), Device() {}
140 
141  __SYCL_DEPRECATED("Use backend_input_t<backend::ext_oneapi_level_zero, "
142  "queue> constructor with device parameter")
143  type(interop<backend::ext_oneapi_level_zero, queue>::type nativeHandle,
144  ext::oneapi::level_zero::ownership ownership =
145  ext::oneapi::level_zero::ownership::transfer)
146  : NativeHandle(nativeHandle), Ownership(ownership), Device() {}
147 
149  device dev,
151  ext::oneapi::level_zero::ownership::transfer)
152  : NativeHandle(nativeHandle), Ownership(ownership), Device(dev) {}
153  };
154 };
155 
156 template <typename DataT, int Dimensions, typename AllocatorT>
158  buffer<DataT, Dimensions, AllocatorT>> {
159  struct type {
162  ext::oneapi::level_zero::ownership::transfer};
163  };
164 };
165 
166 template <typename DataT, int Dimensions, typename AllocatorT>
168  buffer<DataT, Dimensions, AllocatorT>> {
169  using type = void *;
170 };
171 
174 };
175 
178 };
179 
182 };
183 
184 template <bundle_state State>
186  struct type {
189  ext::oneapi::level_zero::ownership::transfer};
190  };
191 };
192 
193 template <bundle_state State>
195  using type = std::vector<ze_module_handle_t>;
196 };
197 
199  struct type {
203  ext::oneapi::level_zero::ownership::transfer};
204  };
205 };
206 
209 };
210 
212  static constexpr bool MakePlatform = true;
213  static constexpr bool MakeDevice = true;
214  static constexpr bool MakeContext = true;
215  static constexpr bool MakeQueue = true;
216  static constexpr bool MakeEvent = true;
217  static constexpr bool MakeKernelBundle = true;
218  static constexpr bool MakeKernel = true;
219  static constexpr bool MakeBuffer = true;
220 };
221 
222 } // namespace detail
223 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
224 } // namespace sycl
ze_image_handle_t
struct _ze_image_handle_t * ze_image_handle_t
Definition: backend_traits_level_zero.hpp:34
sycl::_V1::backend
backend
Definition: backend_types.hpp:21
ze_module_handle_t
struct _ze_module_handle_t * ze_module_handle_t
Definition: backend_traits_level_zero.hpp:36
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, buffer< DataT, Dimensions, AllocatorT > >::type::NativeHandle
void * NativeHandle
Definition: backend_traits_level_zero.hpp:160
sycl::_V1::backend::ext_oneapi_level_zero
@ ext_oneapi_level_zero
device.hpp
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:13
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, context >::type::NativeHandle
interop< backend::ext_oneapi_level_zero, context >::type NativeHandle
Definition: backend_traits_level_zero.hpp:100
sycl::_V1::buffer
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:35
ze_command_queue_handle_t
struct _ze_command_queue_handle_t * ze_command_queue_handle_t
Definition: backend_traits_level_zero.hpp:29
ze_event_handle_t
struct _ze_event_handle_t * ze_event_handle_t
Definition: backend_traits_level_zero.hpp:33
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, kernel >::type::KernelBundle
kernel_bundle< bundle_state::executable > KernelBundle
Definition: backend_traits_level_zero.hpp:200
context.hpp
event.hpp
ze_device_handle_t
struct _ze_device_handle_t * ze_device_handle_t
Definition: backend_traits_level_zero.hpp:31
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, platform >::type
ze_driver_handle_t type
Definition: backend_traits_level_zero.hpp:177
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:13
sycl::_V1::event
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:38
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, queue >::type::Device
device Device
Definition: backend_traits_level_zero.hpp:136
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_level_zero, kernel_bundle< State > >::type
std::vector< ze_module_handle_t > type
Definition: backend_traits_level_zero.hpp:195
backend_traits.hpp
sycl::_V1::detail::BackendInput
Definition: backend_traits.hpp:20
sycl::_V1::detail::InteropFeatureSupportMap
Definition: backend_traits.hpp:24
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_level_zero, kernel >::type
ze_kernel_handle_t type
Definition: backend_traits_level_zero.hpp:208
sycl::_V1::kernel
Provides an abstraction of a SYCL kernel.
Definition: kernel.hpp:69
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_level_zero, buffer< DataT, Dimensions, AllocatorT > >::type
void * type
Definition: backend_traits_level_zero.hpp:169
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_level_zero, event >::type
ze_event_handle_t type
Definition: backend_traits_level_zero.hpp:128
char
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, kernel >::type::NativeHandle
ze_kernel_handle_t NativeHandle
Definition: backend_traits_level_zero.hpp:201
filter_selector.hpp
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, queue >::type::__SYCL_DEPRECATED
__SYCL_DEPRECATED("Use backend_input_t<backend::ext_oneapi_level_zero, " "queue> constructor with device parameter") type(interop< backend
Definition: backend_traits_level_zero.hpp:141
sycl::_V1::detail::interop
Definition: backend_traits.hpp:18
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, queue >::type::type
type()
Definition: backend_traits_level_zero.hpp:138
kernel_bundle.hpp
sycl::_V1::queue
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:86
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, event >::type::NativeHandle
interop< backend::ext_oneapi_level_zero, event >::type NativeHandle
Definition: backend_traits_level_zero.hpp:121
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, queue >::type::Ownership
ext::oneapi::level_zero::ownership Ownership
Definition: backend_traits_level_zero.hpp:134
defines.hpp
Device
@ Device
Definition: usm_allocator.hpp:14
sycl::_V1::kernel_bundle
The kernel_bundle class represents collection of device images in a particular state.
Definition: kernel.hpp:27
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_level_zero, queue >::type
ze_command_queue_handle_t type
Definition: backend_traits_level_zero.hpp:173
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, queue >::type::NativeHandle
interop< backend::ext_oneapi_level_zero, queue >::type NativeHandle
Definition: backend_traits_level_zero.hpp:133
sycl::_V1::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:47
queue.hpp
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, context >::type::DeviceList
std::vector< device > DeviceList
Definition: backend_traits_level_zero.hpp:101
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, kernel_bundle< State > >::type::NativeHandle
ze_module_handle_t NativeHandle
Definition: backend_traits_level_zero.hpp:187
level_zero_ownership.hpp
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_level_zero, device >::type
ze_device_handle_t type
Definition: backend_traits_level_zero.hpp:116
sycl::_V1::ext::oneapi::level_zero::ownership
ownership
Definition: level_zero_ownership.hpp:23
sycl::_V1::accessor
Definition: accessor.hpp:227
sycl::_V1::detail::interop< backend::ext_oneapi_level_zero, kernel >::type
ze_kernel_handle_t type
Definition: backend_traits_level_zero.hpp:95
accessor.hpp
sycl::_V1::detail::BackendReturn
Definition: backend_traits.hpp:22
ze_context_handle_t
struct _ze_context_handle_t * ze_context_handle_t
Definition: backend_traits_level_zero.hpp:30
sycl::_V1::detail::interop< backend::ext_oneapi_level_zero, queue >::type
ze_command_queue_handle_t type
Definition: backend_traits_level_zero.hpp:63
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_level_zero, context >::type
ze_context_handle_t type
Definition: backend_traits_level_zero.hpp:108
ze_driver_handle_t
struct _ze_driver_handle_t * ze_driver_handle_t
Definition: backend_traits_level_zero.hpp:32
sycl::_V1::detail::interop< backend::ext_oneapi_level_zero, context >::type
ze_context_handle_t type
Definition: backend_traits_level_zero.hpp:51
sycl::_V1::platform
Encapsulates a SYCL platform on which kernels may be executed.
Definition: platform.hpp:45
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, device >::type
ze_device_handle_t type
Definition: backend_traits_level_zero.hpp:112
ze_kernel_handle_t
struct _ze_kernel_handle_t * ze_kernel_handle_t
Definition: backend_traits_level_zero.hpp:35
sycl::_V1::detail::interop< backend::ext_oneapi_level_zero, event >::type
ze_event_handle_t type
Definition: backend_traits_level_zero.hpp:59
sycl::_V1::detail::BackendInput< backend::ext_oneapi_level_zero, queue >::type::type
type(interop< backend::ext_oneapi_level_zero, queue >::type nativeHandle, device dev, ext::oneapi::level_zero::ownership ownership=ext::oneapi::level_zero::ownership::transfer)
Definition: backend_traits_level_zero.hpp:148
sycl::_V1::detail::interop< backend::ext_oneapi_level_zero, accessor< DataT, Dimensions, AccessMode, access::target::image, access::placeholder::false_t > >::type
ze_image_handle_t type
Definition: backend_traits_level_zero.hpp:91
sycl::_V1::detail::BackendReturn< backend::ext_oneapi_level_zero, platform >::type
ze_driver_handle_t type
Definition: backend_traits_level_zero.hpp:181
sycl::_V1::detail::interop< backend::ext_oneapi_level_zero, device >::type
ze_device_handle_t type
Definition: backend_traits_level_zero.hpp:55
sycl::_V1::detail::interop< backend::ext_oneapi_level_zero, platform >::type
ze_driver_handle_t type
Definition: backend_traits_level_zero.hpp:67
sycl::_V1::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:39