29 inline namespace _V1 {
35 return pi::getPlugin<backend::opencl>();
37 return pi::getPlugin<backend::ext_oneapi_level_zero>();
39 return pi::getPlugin<backend::ext_oneapi_cuda>();
41 return pi::getPlugin<backend::ext_oneapi_hip>();
44 "getPlugin: Unsupported backend " +
62 return backend::ext_intel_esimd_emulator;
66 throw sycl::runtime_error{
"convertBackend: Unsupported backend",
67 PI_ERROR_INVALID_OPERATION};
78 return detail::createSyclObjFromImpl<platform>(
90 return detail::createSyclObjFromImpl<device>(
91 std::make_shared<device_impl>(
PiDevice, Plugin));
101 NativeHandle, 0,
nullptr,
false, &
PiContext);
103 return detail::createSyclObjFromImpl<context>(
104 std::make_shared<context_impl>(
PiContext, Handler, Plugin));
108 int32_t NativeHandleDesc,
const context &Context,
109 const device *Device,
bool KeepOwnership,
121 PropList, PropList.
has_property<property::queue::in_order>()
128 "Queue create using make_queue cannot have compute_index property.");
134 NativeHandle, NativeHandleDesc, ContextImpl->getHandleRef(),
PiDevice,
135 !KeepOwnership, Properties, &
PiQueue);
137 return detail::createSyclObjFromImpl<queue>(
138 std::make_shared<queue_impl>(
PiQueue, ContextImpl, Handler, PropList));
143 return make_event(NativeHandle, Context,
false, Backend);
147 const context &Context,
bool KeepOwnership,
154 NativeHandle, ContextImpl->getHandleRef(), !KeepOwnership, &
PiEvent);
156 event Event = detail::createSyclObjFromImpl<event>(
157 std::make_shared<event_impl>(
PiEvent, Context));
164 std::shared_ptr<detail::kernel_bundle_impl>
172 NativeHandle, ContextImpl->getHandleRef(), !KeepOwnership, &
PiProgram);
176 std::vector<pi::PiDevice> ProgramDevices;
177 uint32_t NumDevices = 0;
182 ProgramDevices.resize(NumDevices);
185 ProgramDevices.data(),
nullptr);
187 for (
const auto &Dev : ProgramDevices) {
188 size_t BinaryType = 0;
191 &BinaryType,
nullptr);
192 switch (BinaryType) {
196 PiProgram, 1, &Dev,
nullptr, 0,
nullptr,
nullptr,
nullptr,
nullptr);
199 PiProgram, 1, &Dev,
nullptr,
nullptr,
nullptr);
205 "Program and kernel_bundle state mismatch " +
209 ContextImpl->getHandleRef(), 1, &Dev,
nullptr, 1, &
PiProgram,
215 "Program and kernel_bundle state mismatch " +
221 std::vector<device> Devices;
222 Devices.reserve(ProgramDevices.size());
224 ProgramDevices.begin(), ProgramDevices.end(), std::back_inserter(Devices),
225 [&Plugin](
const auto &Dev) {
227 detail::platform_impl::getPlatformFromPiDevice(Dev, Plugin);
228 auto DeviceImpl = Platform->getOrMakeDeviceImpl(Dev, Platform);
229 return createSyclObjFromImpl<device>(DeviceImpl);
237 auto KernelIDs = std::make_shared<std::vector<kernel_id>>();
238 auto DevImgImpl = std::make_shared<device_image_impl>(
239 nullptr, TargetContext, Devices, State, KernelIDs,
PiProgram);
242 return std::make_shared<kernel_bundle_impl>(TargetContext, Devices, DevImg);
246 std::shared_ptr<detail::kernel_bundle_impl>
269 if (KernelBundleImpl->size() != 1)
272 "make_kernel: kernel_bundle must have single program image " +
276 *KernelBundle.
begin();
278 PiProgram = DeviceImageImpl->get_program_ref();
284 NativeHandle, ContextImpl->getHandleRef(),
PiProgram, !KeepOwnership,
291 return detail::createSyclObjFromImpl<kernel>(
292 std::make_shared<kernel_impl>(
PiKernel, ContextImpl, KernelBundleImpl));
299 get_empty_interop_kernel_bundle<bundle_state::executable>(TargetContext),
300 NativeHandle,
false, Backend);
The context class represents a SYCL context on which kernel functions may be executed.
static sycl::detail::pi::PiQueueProperties createPiQueueProperties(const property_list &PropList, QueueOrder Order)
Creates PI properties array.
Objects of the class represents an instance of an image in a specific state.
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
device_image_iterator begin() const
Provides an abstraction of a SYCL kernel.
Objects of the property_list class are containers for the SYCL properties.
bool has_property() const noexcept
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
::pi_queue_properties PiQueueProperties
backend convertBackend(pi_platform_backend PiBackend)
context make_context(pi_native_handle NativeHandle, const async_handler &Handler, backend Backend)
kernel make_kernel(pi_native_handle NativeHandle, const context &TargetContext, backend Backend)
queue make_queue(pi_native_handle NativeHandle, int32_t nativeHandleDesc, const context &TargetContext, const device *TargetDevice, bool KeepOwnership, const property_list &PropList, const async_handler &Handler, backend Backend)
std::string codeToString(pi_int32 code)
platform make_platform(pi_native_handle NativeHandle, backend Backend)
static const PluginPtr & getPlugin(backend Backend)
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
device make_device(pi_native_handle NativeHandle, backend Backend)
event make_event(pi_native_handle NativeHandle, const context &TargetContext, backend Backend)
std::shared_ptr< plugin > PluginPtr
std::shared_ptr< detail::kernel_bundle_impl > make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext, bundle_state State, backend Backend)
std::function< void(sycl::exception_list)> async_handler
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
uintptr_t pi_native_handle
pi_result piProgramGetBuildInfo(pi_program program, pi_device device, _pi_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
pi_result piextProgramCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context context, bool pluginOwnsNativeHandle, pi_program *program)
Creates PI program object from a native handle.
pi_result piProgramRetain(pi_program program)
pi_result piKernelRetain(pi_kernel kernel)
pi_result piextPlatformCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform *platform)
Creates PI platform object from a native handle.
pi_result piextContextCreateWithNativeHandle(pi_native_handle nativeHandle, pi_uint32 numDevices, const pi_device *devices, bool pluginOwnsNativeHandle, pi_context *context)
Creates PI context object from a native handle.
pi_result piProgramGetInfo(pi_program program, pi_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
pi_result piProgramBuild(pi_program program, pi_uint32 num_devices, const pi_device *device_list, const char *options, void(*pfn_notify)(pi_program program, void *user_data), void *user_data)
pi_result piextEventCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context context, bool ownNativeHandle, pi_event *event)
Creates PI event object from a native handle.
constexpr pi_queue_properties PI_QUEUE_FLAGS
pi_result piProgramLink(pi_context context, pi_uint32 num_devices, const pi_device *device_list, const char *options, pi_uint32 num_input_programs, const pi_program *input_programs, void(*pfn_notify)(pi_program program, void *user_data), void *user_data, pi_program *ret_program)
pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform platform, pi_device *device)
Creates PI device object from a native handle.
pi_result piProgramCompile(pi_program program, pi_uint32 num_devices, const pi_device *device_list, const char *options, pi_uint32 num_input_headers, const pi_program *input_headers, const char **header_include_names, void(*pfn_notify)(pi_program program, void *user_data), void *user_data)
pi_result piextKernelCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context context, pi_program program, bool pluginOwnsNativeHandle, pi_kernel *kernel)
Creates PI kernel object from a native handle.
@ PI_EXT_PLATFORM_BACKEND_OPENCL
The backend is OpenCL.
@ PI_EXT_PLATFORM_BACKEND_NATIVE_CPU
The backend is NATIVE_CPU.
@ PI_EXT_PLATFORM_BACKEND_UNKNOWN
The backend is not a recognized one.
@ PI_EXT_PLATFORM_BACKEND_LEVEL_ZERO
The backend is Level Zero.
@ PI_EXT_PLATFORM_BACKEND_ESIMD
The backend is ESIMD.
@ PI_EXT_PLATFORM_BACKEND_HIP
The backend is HIP.
@ PI_EXT_PLATFORM_BACKEND_CUDA
The backend is CUDA.
@ PI_PROGRAM_INFO_NUM_DEVICES
@ PI_PROGRAM_INFO_DEVICES
pi_result piextQueueCreateWithNativeHandle(pi_native_handle nativeHandle, int32_t nativeHandleDesc, pi_context context, pi_device device, bool pluginOwnsNativeHandle, pi_queue_properties *Properties, pi_queue *queue)
Creates PI queue object from a native handle.
@ PI_PROGRAM_BINARY_TYPE_LIBRARY
@ PI_PROGRAM_BINARY_TYPE_EXECUTABLE
@ PI_PROGRAM_BINARY_TYPE_COMPILED_OBJECT
@ PI_PROGRAM_BINARY_TYPE_NONE
pi_result piEventRetain(pi_event event)
@ PI_PROGRAM_BUILD_INFO_BINARY_TYPE
C++ wrapper of extern "C" PI interfaces.