|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | #include "shared/source/device/sub_device.h" |
| 9 | +#include "shared/source/os_interface/device_factory.h" |
9 | 10 | #include "shared/source/os_interface/os_context.h" |
10 | 11 | #include "shared/test/common/helpers/debug_manager_state_restore.h" |
11 | 12 | #include "shared/test/common/helpers/ult_hw_config.h" |
@@ -265,6 +266,91 @@ TEST(SubDevicesTest, givenRootDeviceWithSubDevicesWhenGettingGlobalMemorySizeThe |
265 | 266 | } |
266 | 267 | } |
267 | 268 |
|
| 269 | +TEST(SubDevicesTest, whenCreatingEngineInstancedSubDeviceThenSetCorrectSubdeviceIndex) { |
| 270 | + class MyRootDevice : public RootDevice { |
| 271 | + public: |
| 272 | + using RootDevice::createEngineInstancedSubDevice; |
| 273 | + using RootDevice::RootDevice; |
| 274 | + }; |
| 275 | + |
| 276 | + auto executionEnvironment = new ExecutionEnvironment(); |
| 277 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 278 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); |
| 279 | + DeviceFactory::createMemoryManagerFunc(*executionEnvironment); |
| 280 | + |
| 281 | + auto rootDevice = std::unique_ptr<MyRootDevice>(Device::create<MyRootDevice>(executionEnvironment, 0)); |
| 282 | + |
| 283 | + auto subDevice = std::unique_ptr<SubDevice>(rootDevice->createEngineInstancedSubDevice(1, defaultHwInfo->capabilityTable.defaultEngineType)); |
| 284 | + |
| 285 | + ASSERT_NE(nullptr, subDevice.get()); |
| 286 | + |
| 287 | + EXPECT_EQ(2u, subDevice->getDeviceBitfield().to_ulong()); |
| 288 | +} |
| 289 | + |
| 290 | +TEST(SubDevicesTest, givenDebugFlagSetAndMoreThanOneCcsWhenCreatingRootDeviceWithoutGenericSubDevicesThenCreateEngineInstanced) { |
| 291 | + DebugManagerStateRestore restorer; |
| 292 | + DebugManager.flags.EngineInstancedSubDevices.set(true); |
| 293 | + |
| 294 | + auto executionEnvironment = new ExecutionEnvironment(); |
| 295 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 296 | + |
| 297 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); |
| 298 | + executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 2; |
| 299 | + |
| 300 | + UltDeviceFactory deviceFactory(1, 1, *executionEnvironment); |
| 301 | + |
| 302 | + auto &rootDevice = deviceFactory.rootDevices[0]; |
| 303 | + auto &hwInfo = rootDevice->getHardwareInfo(); |
| 304 | + uint32_t ccsCount = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; |
| 305 | + |
| 306 | + EXPECT_EQ(ccsCount, rootDevice->getNumAvailableDevices()); |
| 307 | + |
| 308 | + for (uint32_t i = 0; i < ccsCount; i++) { |
| 309 | + auto engineType = static_cast<aub_stream::EngineType>(aub_stream::EngineType::ENGINE_CCS + i); |
| 310 | + auto subDevice = static_cast<MockSubDevice *>(rootDevice->getDeviceById(i)); |
| 311 | + ASSERT_NE(nullptr, subDevice); |
| 312 | + |
| 313 | + EXPECT_TRUE(subDevice->engineInstanced); |
| 314 | + EXPECT_EQ(engineType, subDevice->engineType); |
| 315 | + } |
| 316 | +} |
| 317 | + |
| 318 | +TEST(SubDevicesTest, givenDebugFlagSetAndSingleCcsWhenCreatingRootDeviceWithoutGenericSubDevicesThenCreateEngineInstanced) { |
| 319 | + DebugManagerStateRestore restorer; |
| 320 | + DebugManager.flags.EngineInstancedSubDevices.set(true); |
| 321 | + |
| 322 | + auto executionEnvironment = new ExecutionEnvironment(); |
| 323 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 324 | + |
| 325 | + executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get()); |
| 326 | + executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1; |
| 327 | + |
| 328 | + UltDeviceFactory deviceFactory(1, 1, *executionEnvironment); |
| 329 | + |
| 330 | + auto &rootDevice = deviceFactory.rootDevices[0]; |
| 331 | + |
| 332 | + EXPECT_EQ(1u, rootDevice->getNumAvailableDevices()); |
| 333 | + EXPECT_FALSE(rootDevice->getDeviceById(0)->isSubDevice()); |
| 334 | +} |
| 335 | + |
| 336 | +TEST(SubDevicesTest, givenDebugFlagSetWhenCreatingRootDeviceWithGenericSubDevicesThenDontCreateEngineInstanced) { |
| 337 | + DebugManagerStateRestore restorer; |
| 338 | + DebugManager.flags.EngineInstancedSubDevices.set(true); |
| 339 | + |
| 340 | + UltDeviceFactory deviceFactory(1, 2); |
| 341 | + |
| 342 | + auto &rootDevice = deviceFactory.rootDevices[0]; |
| 343 | + |
| 344 | + for (uint32_t i = 0; i < 2; i++) { |
| 345 | + auto subDevice = static_cast<MockSubDevice *>(rootDevice->getDeviceById(i)); |
| 346 | + ASSERT_NE(nullptr, subDevice); |
| 347 | + |
| 348 | + EXPECT_FALSE(subDevice->engineInstanced); |
| 349 | + EXPECT_EQ(1u, subDevice->getNumAvailableDevices()); |
| 350 | + EXPECT_EQ(aub_stream::EngineType::NUM_ENGINES, subDevice->engineType); |
| 351 | + } |
| 352 | +} |
| 353 | + |
268 | 354 | TEST(SubDevicesTest, whenInitializeRootCsrThenDirectSubmissionIsNotInitialized) { |
269 | 355 | auto device = std::make_unique<MockDevice>(); |
270 | 356 | device->initializeRootCommandStreamReceiver(); |
|
0 commit comments