@@ -950,3 +950,171 @@ HWTEST2_F(CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWh
950950
951951 EXPECT_EQ (estimatedCmdSize, offset);
952952}
953+
954+ HWTEST2_F (CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWhenSinglePartitionUsedForPostSyncBarrierThenExpectOnlyPostSyncCommands, IsAtLeastXeHpCore) {
955+ using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
956+
957+ auto &hwInfo = pDevice->getHardwareInfo ();
958+
959+ auto commandStreamReceiver = new MockCsrHw<FamilyType>(*pDevice->executionEnvironment , pDevice->getRootDeviceIndex (), pDevice->getDeviceBitfield ());
960+ pDevice->resetCommandStreamReceiver (commandStreamReceiver);
961+ auto &commandStreamCSR = commandStreamReceiver->getCS ();
962+
963+ TagNodeBase *tagNode = commandStreamReceiver->getTimestampPacketAllocator ()->getTag ();
964+ uint64_t gpuAddress = TimestampPacketHelper::getContextEndGpuAddress (*tagNode);
965+
966+ TimestampPacketDependencies timestampPacketDependencies;
967+ timestampPacketDependencies.barrierNodes .add (tagNode);
968+
969+ DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags ();
970+ dispatchFlags.barrierTimestampPacketNodes = ×tampPacketDependencies.barrierNodes ;
971+
972+ commandStreamReceiver->staticWorkPartitioningEnabled = true ;
973+ commandStreamReceiver->activePartitions = 1 ;
974+
975+ size_t expectedCmdSize = MemorySynchronizationCommands<FamilyType>::getSizeForPipeControlWithPostSyncOperation (hwInfo);
976+ size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands (dispatchFlags);
977+ EXPECT_EQ (expectedCmdSize, estimatedCmdSize);
978+
979+ commandStreamReceiver->programStallingCommandsForBarrier (commandStreamCSR, dispatchFlags);
980+ EXPECT_EQ (estimatedCmdSize, commandStreamCSR.getUsed ());
981+
982+ parseCommands<FamilyType>(commandStreamCSR, 0 );
983+ findHardwareCommands<FamilyType>();
984+ auto cmdItor = cmdList.begin ();
985+
986+ if (MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired (hwInfo)) {
987+ PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(*cmdItor);
988+ ASSERT_NE (nullptr , pipeControl);
989+ cmdItor++;
990+ if (MemorySynchronizationCommands<FamilyType>::getSizeForSingleAdditionalSynchronization (hwInfo) > 0 ) {
991+ cmdItor++;
992+ }
993+ }
994+ PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(*cmdItor);
995+ ASSERT_NE (nullptr , pipeControl);
996+ EXPECT_EQ (PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControl->getPostSyncOperation ());
997+ EXPECT_TRUE (pipeControl->getCommandStreamerStallEnable ());
998+ EXPECT_EQ (0u , pipeControl->getImmediateData ());
999+ EXPECT_EQ (gpuAddress, UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress (*pipeControl));
1000+ }
1001+
1002+ HWTEST2_F (CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionDisabledWhenMultiplePartitionsUsedForPostSyncBarrierThenExpectOnlyPostSyncCommands, IsAtLeastXeHpCore) {
1003+ using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
1004+
1005+ auto &hwInfo = pDevice->getHardwareInfo ();
1006+
1007+ auto commandStreamReceiver = new MockCsrHw<FamilyType>(*pDevice->executionEnvironment , pDevice->getRootDeviceIndex (), pDevice->getDeviceBitfield ());
1008+ pDevice->resetCommandStreamReceiver (commandStreamReceiver);
1009+ auto &commandStreamCSR = commandStreamReceiver->getCS ();
1010+
1011+ TagNodeBase *tagNode = commandStreamReceiver->getTimestampPacketAllocator ()->getTag ();
1012+ uint64_t gpuAddress = TimestampPacketHelper::getContextEndGpuAddress (*tagNode);
1013+
1014+ TimestampPacketDependencies timestampPacketDependencies;
1015+ timestampPacketDependencies.barrierNodes .add (tagNode);
1016+
1017+ DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags ();
1018+ dispatchFlags.barrierTimestampPacketNodes = ×tampPacketDependencies.barrierNodes ;
1019+
1020+ commandStreamReceiver->staticWorkPartitioningEnabled = false ;
1021+ commandStreamReceiver->activePartitions = 2 ;
1022+
1023+ size_t expectedCmdSize = MemorySynchronizationCommands<FamilyType>::getSizeForPipeControlWithPostSyncOperation (hwInfo);
1024+ size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands (dispatchFlags);
1025+ EXPECT_EQ (expectedCmdSize, estimatedCmdSize);
1026+
1027+ commandStreamReceiver->programStallingCommandsForBarrier (commandStreamCSR, dispatchFlags);
1028+ EXPECT_EQ (estimatedCmdSize, commandStreamCSR.getUsed ());
1029+
1030+ parseCommands<FamilyType>(commandStreamCSR, 0 );
1031+ findHardwareCommands<FamilyType>();
1032+ auto cmdItor = cmdList.begin ();
1033+
1034+ if (MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired (hwInfo)) {
1035+ PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(*cmdItor);
1036+ ASSERT_NE (nullptr , pipeControl);
1037+ cmdItor++;
1038+ if (MemorySynchronizationCommands<FamilyType>::getSizeForSingleAdditionalSynchronization (hwInfo) > 0 ) {
1039+ cmdItor++;
1040+ }
1041+ }
1042+ PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(*cmdItor);
1043+ ASSERT_NE (nullptr , pipeControl);
1044+ EXPECT_EQ (PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControl->getPostSyncOperation ());
1045+ EXPECT_TRUE (pipeControl->getCommandStreamerStallEnable ());
1046+ EXPECT_EQ (0u , pipeControl->getImmediateData ());
1047+ EXPECT_EQ (gpuAddress, UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress (*pipeControl));
1048+ }
1049+
1050+ HWTEST2_F (CommandStreamReceiverHwTestXeHPAndLater, givenStaticPartitionEnabledWhenMultiplePartitionsUsedThenExpectImplicitScalingPostSyncBarrierWithoutSelfCleanup, IsAtLeastXeHpCore) {
1051+ using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
1052+ using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
1053+ using MI_ATOMIC = typename FamilyType::MI_ATOMIC;
1054+ using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
1055+
1056+ auto &hwInfo = pDevice->getHardwareInfo ();
1057+
1058+ auto commandStreamReceiver = new MockCsrHw<FamilyType>(*pDevice->executionEnvironment , pDevice->getRootDeviceIndex (), pDevice->getDeviceBitfield ());
1059+ pDevice->resetCommandStreamReceiver (commandStreamReceiver);
1060+ auto &commandStreamCSR = commandStreamReceiver->getCS ();
1061+
1062+ TagNodeBase *tagNode = commandStreamReceiver->getTimestampPacketAllocator ()->getTag ();
1063+ uint64_t gpuAddress = TimestampPacketHelper::getContextEndGpuAddress (*tagNode);
1064+
1065+ TimestampPacketDependencies timestampPacketDependencies;
1066+ timestampPacketDependencies.barrierNodes .add (tagNode);
1067+
1068+ DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags ();
1069+ dispatchFlags.barrierTimestampPacketNodes = ×tampPacketDependencies.barrierNodes ;
1070+
1071+ commandStreamReceiver->staticWorkPartitioningEnabled = true ;
1072+ commandStreamReceiver->activePartitions = 2 ;
1073+
1074+ size_t expectedSize = MemorySynchronizationCommands<FamilyType>::getSizeForPipeControlWithPostSyncOperation (hwInfo) +
1075+ sizeof (MI_ATOMIC) + sizeof (MI_SEMAPHORE_WAIT) +
1076+ sizeof (MI_BATCH_BUFFER_START) +
1077+ 2 * sizeof (uint32_t );
1078+ size_t estimatedCmdSize = commandStreamReceiver->getCmdSizeForStallingCommands (dispatchFlags);
1079+ EXPECT_EQ (expectedSize, estimatedCmdSize);
1080+
1081+ commandStreamReceiver->programStallingCommandsForBarrier (commandStreamCSR, dispatchFlags);
1082+ EXPECT_EQ (estimatedCmdSize, commandStreamCSR.getUsed ());
1083+ EXPECT_EQ (2u , tagNode->getPacketsUsed ());
1084+
1085+ parseCommands<FamilyType>(commandStreamCSR, 0 );
1086+ findHardwareCommands<FamilyType>();
1087+ auto cmdItor = cmdList.begin ();
1088+
1089+ if (MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired (hwInfo)) {
1090+ PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(*cmdItor);
1091+ ASSERT_NE (nullptr , pipeControl);
1092+ cmdItor++;
1093+ if (MemorySynchronizationCommands<FamilyType>::getSizeForSingleAdditionalSynchronization (hwInfo) > 0 ) {
1094+ cmdItor++;
1095+ }
1096+ }
1097+ PIPE_CONTROL *pipeControl = genCmdCast<PIPE_CONTROL *>(*cmdItor);
1098+ ASSERT_NE (nullptr , pipeControl);
1099+ EXPECT_EQ (PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, pipeControl->getPostSyncOperation ());
1100+ EXPECT_TRUE (pipeControl->getCommandStreamerStallEnable ());
1101+ EXPECT_EQ (0u , pipeControl->getImmediateData ());
1102+ EXPECT_EQ (gpuAddress, UnitTestHelper<FamilyType>::getPipeControlPostSyncAddress (*pipeControl));
1103+ EXPECT_TRUE (pipeControl->getWorkloadPartitionIdOffsetEnable ());
1104+ cmdItor++;
1105+
1106+ if (MemorySynchronizationCommands<FamilyType>::getSizeForSingleAdditionalSynchronization (hwInfo) > 0 ) {
1107+ cmdItor++;
1108+ }
1109+
1110+ MI_ATOMIC *miAtomic = genCmdCast<MI_ATOMIC *>(*cmdItor);
1111+ ASSERT_NE (nullptr , miAtomic);
1112+ cmdItor++;
1113+
1114+ MI_SEMAPHORE_WAIT *miSemaphore = genCmdCast<MI_SEMAPHORE_WAIT *>(*cmdItor);
1115+ ASSERT_NE (nullptr , miSemaphore);
1116+ cmdItor++;
1117+
1118+ MI_BATCH_BUFFER_START *bbStart = genCmdCast<MI_BATCH_BUFFER_START *>(*cmdItor);
1119+ ASSERT_NE (nullptr , bbStart);
1120+ }
0 commit comments