From a692f1ecc54c736611ae3799ff32dcdd02b75fe7 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Wed, 19 May 2021 21:41:59 +0000 Subject: [PATCH] Move flag setup after initialization Signed-off-by: Zbigniew Zdanowicz --- ...and_stream_receiver_flush_task_3_tests.cpp | 8 +++--- .../command_stream_receiver_hw_1_tests.cpp | 14 +++++++++++ .../unit_test/fixtures/cl_device_fixture.cpp | 1 + .../unit_test/fixtures/cl_device_fixture.h | 1 + opencl/test/unit_test/kernel/kernel_tests.cpp | 2 ++ .../libult/ult_command_stream_receiver.h | 1 + .../command_stream/command_stream_receiver.h | 2 ++ .../command_stream_receiver_hw.h | 2 ++ .../command_stream_receiver_hw_base.inl | 25 +++++++++++-------- shared/source/device/device.cpp | 1 + .../mocks/mock_command_stream_receiver.h | 3 +++ 11 files changed, 44 insertions(+), 16 deletions(-) diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp index 32f2b7094d..590d07f797 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -2332,9 +2332,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenStaticPartitioningEnabledWhen auto &mockCsr = device->getUltCommandStreamReceiver(); ASSERT_NE(nullptr, mockCsr.getWorkPartitionAllocation()); - auto mockedSubmissionsAggregator = new mockSubmissionsAggregator(); mockCsr.overrideDispatchPolicy(DispatchMode::BatchedDispatch); - mockCsr.submissionAggregator.reset(mockedSubmissionsAggregator); + mockCsr.storeMakeResidentAllocations = true; DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); mockCsr.flushTask(commandStream, @@ -2346,10 +2345,9 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenStaticPartitioningEnabledWhen dispatchFlags, *device); - auto cmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead(); bool found = false; - for (auto allocation : cmdBuffer->surfaces) { - if (allocation == mockCsr.getWorkPartitionAllocation()) { + for (auto allocation : mockCsr.makeResidentAllocations) { + if (allocation.first == mockCsr.getWorkPartitionAllocation()) { found = true; break; } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp index 6712aaaad6..965a157399 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp @@ -500,6 +500,9 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsNotRequiredThenGshAddres HWTEST_F(CommandStreamReceiverHwTest, givenDefaultPlatformCapabilityWhenNoDebugKeysSetThenExpectDefaultPlatformSettings) { auto commandStreamReceiver = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + commandStreamReceiver->setupContext(*osContext); + commandStreamReceiver->postInitFlagsSetup(); + if (commandStreamReceiver->checkPlatformSupportsNewResourceImplicitFlush()) { EXPECT_TRUE(commandStreamReceiver->useNewResourceImplicitFlush); } else { @@ -509,6 +512,9 @@ HWTEST_F(CommandStreamReceiverHwTest, givenDefaultPlatformCapabilityWhenNoDebugK HWTEST_F(CommandStreamReceiverHwTest, givenDefaultGpuIdleImplicitFlushWhenNoDebugKeysSetThenExpectDefaultPlatformSettings) { auto commandStreamReceiver = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + commandStreamReceiver->setupContext(*osContext); + commandStreamReceiver->postInitFlagsSetup(); + if (commandStreamReceiver->checkPlatformSupportsGpuIdleImplicitFlush()) { EXPECT_TRUE(commandStreamReceiver->useGpuIdleImplicitFlush); } else { @@ -521,6 +527,8 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenForceDisableNewResourceImplicitFlushTh DebugManager.flags.PerformImplicitFlushForNewResource.set(0); auto commandStreamReceiver = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + commandStreamReceiver->setupContext(*osContext); + commandStreamReceiver->postInitFlagsSetup(); EXPECT_FALSE(commandStreamReceiver->useNewResourceImplicitFlush); } @@ -529,6 +537,8 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenForceEnableNewResourceImplicitFlushThe DebugManager.flags.PerformImplicitFlushForNewResource.set(1); auto commandStreamReceiver = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + commandStreamReceiver->setupContext(*osContext); + commandStreamReceiver->postInitFlagsSetup(); EXPECT_TRUE(commandStreamReceiver->useNewResourceImplicitFlush); } @@ -537,6 +547,8 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenForceDisableGpuIdleImplicitFlushThenEx DebugManager.flags.PerformImplicitFlushForIdleGpu.set(0); auto commandStreamReceiver = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + commandStreamReceiver->setupContext(*osContext); + commandStreamReceiver->postInitFlagsSetup(); EXPECT_FALSE(commandStreamReceiver->useGpuIdleImplicitFlush); } @@ -545,6 +557,8 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenForceEnableGpuIdleImplicitFlushThenExp DebugManager.flags.PerformImplicitFlushForIdleGpu.set(1); auto commandStreamReceiver = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); + commandStreamReceiver->setupContext(*osContext); + commandStreamReceiver->postInitFlagsSetup(); EXPECT_TRUE(commandStreamReceiver->useGpuIdleImplicitFlush); } diff --git a/opencl/test/unit_test/fixtures/cl_device_fixture.cpp b/opencl/test/unit_test/fixtures/cl_device_fixture.cpp index 5ff78411ca..2bdf73eeb1 100644 --- a/opencl/test/unit_test/fixtures/cl_device_fixture.cpp +++ b/opencl/test/unit_test/fixtures/cl_device_fixture.cpp @@ -26,6 +26,7 @@ void ClDeviceFixture::SetUpImpl(const NEO::HardwareInfo *hardwareInfo) { auto &commandStreamReceiver = pDevice->getGpgpuCommandStreamReceiver(); pTagMemory = commandStreamReceiver.getTagAddress(); ASSERT_NE(nullptr, const_cast(pTagMemory)); + this->osContext = pDevice->getDefaultEngine().osContext; } void ClDeviceFixture::TearDown() { diff --git a/opencl/test/unit_test/fixtures/cl_device_fixture.h b/opencl/test/unit_test/fixtures/cl_device_fixture.h index ebeab9725c..4ce3b9c611 100644 --- a/opencl/test/unit_test/fixtures/cl_device_fixture.h +++ b/opencl/test/unit_test/fixtures/cl_device_fixture.h @@ -25,6 +25,7 @@ struct ClDeviceFixture { volatile uint32_t *pTagMemory = nullptr; HardwareInfo hardwareInfo = {}; PLATFORM platformHelper = {}; + OsContext *osContext = nullptr; const uint32_t rootDeviceIndex = 0u; }; } // namespace NEO diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index fb6964b151..b884404207 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -522,6 +522,8 @@ class CommandStreamReceiverMock : public CommandStreamReceiver { return createPreemptionAllocationReturn; } + void postInitFlagsSetup() override {} + std::map residency; std::unique_ptr mockExecutionEnvironment; bool passResidencyCallToBaseClass = true; diff --git a/opencl/test/unit_test/libult/ult_command_stream_receiver.h b/opencl/test/unit_test/libult/ult_command_stream_receiver.h index c9b234fb83..91c3c8d287 100644 --- a/opencl/test/unit_test/libult/ult_command_stream_receiver.h +++ b/opencl/test/unit_test/libult/ult_command_stream_receiver.h @@ -44,6 +44,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw, publ using BaseClass::isPerDssBackedBufferSent; using BaseClass::makeResident; using BaseClass::perDssBackedBuffer; + using BaseClass::postInitFlagsSetup; using BaseClass::programEnginePrologue; using BaseClass::programPerDssBackedBuffer; using BaseClass::programPreamble; diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index 80075fbc85..60cfb6ab5d 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -253,6 +253,8 @@ class CommandStreamReceiver { virtual GraphicsAllocation *getClearColorAllocation() = 0; + virtual void postInitFlagsSetup() = 0; + protected: void cleanupResources(); void printDeviceIndex(); diff --git a/shared/source/command_stream/command_stream_receiver_hw.h b/shared/source/command_stream/command_stream_receiver_hw.h index dfa822905f..9414fb0593 100644 --- a/shared/source/command_stream/command_stream_receiver_hw.h +++ b/shared/source/command_stream/command_stream_receiver_hw.h @@ -126,6 +126,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { TagAllocatorBase *getTimestampPacketAllocator() override; + void postInitFlagsSetup() override; + protected: void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags); void programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config); diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index 033063a671..d29f8c2bbb 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -59,17 +59,6 @@ CommandStreamReceiverHw::CommandStreamReceiverHw(ExecutionEnvironment timestampPacketWriteEnabled = !!DebugManager.flags.EnableTimestampPacket.get(); } createScratchSpaceController(); - - useNewResourceImplicitFlush = checkPlatformSupportsNewResourceImplicitFlush(); - int32_t overrideNewResourceImplicitFlush = DebugManager.flags.PerformImplicitFlushForNewResource.get(); - if (overrideNewResourceImplicitFlush != -1) { - useNewResourceImplicitFlush = overrideNewResourceImplicitFlush == 0 ? false : true; - } - useGpuIdleImplicitFlush = checkPlatformSupportsGpuIdleImplicitFlush(); - int32_t overrideGpuIdleImplicitFlush = DebugManager.flags.PerformImplicitFlushForIdleGpu.get(); - if (overrideGpuIdleImplicitFlush != -1) { - useGpuIdleImplicitFlush = overrideGpuIdleImplicitFlush == 0 ? false : true; - } } template @@ -1386,4 +1375,18 @@ TagAllocatorBase *CommandStreamReceiverHw::getTimestampPacketAllocato return timestampPacketAllocator.get(); } +template +void CommandStreamReceiverHw::postInitFlagsSetup() { + useNewResourceImplicitFlush = checkPlatformSupportsNewResourceImplicitFlush(); + int32_t overrideNewResourceImplicitFlush = DebugManager.flags.PerformImplicitFlushForNewResource.get(); + if (overrideNewResourceImplicitFlush != -1) { + useNewResourceImplicitFlush = overrideNewResourceImplicitFlush == 0 ? false : true; + } + useGpuIdleImplicitFlush = checkPlatformSupportsGpuIdleImplicitFlush(); + int32_t overrideGpuIdleImplicitFlush = DebugManager.flags.PerformImplicitFlushForIdleGpu.get(); + if (overrideGpuIdleImplicitFlush != -1) { + useGpuIdleImplicitFlush = overrideGpuIdleImplicitFlush == 0 ? false : true; + } +} + } // namespace NEO diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index d17b623e0c..6ceb937b29 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -216,6 +216,7 @@ bool Device::createDeviceImpl() { if (!commandStreamReceiver->initDirectSubmission(*this, *osContext)) { return false; } + commandStreamReceiver->postInitFlagsSetup(); } uint32_t defaultEngineIndexWithinMemoryManager = 0; diff --git a/shared/test/common/mocks/mock_command_stream_receiver.h b/shared/test/common/mocks/mock_command_stream_receiver.h index c7e72da17d..1208884af8 100644 --- a/shared/test/common/mocks/mock_command_stream_receiver.h +++ b/shared/test/common/mocks/mock_command_stream_receiver.h @@ -112,6 +112,8 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { GraphicsAllocation *getClearColorAllocation() override { return nullptr; } + void postInitFlagsSetup() override {} + std::vector instructionHeapReserveredData; int *flushBatchedSubmissionsCallCounter = nullptr; uint32_t waitForCompletionWithTimeoutCalled = 0; @@ -131,6 +133,7 @@ class MockCsrHw2 : public CommandStreamReceiverHw { using CommandStreamReceiverHw::CommandStreamReceiverHw; using CommandStreamReceiverHw::csrSizeRequestFlags; using CommandStreamReceiverHw::flushStamp; + using CommandStreamReceiverHw::postInitFlagsSetup; using CommandStreamReceiverHw::programL3; using CommandStreamReceiverHw::programVFEState; using CommandStreamReceiver::clearColorAllocation;