DPC++ Runtime
Runtime libraries for oneAPI DPC++
|
|
Go to the documentation of this file.
35 return pi::getPlugin<backend::opencl>();
36 case backend::ext_oneapi_level_zero:
37 return pi::getPlugin<backend::ext_oneapi_level_zero>();
38 case backend::ext_oneapi_cuda:
39 return pi::getPlugin<backend::ext_oneapi_cuda>();
41 throw sycl::runtime_error{
"Unsupported backend",
42 PI_ERROR_INVALID_OPERATION};
54 return detail::createSyclObjFromImpl<platform>(
55 platform_impl::getOrMakePlatformImpl(
PiPlatform, Plugin));
66 return detail::createSyclObjFromImpl<device>(
67 std::make_shared<device_impl>(
PiDevice, Plugin));
77 NativeHandle, 0,
nullptr,
false, &
PiContext);
79 return detail::createSyclObjFromImpl<context>(
80 std::make_shared<context_impl>(
PiContext, Handler, Plugin));
91 NativeHandle, ContextImpl->getHandleRef(), Device, !KeepOwnership,
94 return detail::createSyclObjFromImpl<queue>(
95 std::make_shared<queue_impl>(
PiQueue, ContextImpl, Handler));
104 return make_queue_impl(NativeHandle, Context, DeviceImpl->getHandleRef(),
105 KeepOwnership, Handler, Backend);
114 return make_event(NativeHandle, Context,
false, Backend);
118 const context &Context,
bool KeepOwnership,
125 NativeHandle, ContextImpl->getHandleRef(), !KeepOwnership, &
PiEvent);
127 event Event = detail::createSyclObjFromImpl<event>(
128 std::make_shared<event_impl>(
PiEvent, Context));
130 if (Backend == backend::opencl)
135 std::shared_ptr<detail::kernel_bundle_impl>
143 NativeHandle, ContextImpl->getHandleRef(), !KeepOwnership, &
PiProgram);
144 if (Plugin.getBackend() == backend::opencl)
147 std::vector<pi::PiDevice> ProgramDevices;
148 size_t NumDevices = 0;
153 ProgramDevices.resize(NumDevices);
156 ProgramDevices.data(),
nullptr);
158 for (
const auto &Dev : ProgramDevices) {
159 size_t BinaryType = 0;
162 &BinaryType,
nullptr);
163 switch (BinaryType) {
165 if (State == bundle_state::object)
167 PiProgram, 1, &Dev,
nullptr, 0,
nullptr,
nullptr,
nullptr,
nullptr);
168 else if (State == bundle_state::executable)
170 PiProgram, 1, &Dev,
nullptr,
nullptr,
nullptr);
174 if (State == bundle_state::input)
176 throw sycl::runtime_error(errc::invalid,
177 "Program and kernel_bundle state mismatch",
178 PI_ERROR_INVALID_VALUE);
179 if (State == bundle_state::executable)
181 ContextImpl->getHandleRef(), 1, &Dev,
nullptr, 1, &
PiProgram,
185 if (State == bundle_state::input || State == bundle_state::object)
187 throw sycl::runtime_error(errc::invalid,
188 "Program and kernel_bundle state mismatch",
189 PI_ERROR_INVALID_VALUE);
194 std::vector<device> Devices;
195 Devices.reserve(ProgramDevices.size());
197 ProgramDevices.begin(), ProgramDevices.end(), std::back_inserter(Devices),
198 [&Plugin](
const auto &Dev) {
200 detail::platform_impl::getPlatformFromPiDevice(Dev, Plugin);
201 auto DeviceImpl = Platform->getOrMakeDeviceImpl(Dev, Platform);
202 return createSyclObjFromImpl<device>(DeviceImpl);
210 auto KernelIDs = std::make_shared<std::vector<kernel_id>>();
211 auto DevImgImpl = std::make_shared<device_image_impl>(
212 nullptr, TargetContext, Devices, State, KernelIDs,
PiProgram);
215 return std::make_shared<kernel_bundle_impl>(TargetContext, Devices, DevImg);
219 std::shared_ptr<detail::kernel_bundle_impl>
241 if (Backend == backend::ext_oneapi_level_zero) {
242 if (KernelBundleImpl->size() != 1)
243 throw sycl::runtime_error{
244 "make_kernel: kernel_bundle must have single program image",
245 PI_ERROR_INVALID_PROGRAM};
248 *KernelBundle.
begin();
250 PiProgram = DeviceImageImpl->get_program_ref();
256 NativeHandle, ContextImpl->getHandleRef(),
PiProgram, !KeepOwnership,
259 if (Backend == backend::opencl)
263 return detail::createSyclObjFromImpl<kernel>(
264 std::make_shared<kernel_impl>(
PiKernel, ContextImpl, KernelBundleImpl));
271 get_empty_interop_kernel_bundle<bundle_state::executable>(TargetContext),
272 NativeHandle,
false, Backend);
kernel_bundle< bundle_state::executable > build(const kernel_bundle< bundle_state::input > &InputBundle, const std::vector< device > &Devs, const property_list &PropList={})
std::shared_ptr< detail::kernel_bundle_impl > make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext, bundle_state State, backend Backend)
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)
#define __SYCL_INLINE_VER_NAMESPACE(X)
pi_result piProgramRetain(pi_program program)
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 piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform platform, pi_device *device)
Creates PI device object from a native handle.
device_image_iterator begin() const
---— Error handling, matching OpenCL plugin semantics.
Objects of the class represents an instance of an image in a specific state.
kernel make_kernel(pi_native_handle NativeHandle, const context &TargetContext, backend Backend)
pi_result piextEventCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context context, bool ownNativeHandle, pi_event *event)
Creates PI event object from a native handle.
context make_context(pi_native_handle NativeHandle)
static const plugin & getPlugin(backend Backend)
Implementation of a PI Kernel for CUDA.
@ PI_PROGRAM_BINARY_TYPE_NONE
queue make_queue_impl(pi_native_handle NativeHandle, const context &Context, RT::PiDevice Device, bool KeepOwnership, const async_handler &Handler, backend Backend)
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)
Provides an abstraction of a SYCL kernel.
@ PI_PROGRAM_BINARY_TYPE_EXECUTABLE
pi_result piextProgramCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context context, bool pluginOwnsNativeHandle, pi_program *program)
Creates PI program object from a native handle.
queue make_queue(const context &Context, pi_native_handle InteropHandle)
PI queue mapping on to CUstream objects.
The plugin class provides a unified interface to the underlying low-level runtimes for the device-agn...
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
pi_result piKernelRetain(pi_kernel kernel)
pi_result piextPlatformCreateWithNativeHandle(pi_native_handle nativeHandle, pi_platform *platform)
Creates PI platform object from a native handle.
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Implementation of PI Program on CUDA Module object.
uintptr_t pi_native_handle
@ PI_PROGRAM_BINARY_TYPE_COMPILED_OBJECT
pi_result piEventRetain(pi_event event)
PI Event mapping to CUevent.
std::function< void(sycl::exception_list)> async_handler
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)
device make_device(pi_native_handle NativeHandle)
platform make_platform(pi_native_handle NativeHandle)
@ PI_PROGRAM_INFO_DEVICES
@ PI_PROGRAM_INFO_NUM_DEVICES
@ PI_PROGRAM_BINARY_TYPE_LIBRARY
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.
event make_event(pi_native_handle NativeHandle, const context &TargetContext, backend Backend)
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_PROGRAM_BUILD_INFO_BINARY_TYPE
pi_result piextQueueCreateWithNativeHandle(pi_native_handle nativeHandle, pi_context context, pi_device device, bool pluginOwnsNativeHandle, pi_queue *queue)
Creates PI queue object from a native handle.
PI context mapping to a CUDA context object.
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
PI device mapping to a CUdevice.
The context class represents a SYCL context on which kernel functions may be executed.