|
21 | 21 | #include "shared/source/utilities/tag_allocator.h" |
22 | 22 | #include "shared/test/common/helpers/debug_manager_state_restore.h" |
23 | 23 | #include "shared/test/common/mocks/mock_graphics_allocation.h" |
| 24 | +#include "shared/test/common/mocks/ult_device_factory.h" |
| 25 | +#include "shared/test/common/test_macros/test_checks_shared.h" |
24 | 26 |
|
25 | 27 | #include "opencl/source/mem_obj/buffer.h" |
26 | 28 | #include "opencl/source/platform/platform.h" |
@@ -1231,6 +1233,78 @@ HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadWhenTerminatingAtSecond |
1231 | 1233 | EXPECT_EQ(1u, confirmationCounter); |
1232 | 1234 | } |
1233 | 1235 |
|
| 1236 | +HWTEST_F(CommandStreamReceiverTest, givenDebugFlagWhenCreatingCsrThenSetEnableStaticPartitioningAccordingly) { |
| 1237 | + DebugManagerStateRestore restore{}; |
| 1238 | + { |
| 1239 | + MockDevice device{}; |
| 1240 | + EXPECT_FALSE(device.getUltCommandStreamReceiver<FamilyType>().staticWorkPartitioningEnabled); |
| 1241 | + } |
| 1242 | + { |
| 1243 | + DebugManager.flags.EnableStaticPartitioning.set(0); |
| 1244 | + MockDevice device{}; |
| 1245 | + EXPECT_FALSE(device.getUltCommandStreamReceiver<FamilyType>().staticWorkPartitioningEnabled); |
| 1246 | + } |
| 1247 | + { |
| 1248 | + DebugManager.flags.EnableStaticPartitioning.set(1); |
| 1249 | + MockDevice device{}; |
| 1250 | + EXPECT_TRUE(device.getUltCommandStreamReceiver<FamilyType>().staticWorkPartitioningEnabled); |
| 1251 | + } |
| 1252 | +} |
| 1253 | + |
| 1254 | +HWTEST_F(CommandStreamReceiverTest, whenCreatingWorkPartitionAllocationThenInitializeContentsWithCopyEngine) { |
| 1255 | + REQUIRE_BLITTER_OR_SKIP(defaultHwInfo.get()); |
| 1256 | + DebugManagerStateRestore restore{}; |
| 1257 | + DebugManager.flags.EnableStaticPartitioning.set(0); |
| 1258 | + |
| 1259 | + constexpr size_t subDeviceCount = 3; |
| 1260 | + UltDeviceFactory deviceFactory{1, subDeviceCount}; |
| 1261 | + MockDevice &rootDevice = *deviceFactory.rootDevices[0]; |
| 1262 | + rootDevice.getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true; |
| 1263 | + rootDevice.getRootDeviceEnvironment().getMutableHardwareInfo()->featureTable.ftrBcsInfo = 1; |
| 1264 | + UltCommandStreamReceiver<FamilyType> &csr = rootDevice.getUltCommandStreamReceiver<FamilyType>(); |
| 1265 | + UltCommandStreamReceiver<FamilyType> *bcsCsrs[] = { |
| 1266 | + reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(rootDevice.getDeviceById(0)->getEngine(aub_stream::ENGINE_BCS, false, false).commandStreamReceiver), |
| 1267 | + reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(rootDevice.getDeviceById(1)->getEngine(aub_stream::ENGINE_BCS, false, false).commandStreamReceiver), |
| 1268 | + reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(rootDevice.getDeviceById(2)->getEngine(aub_stream::ENGINE_BCS, false, false).commandStreamReceiver), |
| 1269 | + }; |
| 1270 | + const size_t bcsStarts[] = { |
| 1271 | + bcsCsrs[0]->commandStream.getUsed(), |
| 1272 | + bcsCsrs[1]->commandStream.getUsed(), |
| 1273 | + bcsCsrs[2]->commandStream.getUsed(), |
| 1274 | + }; |
| 1275 | + |
| 1276 | + csr.staticWorkPartitioningEnabled = true; |
| 1277 | + EXPECT_TRUE(csr.createWorkPartitionAllocation(rootDevice)); |
| 1278 | + EXPECT_NE(nullptr, csr.getWorkPartitionAllocation()); |
| 1279 | + |
| 1280 | + EXPECT_LT(bcsStarts[0], bcsCsrs[0]->commandStream.getUsed()); |
| 1281 | + EXPECT_LT(bcsStarts[1], bcsCsrs[1]->commandStream.getUsed()); |
| 1282 | + EXPECT_LT(bcsStarts[2], bcsCsrs[2]->commandStream.getUsed()); |
| 1283 | +} |
| 1284 | + |
| 1285 | +HWTEST_F(CommandStreamReceiverTest, givenFailingMemoryManagerWhenCreatingWorkPartitionAllocationThenReturnFalse) { |
| 1286 | + struct FailingMemoryManager : OsAgnosticMemoryManager { |
| 1287 | + using OsAgnosticMemoryManager::OsAgnosticMemoryManager; |
| 1288 | + GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) override { |
| 1289 | + return nullptr; |
| 1290 | + } |
| 1291 | + }; |
| 1292 | + |
| 1293 | + DebugManagerStateRestore restore{}; |
| 1294 | + DebugManager.flags.EnableStaticPartitioning.set(0); |
| 1295 | + UltDeviceFactory deviceFactory{1, 2}; |
| 1296 | + MockDevice &rootDevice = *deviceFactory.rootDevices[0]; |
| 1297 | + UltCommandStreamReceiver<FamilyType> &csr = rootDevice.getUltCommandStreamReceiver<FamilyType>(); |
| 1298 | + |
| 1299 | + ExecutionEnvironment &executionEnvironment = *deviceFactory.rootDevices[0]->executionEnvironment; |
| 1300 | + executionEnvironment.memoryManager = std::make_unique<FailingMemoryManager>(executionEnvironment); |
| 1301 | + |
| 1302 | + csr.staticWorkPartitioningEnabled = true; |
| 1303 | + DebugManager.flags.EnableStaticPartitioning.set(1); |
| 1304 | + EXPECT_FALSE(csr.createWorkPartitionAllocation(rootDevice)); |
| 1305 | + EXPECT_EQ(nullptr, csr.getWorkPartitionAllocation()); |
| 1306 | +} |
| 1307 | + |
1234 | 1308 | class CommandStreamReceiverWithAubSubCaptureTest : public CommandStreamReceiverTest, |
1235 | 1309 | public ::testing::WithParamInterface<std::pair<bool, bool>> {}; |
1236 | 1310 |
|
|
0 commit comments