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/backend_types.hpp> // for backend
19 #include <sycl/context.hpp> // for context
20 #include <sycl/detail/backend_traits.hpp> // for BackendI...
21 #include <sycl/device.hpp> // for device
22 #include <sycl/event.hpp> // for event
23 #include <sycl/ext/oneapi/backend/level_zero_ownership.hpp> // for ownership
24 #include <sycl/handler.hpp> // for buffer
25 #include <sycl/image.hpp> // for image
26 #include <sycl/kernel.hpp> // for kernel
27 #include <sycl/kernel_bundle.hpp> // for kernel_b...
28 #include <sycl/kernel_bundle_enums.hpp> // for bundle_s...
29 #include <sycl/platform.hpp> // for platform
30 #include <sycl/property_list.hpp> // for property...
31 #include <sycl/queue.hpp> // for queue
32 #include <sycl/range.hpp> // for range
33 
34 #include <variant> // for variant
35 #include <vector> // for vector
36 
37 typedef struct _ze_command_queue_handle_t *ze_command_queue_handle_t;
38 typedef struct _ze_command_list_handle_t *ze_command_list_handle_t;
39 typedef struct _ze_context_handle_t *ze_context_handle_t;
40 typedef struct _ze_device_handle_t *ze_device_handle_t;
41 typedef struct _ze_driver_handle_t *ze_driver_handle_t;
42 typedef struct _ze_event_handle_t *ze_event_handle_t;
43 typedef struct _ze_image_handle_t *ze_image_handle_t;
44 typedef struct _ze_kernel_handle_t *ze_kernel_handle_t;
45 typedef struct _ze_module_handle_t *ze_module_handle_t;
46 
47 namespace sycl {
48 inline namespace _V1 {
49 namespace detail {
50 
51 // Forward declarations
52 class device_impl;
53 
54 // TODO the interops for context, device, event, platform and program
55 // may be removed after removing the deprecated 'get_native()' methods
56 // from the corresponding classes.
59 };
60 
63 };
64 
65 template <> struct interop<backend::ext_oneapi_level_zero, event> {
67 };
68 
69 template <> struct interop<backend::ext_oneapi_level_zero, queue> {
70  using type =
71  std::variant<ze_command_queue_handle_t, ze_command_list_handle_t>;
72 };
73 
76 };
77 
80 };
81 
83  struct type {
85  std::vector<device> DeviceList;
88  };
89 };
90 
93 };
94 
97 };
98 
101 };
102 
104  struct type {
108  };
109 };
110 
113 };
114 
116  struct type {
120 
122 
124  device dev,
127  property_list properties = {})
128  : NativeHandle(nativeHandle), Ownership(ownership),
129  Properties(properties), Device(dev) {}
130  };
131 };
132 
133 template <typename DataT, int Dimensions, typename AllocatorT>
135  buffer<DataT, Dimensions, AllocatorT>> {
136  struct type {
140  };
141 };
142 
143 template <typename DataT, int Dimensions, typename AllocatorT>
145  buffer<DataT, Dimensions, AllocatorT>> {
146  using type = void *;
147 };
148 
149 template <int Dimensions, typename AllocatorT>
151  image<Dimensions, AllocatorT>> {
152  // LevelZero has no way of getting image description FROM a ZeImageHandle so
153  // it must be provided.
154  struct type {
161  };
162 };
163 
164 template <int Dimensions, typename AllocatorT>
166  image<Dimensions, AllocatorT>> {
168 };
169 
171  using type =
172  std::variant<ze_command_queue_handle_t, ze_command_list_handle_t>;
173 };
174 
177 };
178 
181 };
182 
183 template <bundle_state State>
185  struct type {
189  };
190 };
191 
192 template <bundle_state State>
194  using type = std::vector<ze_module_handle_t>;
195 };
196 
198  struct type {
203  };
204 };
205 
208 };
209 
211  static constexpr bool MakePlatform = true;
212  static constexpr bool MakeDevice = true;
213  static constexpr bool MakeContext = true;
214  static constexpr bool MakeQueue = true;
215  static constexpr bool MakeEvent = true;
216  static constexpr bool MakeKernelBundle = true;
217  static constexpr bool MakeKernel = true;
218  static constexpr bool MakeBuffer = true;
219  static constexpr bool MakeImage = true;
220 };
221 
222 } // namespace detail
223 } // namespace _V1
224 } // namespace sycl
struct _ze_event_handle_t * ze_event_handle_t
struct _ze_command_queue_handle_t * ze_command_queue_handle_t
struct _ze_device_handle_t * ze_device_handle_t
struct _ze_context_handle_t * ze_context_handle_t
struct _ze_command_list_handle_t * ze_command_list_handle_t
struct _ze_image_handle_t * ze_image_handle_t
struct _ze_driver_handle_t * ze_driver_handle_t
struct _ze_module_handle_t * ze_module_handle_t
struct _ze_kernel_handle_t * ze_kernel_handle_t
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:168
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:50
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:64
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:44
Defines a shared image data.
Definition: image.hpp:443
The kernel_bundle class represents collection of device images in a particular state.
Provides an abstraction of a SYCL kernel.
Definition: kernel.hpp:77
Encapsulates a SYCL platform on which kernels may be executed.
Definition: platform.hpp:99
Objects of the property_list class are containers for the SYCL properties.
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:111
image_channel_order
Definition: image.hpp:56
image_channel_type
Definition: image.hpp:74
Definition: access.hpp:18
type(interop< backend::ext_oneapi_level_zero, queue >::type nativeHandle, device dev, ext::oneapi::level_zero::ownership ownership=ext::oneapi::level_zero::ownership::transfer, property_list properties={})
std::variant< ze_command_queue_handle_t, ze_command_list_handle_t > type
std::variant< ze_command_queue_handle_t, ze_command_list_handle_t > type