feature: enable in-order counter waits if temp allocation storage is empty 2

Related-To: NEO-7966

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2023-10-31 18:33:09 +00:00
committed by Compute-Runtime-Automation
parent 1c44f02e84
commit ddd1e8df5e
2 changed files with 57 additions and 2 deletions

View File

@@ -894,7 +894,11 @@ template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::hostSynchronize(uint64_t timeout, TaskCountType taskCount, bool handlePostWaitOperations) {
ze_result_t status = ZE_RESULT_SUCCESS;
bool inOrderWaitAllowed = (isInOrderExecutionEnabled() && !handlePostWaitOperations && this->latestFlushIsHostVisible);
auto internalAllocStorage = this->csr->getInternalAllocationStorage();
auto tempAllocsCleanupRequired = handlePostWaitOperations && !internalAllocStorage->getTemporaryAllocations().peekIsEmpty();
bool inOrderWaitAllowed = (isInOrderExecutionEnabled() && !tempAllocsCleanupRequired && this->latestFlushIsHostVisible);
if (inOrderWaitAllowed) {
status = synchronizeInOrderExecution(timeout);
@@ -913,7 +917,10 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::hostSynchronize(uint6
if (handlePostWaitOperations && status != ZE_RESULT_NOT_READY) {
if (status == ZE_RESULT_SUCCESS) {
this->cmdQImmediate->unregisterCsrClient();
this->csr->getInternalAllocationStorage()->cleanAllocationList(taskCount, NEO::AllocationUsage::TEMPORARY_ALLOCATION);
if (tempAllocsCleanupRequired) {
internalAllocStorage->cleanAllocationList(taskCount, NEO::AllocationUsage::TEMPORARY_ALLOCATION);
}
}
this->printKernelsPrintfOutput(status == ZE_RESULT_ERROR_DEVICE_LOST);

View File

@@ -17,6 +17,7 @@
#include "shared/source/helpers/register_offsets.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "shared/source/kernel/implicit_args.h"
#include "shared/source/memory_manager/internal_allocation_storage.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/source/os_interface/product_helper.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
@@ -27,6 +28,7 @@
#include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_direct_submission_hw.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_os_context.h"
#include "shared/test/common/test_macros/hw_test.h"
@@ -868,6 +870,11 @@ HWTEST2_F(InOrderCmdListTests, givenCmdListsWhenDispatchingThenUseInternalTaskCo
auto ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(device->getNEODevice()->getDefaultEngine().commandStreamReceiver);
auto mockAlloc = std::make_unique<MockGraphicsAllocation>();
auto internalAllocStorage = ultCsr->getInternalAllocationStorage();
internalAllocStorage->storeAllocationWithTaskCount(std::move(mockAlloc), NEO::AllocationUsage::TEMPORARY_ALLOCATION, 123);
immCmdList0->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false);
immCmdList1->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false);
@@ -2083,6 +2090,11 @@ HWTEST2_F(InOrderCmdListTests, givenInOrderModeWhenProgrammingRegularEventThenCl
HWTEST2_F(InOrderCmdListTests, givenHostVisibleEventOnLatestFlushWhenCallingSynchronizeThenUseInOrderSync, IsAtLeastSkl) {
auto ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(device->getNEODevice()->getDefaultEngine().commandStreamReceiver);
auto mockAlloc = std::make_unique<MockGraphicsAllocation>();
auto internalAllocStorage = ultCsr->getInternalAllocationStorage();
internalAllocStorage->storeAllocationWithTaskCount(std::move(mockAlloc), NEO::AllocationUsage::TEMPORARY_ALLOCATION, 123);
auto immCmdList = createImmCmdList<gfxCoreFamily>();
auto eventPool = createEvents<FamilyType>(1, true);
@@ -2132,6 +2144,37 @@ HWTEST2_F(InOrderCmdListTests, givenHostVisibleEventOnLatestFlushWhenCallingSync
}
}
HWTEST2_F(InOrderCmdListTests, givenEmptyTempAllocationsStorageWhenCallingSynchronizeThenUseInternalCounter, IsAtLeastSkl) {
auto ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(device->getNEODevice()->getDefaultEngine().commandStreamReceiver);
auto mockAlloc = std::make_unique<MockGraphicsAllocation>();
auto internalAllocStorage = ultCsr->getInternalAllocationStorage();
auto immCmdList = createImmCmdList<gfxCoreFamily>();
auto eventPool = createEvents<FamilyType>(1, true);
events[0]->signalScope = ZE_EVENT_SCOPE_FLAG_HOST;
immCmdList->appendLaunchKernel(kernel->toHandle(), groupCount, events[0]->toHandle(), 0, nullptr, launchParams, false);
EXPECT_TRUE(immCmdList->latestFlushIsHostVisible);
EXPECT_EQ(0u, immCmdList->synchronizeInOrderExecutionCalled);
EXPECT_EQ(0u, ultCsr->waitForCompletionWithTimeoutTaskCountCalled);
immCmdList->hostSynchronize(0, 1, true);
EXPECT_EQ(1u, immCmdList->synchronizeInOrderExecutionCalled);
EXPECT_EQ(0u, ultCsr->waitForCompletionWithTimeoutTaskCountCalled);
internalAllocStorage->storeAllocationWithTaskCount(std::move(mockAlloc), NEO::AllocationUsage::TEMPORARY_ALLOCATION, 123);
immCmdList->hostSynchronize(0, 1, true);
EXPECT_EQ(1u, immCmdList->synchronizeInOrderExecutionCalled);
EXPECT_EQ(1u, ultCsr->waitForCompletionWithTimeoutTaskCountCalled);
}
using NonPostSyncWalkerMatcher = IsWithinGfxCore<IGFX_GEN9_CORE, IGFX_GEN12LP_CORE>;
HWTEST2_F(InOrderCmdListTests, givenNonPostSyncWalkerWhenPatchingThenThrow, NonPostSyncWalkerMatcher) {
@@ -3348,6 +3391,11 @@ HWTEST2_F(InOrderCmdListTests, givenInOrderModeWhenCallingSyncThenHandleCompleti
auto ultCsr = static_cast<UltCommandStreamReceiver<FamilyType> *>(device->getNEODevice()->getDefaultEngine().commandStreamReceiver);
auto mockAlloc = std::make_unique<MockGraphicsAllocation>();
auto internalAllocStorage = ultCsr->getInternalAllocationStorage();
internalAllocStorage->storeAllocationWithTaskCount(std::move(mockAlloc), NEO::AllocationUsage::TEMPORARY_ALLOCATION, 123);
auto eventPool = createEvents<FamilyType>(1, false);
immCmdList->appendLaunchKernel(kernel->toHandle(), groupCount, events[0]->toHandle(), 0, nullptr, launchParams, false);