Revert "performance: remove not needed logic"

This reverts commit 0ec4e9333d.

Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek 2024-07-30 06:31:25 +00:00 committed by Compute-Runtime-Automation
parent f9228ad11b
commit 5dc01e5764
5 changed files with 94 additions and 0 deletions

View File

@ -165,6 +165,7 @@ void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) {
}
if (this->dispatchMode == DispatchMode::batchedDispatch) {
checkForNewResources(submissionTaskCount, gfxAllocation.getTaskCount(osContext->getContextId()), gfxAllocation);
if (!gfxAllocation.isResident(osContext->getContextId())) {
this->totalMemoryUsed += gfxAllocation.getUnderlyingBufferSize();
}
@ -987,6 +988,17 @@ void CommandStreamReceiver::printDeviceIndex() {
}
}
void CommandStreamReceiver::checkForNewResources(TaskCountType submittedTaskCount, TaskCountType allocationTaskCount, GraphicsAllocation &gfxAllocation) {
if (useNewResourceImplicitFlush) {
if (allocationTaskCount == GraphicsAllocation::objectNotUsed && !GraphicsAllocation::isIsaAllocationType(gfxAllocation.getAllocationType())) {
newResources = true;
if (debugManager.flags.ProvideVerboseImplicitFlush.get()) {
printf("New resource detected of type %llu\n", static_cast<unsigned long long>(gfxAllocation.getAllocationType()));
}
}
}
}
bool CommandStreamReceiver::checkImplicitFlushForGpuIdle() {
if (useGpuIdleImplicitFlush) {
if (this->taskCount == *getTagAddress()) {

View File

@ -543,6 +543,7 @@ class CommandStreamReceiver {
protected:
void cleanupResources();
void printDeviceIndex();
void checkForNewResources(TaskCountType submittedTaskCount, TaskCountType allocationTaskCount, GraphicsAllocation &gfxAllocation);
bool checkImplicitFlushForGpuIdle();
void downloadTagAllocation(TaskCountType taskCountToWait);
void printTagAddressContent(TaskCountType taskCountToWait, int64_t waitTimeout, bool start);

View File

@ -99,6 +99,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
using BaseClass::CommandStreamReceiver::baseWaitFunction;
using BaseClass::CommandStreamReceiver::bindingTableBaseAddressRequired;
using BaseClass::CommandStreamReceiver::canUse4GbHeaps;
using BaseClass::CommandStreamReceiver::checkForNewResources;
using BaseClass::CommandStreamReceiver::checkImplicitFlushForGpuIdle;
using BaseClass::CommandStreamReceiver::cleanupResources;
using BaseClass::CommandStreamReceiver::clearColorAllocation;

View File

@ -33,6 +33,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
public:
using CommandStreamReceiver::activePartitions;
using CommandStreamReceiver::baseWaitFunction;
using CommandStreamReceiver::checkForNewResources;
using CommandStreamReceiver::checkImplicitFlushForGpuIdle;
using CommandStreamReceiver::cleanupResources;
using CommandStreamReceiver::CommandStreamReceiver;

View File

@ -1609,6 +1609,85 @@ TEST(CommandStreamReceiverSimpleTest, givenBaseCsrWhenWritingMemoryThenReturnFal
EXPECT_FALSE(csr.writeMemory(mockAllocation));
}
TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushDisabledWhenProvidingNeverUsedAllocationTaskCountThenDoNotMarkNewResourceTrue) {
MockExecutionEnvironment executionEnvironment;
executionEnvironment.prepareRootDeviceEnvironments(1);
executionEnvironment.initializeMemoryManager();
DeviceBitfield deviceBitfield(1);
MockCommandStreamReceiver csr(executionEnvironment, 0, deviceBitfield);
MockGraphicsAllocation mockAllocation;
csr.useNewResourceImplicitFlush = false;
csr.newResources = false;
csr.checkForNewResources(10u, GraphicsAllocation::objectNotUsed, mockAllocation);
EXPECT_FALSE(csr.newResources);
}
TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushEnabledWhenProvidingNeverUsedAllocationTaskCountThenMarkNewResourceTrue) {
MockExecutionEnvironment executionEnvironment;
executionEnvironment.prepareRootDeviceEnvironments(1);
executionEnvironment.initializeMemoryManager();
DeviceBitfield deviceBitfield(1);
MockCommandStreamReceiver csr(executionEnvironment, 0, deviceBitfield);
MockGraphicsAllocation mockAllocation;
csr.useNewResourceImplicitFlush = true;
csr.newResources = false;
csr.checkForNewResources(10u, GraphicsAllocation::objectNotUsed, mockAllocation);
EXPECT_TRUE(csr.newResources);
}
TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushEnabledWhenProvidingNeverUsedAllocationThatIsKernelIsaThenMarkNewResourceFalse) {
MockExecutionEnvironment executionEnvironment;
executionEnvironment.prepareRootDeviceEnvironments(1);
executionEnvironment.initializeMemoryManager();
DeviceBitfield deviceBitfield(1);
MockCommandStreamReceiver csr(executionEnvironment, 0, deviceBitfield);
MockGraphicsAllocation mockAllocation;
mockAllocation.setAllocationType(AllocationType::kernelIsa);
csr.useNewResourceImplicitFlush = true;
csr.newResources = false;
csr.checkForNewResources(10u, GraphicsAllocation::objectNotUsed, mockAllocation);
EXPECT_FALSE(csr.newResources);
}
TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushEnabledWhenProvidingAlreadyUsedAllocationTaskCountThenDoNotMarkNewResource) {
MockExecutionEnvironment executionEnvironment;
executionEnvironment.prepareRootDeviceEnvironments(1);
executionEnvironment.initializeMemoryManager();
DeviceBitfield deviceBitfield(1);
MockCommandStreamReceiver csr(executionEnvironment, 0, deviceBitfield);
MockGraphicsAllocation mockAllocation;
csr.useNewResourceImplicitFlush = true;
csr.newResources = false;
csr.checkForNewResources(10u, 10u, mockAllocation);
EXPECT_FALSE(csr.newResources);
}
TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushEnabledWhenProvidingNewAllocationAndVerbosityEnabledThenProvidePrintOfNewAllocationType) {
DebugManagerStateRestore restore;
debugManager.flags.ProvideVerboseImplicitFlush.set(true);
MockExecutionEnvironment executionEnvironment;
executionEnvironment.prepareRootDeviceEnvironments(1);
executionEnvironment.initializeMemoryManager();
DeviceBitfield deviceBitfield(1);
MockCommandStreamReceiver csr(executionEnvironment, 0, deviceBitfield);
MockGraphicsAllocation mockAllocation;
csr.useNewResourceImplicitFlush = true;
csr.newResources = false;
testing::internal::CaptureStdout();
csr.checkForNewResources(10u, GraphicsAllocation::objectNotUsed, mockAllocation);
EXPECT_TRUE(csr.newResources);
std::string output = testing::internal::GetCapturedStdout();
EXPECT_NE(0u, output.size());
EXPECT_STREQ("New resource detected of type 0\n", output.c_str());
}
TEST(CommandStreamReceiverSimpleTest, givenPrintfTagAllocationAddressFlagEnabledWhenCreatingTagAllocationThenPrintItsAddress) {
DebugManagerStateRestore restore;
debugManager.flags.PrintTagAllocationAddress.set(true);