@@ -53,8 +53,8 @@ class DriverLinuxFixture : public ::testing::Test {
53
53
static constexpr uint32_t numRootDevices = 5u ;
54
54
static constexpr uint32_t numSubDevices = 2u ;
55
55
std::vector<std::unique_ptr<NEO::Device>> devices;
56
- std::string bdf[numRootDevices] = {" 03:04.0" , " 08:02.0" , " 08:03.1" , " 10:03.0" , " 02:01.0" };
57
- std::string sortedBdf[numRootDevices] = {" 02:01.0" , " 03:04.0" , " 08:02.0" , " 08:03.1" , " 10:03.0" };
56
+ std::string bdf[numRootDevices] = {" 0000: 03:04.0" , " 0000: 08:02.0" , " 0000: 08:03.1" , " 0000: 10:03.0" , " 0000: 02:01.0" };
57
+ std::string sortedBdf[numRootDevices] = {" 0000: 02:01.0" , " 0000: 03:04.0" , " 0000: 08:02.0" , " 0000: 08:03.1" , " 0000: 10:03.0" };
58
58
std::unique_ptr<UltDeviceFactory> deviceFactory;
59
59
};
60
60
@@ -147,8 +147,8 @@ class DriverPciOrderWitSimilarBusLinuxFixture : public ::testing::Test {
147
147
static constexpr uint32_t numRootDevices = 4u ;
148
148
static constexpr uint32_t numSubDevices = 2u ;
149
149
std::vector<std::unique_ptr<NEO::Device>> devices;
150
- std::string bdf[numRootDevices] = {" 03:04.0" , " 03:05.0" , " 03:06.0" , " 03:01.0" };
151
- std::string sortedBdf[numRootDevices] = {" 03:01.0" , " 03:04.0" , " 03:05.0" , " 03:06.0" };
150
+ std::string bdf[numRootDevices] = {" 0000: 03:04.0" , " 0000: 03:05.0" , " 0000: 03:06.0" , " 0000: 03:01.0" };
151
+ std::string sortedBdf[numRootDevices] = {" 0000: 03:01.0" , " 0000: 03:04.0" , " 0000: 03:05.0" , " 0000: 03:06.0" };
152
152
std::unique_ptr<UltDeviceFactory> deviceFactory;
153
153
};
154
154
@@ -198,8 +198,8 @@ class DriverPciOrderWitDifferentDeviceLinuxFixture : public ::testing::Test {
198
198
static constexpr uint32_t numRootDevices = 2u ;
199
199
static constexpr uint32_t numSubDevices = 2u ;
200
200
std::vector<std::unique_ptr<NEO::Device>> devices;
201
- std::string bdf[numRootDevices] = {" 03:05.0" , " 03:04.0" };
202
- std::string sortedBdf[numRootDevices] = {" 03:04.0" , " 03:05.0" };
201
+ std::string bdf[numRootDevices] = {" 0000: 03:05.0" , " 0000: 03:04.0" };
202
+ std::string sortedBdf[numRootDevices] = {" 0000: 03:04.0" , " 0000: 03:05.0" };
203
203
std::unique_ptr<UltDeviceFactory> deviceFactory;
204
204
};
205
205
@@ -249,8 +249,8 @@ class DriverPciOrderWitSimilarBusAndDeviceLinuxFixture : public ::testing::Test
249
249
static constexpr uint32_t numRootDevices = 2u ;
250
250
static constexpr uint32_t numSubDevices = 2u ;
251
251
std::vector<std::unique_ptr<NEO::Device>> devices;
252
- std::string bdf[numRootDevices] = {" 03:04.1" , " 03:04.0" };
253
- std::string sortedBdf[numRootDevices] = {" 03:04.0" , " 03:04.1" };
252
+ std::string bdf[numRootDevices] = {" 0000: 03:04.1" , " 0000: 03:04.0" };
253
+ std::string sortedBdf[numRootDevices] = {" 0000: 03:04.0" , " 0000: 03:04.1" };
254
254
std::unique_ptr<UltDeviceFactory> deviceFactory;
255
255
};
256
256
@@ -271,5 +271,56 @@ TEST_F(DriverPciOrderWitSimilarBusAndDeviceLinuxFixture, GivenEnvironmentVariabl
271
271
delete driverHandle;
272
272
}
273
273
274
+ class DriverPciOrderWitSimilarBDFLinuxFixture : public ::testing::Test {
275
+ public:
276
+ void SetUp () override {
277
+ DebugManagerStateRestore restorer;
278
+ DebugManager.flags .ZE_ENABLE_PCI_ID_DEVICE_ORDER .set (1 );
279
+
280
+ NEO::MockCompilerEnableGuard mock (true );
281
+ auto executionEnvironment = new NEO::ExecutionEnvironment ();
282
+ executionEnvironment->prepareRootDeviceEnvironments (numRootDevices);
283
+ NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get ();
284
+ for (auto i = 0u ; i < executionEnvironment->rootDeviceEnvironments .size (); i++) {
285
+ executionEnvironment->rootDeviceEnvironments [i]->setHwInfo (&hwInfo);
286
+ }
287
+ deviceFactory = std::make_unique<UltDeviceFactory>(numRootDevices, numSubDevices, *executionEnvironment);
288
+ for (auto i = 0u ; i < executionEnvironment->rootDeviceEnvironments .size (); i++) {
289
+ devices.push_back (std::unique_ptr<NEO::Device>(deviceFactory->rootDevices [i]));
290
+ }
291
+ for (auto i = 0u ; i < devices.size (); i++) {
292
+ devices[i]->getExecutionEnvironment ()->rootDeviceEnvironments [i]->osInterface = std::make_unique<NEO::OSInterface>();
293
+ auto osInterface = devices[i]->getExecutionEnvironment ()->rootDeviceEnvironments [i]->osInterface .get ();
294
+ osInterface->setDriverModel (std::make_unique<TestDriverMockDrm>(bdf[i], const_cast <NEO::RootDeviceEnvironment &>(devices[i]->getRootDeviceEnvironment ())));
295
+ }
296
+ executionEnvironment->sortNeoDevices ();
297
+ }
298
+ void TearDown () override {}
299
+
300
+ static constexpr uint32_t numRootDevices = 2u ;
301
+ static constexpr uint32_t numSubDevices = 2u ;
302
+ std::vector<std::unique_ptr<NEO::Device>> devices;
303
+ std::string bdf[numRootDevices] = {" 0001:03:04.0" , " 0000:03:04.0" };
304
+ std::string sortedBdf[numRootDevices] = {" 0000:03:04.0" , " 0001:03:04.0" };
305
+ std::unique_ptr<UltDeviceFactory> deviceFactory;
306
+ };
307
+
308
+ TEST_F (DriverPciOrderWitSimilarBDFLinuxFixture, GivenEnvironmentVariableForDeviceOrderAccordingToPciSetWhenRetrievingNeoDevicesThenNeoDevicesAccordingToDomainOrderRetrieved) {
309
+ NEO::MockCompilerEnableGuard mock (true );
310
+ DriverHandleImp *driverHandle = new DriverHandleImp;
311
+
312
+ EXPECT_EQ (ZE_RESULT_SUCCESS, driverHandle->initialize (std::move (devices)));
313
+
314
+ for (uint32_t i = 0 ; i < numRootDevices; i++) {
315
+ auto L0Device = driverHandle->devices [i];
316
+ if (L0Device != nullptr ) {
317
+ auto pDrm = L0Device->getNEODevice ()->getExecutionEnvironment ()->rootDeviceEnvironments [L0Device->getRootDeviceIndex ()]->osInterface ->getDriverModel ()->as <Drm>();
318
+ EXPECT_NE (pDrm, nullptr );
319
+ EXPECT_TRUE (!pDrm->getPciPath ().compare (sortedBdf[i]));
320
+ }
321
+ }
322
+ delete driverHandle;
323
+ }
324
+
274
325
} // namespace ult
275
326
} // namespace L0
0 commit comments