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 " +
65 "convertBackend: Unsupported backend");
76 return detail::createSyclObjFromImpl<platform>(
88 return detail::createSyclObjFromImpl<device>(
89 std::make_shared<device_impl>(
PiDevice, Plugin));
94 backend Backend,
bool KeepOwnership,
95 const std::vector<device> &DeviceList) {
99 std::vector<pi_device> DeviceHandles;
100 for (
auto Dev : DeviceList) {
104 NativeHandle, DeviceHandles.size(), DeviceHandles.data(),
false,
107 return detail::createSyclObjFromImpl<context>(std::make_shared<context_impl>(
108 PiContext, Handler, Plugin, DeviceList, !KeepOwnership));
112 int32_t NativeHandleDesc,
const context &Context,
113 const device *Device,
bool KeepOwnership,
125 PropList, PropList.
has_property<property::queue::in_order>()
132 "Queue create using make_queue cannot have compute_index property.");
138 NativeHandle, NativeHandleDesc, ContextImpl->getHandleRef(),
PiDevice,
139 !KeepOwnership, Properties, &
PiQueue);
141 return detail::createSyclObjFromImpl<queue>(
142 std::make_shared<queue_impl>(
PiQueue, ContextImpl, Handler, PropList));
147 return make_event(NativeHandle, Context,
false, Backend);
151 const context &Context,
bool KeepOwnership,
158 NativeHandle, ContextImpl->getHandleRef(), !KeepOwnership, &
PiEvent);
160 event Event = detail::createSyclObjFromImpl<event>(
161 std::make_shared<event_impl>(
PiEvent, Context));
168 std::shared_ptr<detail::kernel_bundle_impl>
176 NativeHandle, ContextImpl->getHandleRef(), !KeepOwnership, &
PiProgram);
180 std::vector<pi::PiDevice> ProgramDevices;
181 uint32_t NumDevices = 0;
186 ProgramDevices.resize(NumDevices);
189 ProgramDevices.data(),
nullptr);
191 for (
const auto &Dev : ProgramDevices) {
192 size_t BinaryType = 0;
195 &BinaryType,
nullptr);
196 switch (BinaryType) {
200 PiProgram, 1, &Dev,
nullptr, 0,
nullptr,
nullptr,
nullptr,
nullptr);
203 PiProgram, 1, &Dev,
nullptr,
nullptr,
nullptr);
209 "Program and kernel_bundle state mismatch " +
213 ContextImpl->getHandleRef(), 1, &Dev,
nullptr, 1, &
PiProgram,
219 "Program and kernel_bundle state mismatch " +
225 std::vector<device> Devices;
226 Devices.reserve(ProgramDevices.size());
228 ProgramDevices.begin(), ProgramDevices.end(), std::back_inserter(Devices),
229 [&Plugin](
const auto &Dev) {
231 detail::platform_impl::getPlatformFromPiDevice(Dev, Plugin);
232 auto DeviceImpl = Platform->getOrMakeDeviceImpl(Dev, Platform);
233 return createSyclObjFromImpl<device>(DeviceImpl);
241 auto KernelIDs = std::make_shared<std::vector<kernel_id>>();
242 auto DevImgImpl = std::make_shared<device_image_impl>(
243 nullptr, TargetContext, Devices, State, KernelIDs,
PiProgram);
246 return std::make_shared<kernel_bundle_impl>(TargetContext, Devices, DevImg);
250 std::shared_ptr<detail::kernel_bundle_impl>
273 if (KernelBundleImpl->size() != 1)
276 "make_kernel: kernel_bundle must have single program image " +
280 *KernelBundle.
begin();
282 PiProgram = DeviceImageImpl->get_program_ref();
288 NativeHandle, ContextImpl->getHandleRef(),
PiProgram, !KeepOwnership,
295 return detail::createSyclObjFromImpl<kernel>(
296 std::make_shared<kernel_impl>(
PiKernel, ContextImpl, KernelBundleImpl));
303 get_empty_interop_kernel_bundle<bundle_state::executable>(TargetContext),
304 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)
decltype(Obj::impl) const & getSyclObjImpl(const Obj &SyclObject)
kernel make_kernel(pi_native_handle NativeHandle, const context &TargetContext, backend Backend)
context make_context(pi_native_handle NativeHandle, const async_handler &Handler, backend Backend, bool KeepOwnership, const std::vector< device > &DeviceList={})
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)
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_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.