File tree 2 files changed +14
-9
lines changed
2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,17 @@ void force_type(info::device_type &t, const info::device_type &ft) {
30
30
31
31
device::device () : impl(detail::device_impl::getHostDeviceImpl()) {}
32
32
33
- device::device (cl_device_id deviceId)
34
- : impl(std::make_shared<detail::device_impl>(
35
- detail::pi ::cast<pi_native_handle>(deviceId),
36
- RT::getPlugin<backend::opencl>())) {
33
+ device::device (cl_device_id DeviceId) {
37
34
// The implementation constructor takes ownership of the native handle so we
38
35
// must retain it in order to adhere to SYCL 1.2.1 spec (Rev6, section 4.3.1.)
39
- clRetainDevice (deviceId);
36
+ detail::RT::PiDevice Device;
37
+ auto Plugin = detail::RT::getPlugin<backend::opencl>();
38
+ Plugin.call <detail::PiApiKind::piextDeviceCreateWithNativeHandle>(
39
+ detail::pi ::cast<pi_native_handle>(DeviceId), nullptr , &Device);
40
+ auto Platform =
41
+ detail::platform_impl::getPlatformFromPiDevice (Device, Plugin);
42
+ impl = Platform->getOrMakeDeviceImpl (Device, Platform);
43
+ clRetainDevice (DeviceId);
40
44
}
41
45
42
46
device::device (const device_selector &deviceSelector) {
Original file line number Diff line number Diff line change @@ -19,10 +19,11 @@ namespace sycl {
19
19
20
20
platform::platform () : impl(detail::platform_impl::getHostPlatformImpl()) {}
21
21
22
- platform::platform (cl_platform_id PlatformId)
23
- : impl(std::make_shared<detail::platform_impl>(
24
- detail::pi ::cast<detail::RT::PiPlatform>(PlatformId),
25
- RT::getPlugin<backend::opencl>())) {}
22
+ platform::platform (cl_platform_id PlatformId) {
23
+ impl = detail::platform_impl::getOrMakePlatformImpl (
24
+ detail::pi ::cast<detail::RT::PiPlatform>(PlatformId),
25
+ detail::RT::getPlugin<backend::opencl>());
26
+ }
26
27
27
28
platform::platform (const device_selector &dev_selector) {
28
29
*this = dev_selector.select_device ().get_platform ();
You can’t perform that action at this time.
0 commit comments