37 #include <type_traits>
42 inline namespace _V1 {
43 namespace ext::oneapi::level_zero::detail {
45 ur_native_handle_t NativeHandle);
50 inline context make_context<backend::ext_oneapi_level_zero>(
54 const std::vector<device> &DeviceList = BackendObject.DeviceList;
55 ur_native_handle_t NativeHandle =
56 detail::ur::cast<ur_native_handle_t>(BackendObject.NativeHandle);
62 KeepOwnership, DeviceList);
70 if (get_native<backend::ext_oneapi_level_zero>(d) == BackendObject)
72 std::vector<info::partition_property> partition_props =
73 d.
get_info<info::device::partition_properties>();
75 for (
auto pp : partition_props) {
80 for (
auto &sub_dev : sub_devices) {
81 if (
auto maybe_device =
87 assert(
false &&
"Unexpected partitioning scheme for a Level-Zero device!");
109 inline device make_device<backend::ext_oneapi_level_zero>(
116 for (
auto &d : p.get_devices()) {
118 return *maybe_device;
123 "Native device isn't exposed to SYCL.");
128 inline queue make_queue<backend::ext_oneapi_level_zero>(
132 bool IsImmCmdList = std::holds_alternative<ze_command_list_handle_t>(
133 BackendObject.NativeHandle);
134 ur_native_handle_t Handle =
135 IsImmCmdList ?
reinterpret_cast<ur_native_handle_t
>(
136 *(std::get_if<ze_command_list_handle_t>(
137 &BackendObject.NativeHandle)))
138 :
reinterpret_cast<ur_native_handle_t
>(
139 *(std::get_if<ze_command_queue_handle_t>(
140 &BackendObject.NativeHandle)));
143 Handle, IsImmCmdList, TargetContext, &Device,
150 inline auto get_native<backend::ext_oneapi_level_zero, queue>(
const queue &Obj)
152 int32_t IsImmCmdList;
153 ur_native_handle_t Handle = Obj.getNative(IsImmCmdList);
164 inline event make_event<backend::ext_oneapi_level_zero>(
166 const context &TargetContext) {
168 detail::ur::cast<ur_native_handle_t>(BackendObject.NativeHandle),
176 inline kernel_bundle<bundle_state::executable>
177 make_kernel_bundle<backend::ext_oneapi_level_zero, bundle_state::executable>(
179 kernel_bundle<bundle_state::executable>>
181 const context &TargetContext) {
182 std::shared_ptr<detail::kernel_bundle_impl> KBImpl =
184 detail::ur::cast<ur_native_handle_t>(BackendObject.NativeHandle),
188 return detail::createSyclObjFromImpl<kernel_bundle<bundle_state::executable>>(
194 inline kernel make_kernel<backend::ext_oneapi_level_zero>(
197 const context &TargetContext) {
199 TargetContext, BackendObject.KernelBundle,
200 detail::ur::cast<ur_native_handle_t>(BackendObject.NativeHandle),
207 typename AllocatorT = buffer_allocator<std::remove_const_t<T>>>
209 buffer<T, Dimensions, AllocatorT>>
214 return detail::make_buffer_helper<T, Dimensions, AllocatorT>(
215 detail::ur::cast<ur_native_handle_t>(BackendObject.NativeHandle),
216 TargetContext, AvailableEvent,
222 typename AllocatorT = buffer_allocator<std::remove_const_t<T>>>
224 buffer<T, Dimensions, AllocatorT>>
228 const context &TargetContext) {
229 return detail::make_buffer_helper<T, Dimensions, AllocatorT>(
230 detail::ur::cast<ur_native_handle_t>(BackendObject.NativeHandle),
231 TargetContext,
event{},
239 image<Dimensions, AllocatorT>>
244 bool OwnNativeHandle =
248 detail::ur::cast<ur_native_handle_t>(BackendObject.ZeImageHandle),
249 TargetContext, AvailableEvent, BackendObject.ChanOrder,
250 BackendObject.ChanType, OwnNativeHandle, BackendObject.Range);
255 using namespace ext::oneapi::level_zero;
struct _ze_command_queue_handle_t * ze_command_queue_handle_t
struct _ze_command_list_handle_t * ze_command_list_handle_t
Defines a shared array that can be used by kernels in queues.
The context class represents a SYCL context on which kernel functions may be executed.
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
std::vector< device > create_sub_devices(size_t ComputeUnits) const
Partition device into sub devices.
detail::is_device_info_desc< Param >::return_type get_info() const
Queries this SYCL device for information requested by the template parameter param.
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Defines a shared image data.
Provides an abstraction of a SYCL kernel.
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
queue make_queue(ur_native_handle_t NativeHandle, int32_t nativeHandleDesc, const context &TargetContext, const device *TargetDevice, bool KeepOwnership, const property_list &PropList, const async_handler &Handler, backend Backend)
std::optional< sycl::device > find_matching_descendent_device(sycl::device d, const backend_input_t< backend::ext_oneapi_level_zero, device > &BackendObject)
context make_context(ur_native_handle_t NativeHandle, const async_handler &Handler, backend Backend, bool KeepOwnership, const std::vector< device > &DeviceList={})
std::shared_ptr< detail::kernel_bundle_impl > make_kernel_bundle(ur_native_handle_t NativeHandle, const context &TargetContext, bundle_state State, backend Backend)
event make_event(ur_native_handle_t NativeHandle, const context &TargetContext, backend Backend)
kernel make_kernel(ur_native_handle_t NativeHandle, const context &TargetContext, backend Backend)
device make_device(const platform &Platform, ur_native_handle_t NativeHandle)
@ partition_by_affinity_domain
class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions
signed char __SYCL2020_DEPRECATED
typename backend_traits< Backend >::template return_type< SyclType > backend_return_t
std::enable_if_t< detail::InteropFeatureSupportMap< Backend >::MakeImage==true &&Backend !=backend::ext_oneapi_level_zero, image< Dimensions, AllocatorT > > make_image(const typename backend_traits< Backend >::template input_type< image< Dimensions, AllocatorT >> &BackendObject, const context &TargetContext, event AvailableEvent={})
std::function< void(sycl::exception_list)> async_handler
detail::aligned_allocator< byte > image_allocator
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
std::enable_if_t< detail::InteropFeatureSupportMap< Backend >::MakeBuffer==true &&Backend !=backend::ext_oneapi_level_zero, buffer< T, Dimensions, AllocatorT > > make_buffer(const typename backend_traits< Backend >::template input_type< buffer< T, Dimensions, AllocatorT >> &BackendObject, const context &TargetContext, event AvailableEvent={})
typename backend_traits< Backend >::template input_type< SyclType > backend_input_t
C++ utilities for Unified Runtime integration.