@@ -1076,8 +1076,6 @@ static pi_result copyModule(ze_context_handle_t ZeContext,
1076
1076
1077
1077
static bool setEnvVar (const char *var, const char *value);
1078
1078
1079
- static pi_result populateDeviceCacheIfNeeded (pi_platform Platform);
1080
-
1081
1079
// Forward declarations for mock implementations of Level Zero APIs that
1082
1080
// do not yet work in the driver.
1083
1081
// TODO: Remove these mock definitions when they work in the driver.
@@ -1335,7 +1333,7 @@ pi_result piextPlatformCreateWithNativeHandle(pi_native_handle NativeHandle,
1335
1333
// Return NULL if no such PI device found.
1336
1334
pi_device _pi_platform::getDeviceFromNativeHandle (ze_device_handle_t ZeDevice) {
1337
1335
1338
- pi_result Res = populateDeviceCacheIfNeeded (Platform );
1336
+ pi_result Res = populateDeviceCacheIfNeeded ();
1339
1337
if (Res != PI_SUCCESS) {
1340
1338
return nullptr ;
1341
1339
}
@@ -1356,7 +1354,7 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType,
1356
1354
1357
1355
PI_ASSERT (Platform, PI_INVALID_PLATFORM);
1358
1356
1359
- pi_result Res = populateDeviceCacheIfNeeded (Platform );
1357
+ pi_result Res = Platform-> populateDeviceCacheIfNeeded ();
1360
1358
if (Res != PI_SUCCESS) {
1361
1359
return Res;
1362
1360
}
@@ -1415,14 +1413,13 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType,
1415
1413
}
1416
1414
1417
1415
// Check the device cache and load it if necessary.
1418
- static pi_result populateDeviceCacheIfNeeded (pi_platform Platform ) {
1419
- std::lock_guard<std::mutex> Lock (Platform-> PiDevicesCacheMutex );
1416
+ pi_result _pi_platform:: populateDeviceCacheIfNeeded () {
1417
+ std::lock_guard<std::mutex> Lock (PiDevicesCacheMutex);
1420
1418
1421
- if (Platform-> DeviceCachePopulated ) {
1419
+ if (DeviceCachePopulated) {
1422
1420
return PI_SUCCESS;
1423
1421
}
1424
1422
1425
- ze_driver_handle_t ZeDriver = Platform->ZeDriver ;
1426
1423
uint32_t ZeDeviceCount = 0 ;
1427
1424
ZE_CALL (zeDeviceGet, (ZeDriver, &ZeDeviceCount, nullptr ));
1428
1425
@@ -1431,8 +1428,7 @@ static pi_result populateDeviceCacheIfNeeded(pi_platform Platform) {
1431
1428
ZE_CALL (zeDeviceGet, (ZeDriver, &ZeDeviceCount, ZeDevices.data ()));
1432
1429
1433
1430
for (uint32_t I = 0 ; I < ZeDeviceCount; ++I) {
1434
- std::unique_ptr<_pi_device> Device (
1435
- new _pi_device (ZeDevices[I], Platform));
1431
+ std::unique_ptr<_pi_device> Device (new _pi_device (ZeDevices[I], this ));
1436
1432
pi_result Result = Device->initialize ();
1437
1433
if (Result != PI_SUCCESS) {
1438
1434
return Result;
@@ -1453,27 +1449,27 @@ static pi_result populateDeviceCacheIfNeeded(pi_platform Platform) {
1453
1449
// cache.
1454
1450
for (uint32_t I = 0 ; I < SubDevicesCount; ++I) {
1455
1451
std::unique_ptr<_pi_device> PiSubDevice (
1456
- new _pi_device (ZeSubdevices[I], Platform , true ));
1452
+ new _pi_device (ZeSubdevices[I], this , true ));
1457
1453
pi_result Result = PiSubDevice->initialize ();
1458
1454
if (Result != PI_SUCCESS) {
1459
1455
delete[] ZeSubdevices;
1460
1456
return Result;
1461
1457
}
1462
1458
// save pointers to sub-devices for quick retrieval in the future.
1463
1459
Device->SubDevices .push_back (PiSubDevice.get ());
1464
- Platform-> PiDevicesCache .push_back (std::move (PiSubDevice));
1460
+ PiDevicesCache.push_back (std::move (PiSubDevice));
1465
1461
}
1466
1462
delete[] ZeSubdevices;
1467
1463
1468
1464
// Save the root device in the cache for future uses.
1469
- Platform-> PiDevicesCache .push_back (std::move (Device));
1465
+ PiDevicesCache.push_back (std::move (Device));
1470
1466
}
1471
1467
} catch (const std::bad_alloc &) {
1472
1468
return PI_OUT_OF_HOST_MEMORY;
1473
1469
} catch (...) {
1474
1470
return PI_ERROR_UNKNOWN;
1475
1471
}
1476
- Platform-> DeviceCachePopulated = true ;
1472
+ DeviceCachePopulated = true ;
1477
1473
return PI_SUCCESS;
1478
1474
}
1479
1475
@@ -2022,7 +2018,7 @@ pi_result piDevicePartition(pi_device Device,
2022
2018
// Devices cache is normally created in piDevicesGet but still make
2023
2019
// sure that cache is populated.
2024
2020
//
2025
- pi_result Res = populateDeviceCacheIfNeeded ( Device->Platform );
2021
+ pi_result Res = Device->Platform -> populateDeviceCacheIfNeeded ( );
2026
2022
if (Res != PI_SUCCESS) {
2027
2023
return Res;
2028
2024
}
0 commit comments