Skip to content

Commit b0751ee

Browse files
committed
[SYCL] remove lock from read-only getDeviceFromNativeHandle
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 47c9403 commit b0751ee

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,11 @@ pi_result piextPlatformCreateWithNativeHandle(pi_native_handle NativeHandle,
13351335
// Return NULL if no such PI device found.
13361336
pi_device _pi_platform::getDeviceFromNativeHandle(ze_device_handle_t ZeDevice) {
13371337

1338-
std::lock_guard<std::mutex> Lock(this->PiDevicesCacheMutex);
1338+
pi_result Res = populateDeviceCacheIfNeeded(Platform);
1339+
if (Res != PI_SUCCESS) {
1340+
return nullptr;
1341+
}
1342+
13391343
auto it = std::find_if(PiDevicesCache.begin(), PiDevicesCache.end(),
13401344
[&](std::unique_ptr<_pi_device> &D) {
13411345
return D.get()->ZeDevice == ZeDevice;
@@ -2029,6 +2033,9 @@ pi_result piDevicePartition(pi_device Device,
20292033

20302034
if (OutDevices) {
20312035
// TODO: Consider support for partitioning to <= total sub-devices.
2036+
// Currently supported partitioning (by affinity domain/numa) would always
2037+
// partition to all sub-devices.
2038+
//
20322039
PI_ASSERT(NumDevices == Device->SubDevices.size(), PI_INVALID_VALUE);
20332040

20342041
for (uint32_t I = 0; I < NumDevices; I++) {
@@ -2105,10 +2112,6 @@ pi_result piextDeviceCreateWithNativeHandle(pi_native_handle NativeHandle,
21052112
PI_ASSERT(NativeHandle, PI_INVALID_VALUE);
21062113
PI_ASSERT(Platform, PI_INVALID_PLATFORM);
21072114

2108-
pi_result Res = populateDeviceCacheIfNeeded(Platform);
2109-
if (Res != PI_SUCCESS) {
2110-
return Res;
2111-
}
21122115
auto ZeDevice = pi_cast<ze_device_handle_t>(NativeHandle);
21132116

21142117
// The SYCL spec requires that the set of devices must remain fixed for the

0 commit comments

Comments
 (0)