Skip to content
1 change: 0 additions & 1 deletion sycl/include/CL/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <CL/sycl/platform.hpp>
#include <CL/sycl/stl.hpp>

#include <memory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory was actually used for shared_ptr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was deleted when I tested map. But memory is included in stl.hpp, that included higher. Do I need to return it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. You can't rely on CL/sycl/stl.hpp to include memory header for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned it

#include <utility>

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down
14 changes: 9 additions & 5 deletions sycl/source/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ void force_type(info::device_type &t, const info::device_type &ft) {

device::device() : impl(detail::device_impl::getHostDeviceImpl()) {}

device::device(cl_device_id deviceId)
: impl(std::make_shared<detail::device_impl>(
detail::pi::cast<pi_native_handle>(deviceId),
RT::getPlugin<backend::opencl>())) {
device::device(cl_device_id DeviceId) {
// The implementation constructor takes ownership of the native handle so we
// must retain it in order to adhere to SYCL 1.2.1 spec (Rev6, section 4.3.1.)
clRetainDevice(deviceId);
detail::RT::PiDevice Device;
auto Plugin = detail::RT::getPlugin<backend::opencl>();
Plugin.call<detail::PiApiKind::piextDeviceCreateWithNativeHandle>(
detail::pi::cast<pi_native_handle>(DeviceId), nullptr, &Device);
auto Platform =
detail::platform_impl::getPlatformFromPiDevice(Device, Plugin);
impl = Platform->getOrMakeDeviceImpl(Device, Platform);
clRetainDevice(DeviceId);
}

device::device(const device_selector &deviceSelector) {
Expand Down
9 changes: 5 additions & 4 deletions sycl/source/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ namespace sycl {

platform::platform() : impl(detail::platform_impl::getHostPlatformImpl()) {}

platform::platform(cl_platform_id PlatformId)
: impl(std::make_shared<detail::platform_impl>(
detail::pi::cast<detail::RT::PiPlatform>(PlatformId),
RT::getPlugin<backend::opencl>())) {}
platform::platform(cl_platform_id PlatformId) {
impl = detail::platform_impl::getOrMakePlatformImpl(
detail::pi::cast<detail::RT::PiPlatform>(PlatformId),
detail::RT::getPlugin<backend::opencl>());
}

platform::platform(const device_selector &dev_selector) {
*this = dev_selector.select_device().get_platform();
Expand Down