Skip to content

Commit 6396c62

Browse files
committed
[SYCL][UR] Do not call urDeviceRetain() in device_impl ctor at all
urDeviceRetain(MDevice) should not be called in device_impl ctor at all, because RefCounter is initialized with 1, when the device is created. It fixes URT-961. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent 596d557 commit 6396c62

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

sycl/source/detail/device_impl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ device_impl::device_impl(ur_device_handle_t Device, platform_impl &Platform,
3030
: get_info_impl<UR_DEVICE_INFO_PARENT_DEVICE>()),
3131
// TODO catch an exception and put it to list of asynchronous exceptions:
3232
MCache{*this} {
33-
// Interoperability Constructor already calls DeviceRetain in
34-
// urDeviceCreateWithNativeHandle.
35-
getAdapter().call<UrApiKind::urDeviceRetain>(MDevice);
33+
// urDeviceRetain(MDevice) should not be called here,
34+
// because RefCounter is initialized with 1,
35+
// when the device is created.
3636
}
3737

3838
device_impl::~device_impl() {

sycl/unittests/context_device/DeviceRefCounter.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@ TEST(DevRefCounter, DevRefCounter) {
4343
sycl::platform Plt = sycl::platform();
4444

4545
Plt.get_devices();
46-
EXPECT_NE(DevRefCounter, 0);
47-
// This is the behavior that SYCL performs at shutdown, but there
48-
// are timing differences Lin/Win and shared/static that make
49-
// it not map correctly into our mock.
50-
// So for this test, we just do it.
51-
sycl::detail::GlobalHandler::instance().getPlatformCache().clear();
46+
47+
EXPECT_EQ(DevRefCounter, 0);
5248
}
53-
EXPECT_EQ(DevRefCounter, 0);
5449
}

0 commit comments

Comments
 (0)