performance: prealloc cmdbuffer on mtl

Preallocate 2 command buffers allocations per command queue initialized
on MTL.

Related-To: NEO-8152

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2023-11-08 12:44:01 +00:00
committed by Compute-Runtime-Automation
parent 79fbd8fedf
commit 7a6fc209dd
16 changed files with 107 additions and 23 deletions

View File

@@ -173,17 +173,30 @@ HWTEST_F(CommandStreamReceiverTest, givenFlagDisabledWhenCallFillReusableAllocat
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
}
HWTEST_F(CommandStreamReceiverTest, givenUnsetPreallocationsPerQueueWhenRequestPreallocationCalledThenDoNotAllocateCommandBuffer) {
HWTEST_F(CommandStreamReceiverTest, givenUnsetPreallocationsPerQueueWhenRequestPreallocationCalledThenPreallocateCommandBufferCorrectly) {
EXPECT_TRUE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
auto &productHelper = getHelper<ProductHelper>();
const auto expectedPreallocations = productHelper.getCommandBuffersPreallocatedPerCommandQueue();
commandStreamReceiver->requestPreallocation();
EXPECT_TRUE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
if (expectedPreallocations > 0) {
EXPECT_FALSE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(expectedPreallocations, commandStreamReceiver->getResidencyAllocations().size());
} else {
EXPECT_TRUE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
}
commandStreamReceiver->releasePreallocationRequest();
EXPECT_TRUE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
if (expectedPreallocations > 0) {
EXPECT_FALSE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(expectedPreallocations, commandStreamReceiver->getResidencyAllocations().size());
} else {
EXPECT_TRUE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
}
}
HWTEST_F(CommandStreamReceiverTest, givenPreallocationsPerQueueEqualZeroWhenRequestPreallocationCalledThenDoNotAllocateCommandBuffer) {
@@ -220,6 +233,28 @@ HWTEST_F(CommandStreamReceiverTest, givenPreallocationsPerQueueWhenRequestPreall
EXPECT_EQ(2u, commandStreamReceiver->getResidencyAllocations().size());
}
HWTEST_F(CommandStreamReceiverTest, givenPreallocationsPerQueueWhenRequestPreallocationCalledButAllocationFailedThenRequestIsIgnored) {
DebugManagerStateRestore restorer;
DebugManager.flags.SetAmountOfReusableAllocationsPerCmdQueue.set(1);
EXPECT_TRUE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
// make allocation fail
ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment();
auto memoryManagerBackup = executionEnvironment.memoryManager.release();
executionEnvironment.memoryManager.reset(new FailMemoryManager(executionEnvironment));
commandStreamReceiver->requestPreallocation();
EXPECT_TRUE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(0u, commandStreamReceiver->getResidencyAllocations().size());
// make allocation succeed
executionEnvironment.memoryManager.reset(memoryManagerBackup);
commandStreamReceiver->requestPreallocation();
EXPECT_FALSE(commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
EXPECT_EQ(1u, commandStreamReceiver->getResidencyAllocations().size());
}
HWTEST_F(CommandStreamReceiverTest, whenRegisterClientThenIncrementClientNum) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
auto numClients = csr.getNumClients();

View File

@@ -20,4 +20,4 @@ HWTEST_EXCLUDE_PRODUCT(ComputeModeRequirements, givenComputeModeProgrammingWhenR
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenAskedIfPatIndexProgrammingSupportedThenReturnFalse, IGFX_METEORLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenIsAdjustWalkOrderAvailableCallThenFalseReturn, IGFX_METEORLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenBooleanUncachedWhenCallOverridePatIndexThenProperPatIndexIsReturned, IGFX_METEORLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueueAllowedThenReturnTrue, IGFX_METEORLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueueAllowedThenReturnTrue, IGFX_METEORLAKE);