Optimize flushTask.

Move Batching code under batching if to not call not required functions.
Update task level only if level is closed.
70ns gain.

Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2022-10-10 17:39:04 +00:00
committed by Compute-Runtime-Automation
parent 8132503b87
commit 809abb005f
2 changed files with 27 additions and 17 deletions

View File

@@ -627,27 +627,29 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
this->wasSubmittedToSingleSubdevice = dispatchFlags.useSingleSubdevice;
// check if we are not over the budget, if we are do implicit flush
if (getMemoryManager()->isMemoryBudgetExhausted()) {
if (this->totalMemoryUsed >= device.getDeviceInfo().globalMemSize / 4) {
implicitFlush = true;
if (this->dispatchMode == DispatchMode::BatchedDispatch) {
// check if we are not over the budget, if we are do implicit flush
if (getMemoryManager()->isMemoryBudgetExhausted()) {
if (this->totalMemoryUsed >= device.getDeviceInfo().globalMemSize / 4) {
implicitFlush = true;
}
}
}
if (DebugManager.flags.PerformImplicitFlushEveryEnqueueCount.get() != -1) {
if ((taskCount + 1) % DebugManager.flags.PerformImplicitFlushEveryEnqueueCount.get() == 0) {
implicitFlush = true;
if (DebugManager.flags.PerformImplicitFlushEveryEnqueueCount.get() != -1) {
if ((taskCount + 1) % DebugManager.flags.PerformImplicitFlushEveryEnqueueCount.get() == 0) {
implicitFlush = true;
}
}
}
if (this->newResources) {
implicitFlush = true;
this->newResources = false;
}
implicitFlush |= checkImplicitFlushForGpuIdle();
if (this->newResources) {
implicitFlush = true;
this->newResources = false;
}
implicitFlush |= checkImplicitFlushForGpuIdle();
if (this->dispatchMode == DispatchMode::BatchedDispatch && implicitFlush) {
this->flushBatchedSubmissions();
if (implicitFlush) {
this->flushBatchedSubmissions();
}
}
++taskCount;
@@ -659,7 +661,9 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
this->taskLevel,
flushStamp->peekStamp()};
this->taskLevel += levelClosed ? 1 : 0;
if (levelClosed) {
this->taskLevel++;
}
return completionStamp;
}

View File

@@ -32,3 +32,9 @@ TEST(MemoryManagerTest, givenAllocationWithNullCpuPtrThenMemoryCopyToAllocationR
EXPECT_FALSE(memoryManager.copyMemoryToAllocation(&allocation, offset, nullptr, 0));
}
TEST(MemoryManagerTest, givenDefaultMemoryManagerWhenItIsAskedForBudgetExhaustionThenFalseIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
MockMemoryManager memoryManager(false, false, executionEnvironment);
EXPECT_FALSE(memoryManager.isMemoryBudgetExhausted());
}