From 5c120893edc666e3613de149a0b98ce9a6a8a548 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Thu, 12 Sep 2019 17:30:13 +0200 Subject: [PATCH] Move method isMultiOsContextCapable to CommandStreamReceiverHw Related-To: NEO-3691 Change-Id: I3169ee8d5a29b8f562b70403b2fa9ebba7601a48 Signed-off-by: Mateusz Jablonski --- runtime/command_stream/command_stream_receiver.cpp | 4 ---- runtime/command_stream/command_stream_receiver.h | 2 +- runtime/command_stream/command_stream_receiver_hw.h | 2 ++ .../command_stream_receiver_hw_bdw_plus.inl | 5 +++++ .../command_stream_receiver_flush_task_1_tests.cpp | 2 +- .../command_stream/command_stream_receiver_tests.cpp | 9 --------- unit_tests/kernel/kernel_tests.cpp | 3 +++ unit_tests/libult/ult_command_stream_receiver.h | 5 +++++ unit_tests/mocks/mock_csr.h | 3 +++ 9 files changed, 20 insertions(+), 15 deletions(-) diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 7a848ecfed..cb8b434a34 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -144,10 +144,6 @@ MemoryManager *CommandStreamReceiver::getMemoryManager() const { return executionEnvironment.memoryManager.get(); } -bool CommandStreamReceiver::isMultiOsContextCapable() const { - return executionEnvironment.specialCommandStreamReceiver.get() == this; -} - LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) { constexpr static auto additionalAllocationSize = MemoryConstants::cacheLineSize + CSRequirements::csOverfetchSize; ensureCommandBufferAllocation(this->commandStream, minRequiredSize, additionalAllocationSize); diff --git a/runtime/command_stream/command_stream_receiver.h b/runtime/command_stream/command_stream_receiver.h index 2bfefab8b8..1015f5bc63 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -170,7 +170,7 @@ class CommandStreamReceiver { virtual cl_int expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation); - bool isMultiOsContextCapable() const; + virtual bool isMultiOsContextCapable() const = 0; void setLatestSentTaskCount(uint32_t latestSentTaskCount) { this->latestSentTaskCount = latestSentTaskCount; diff --git a/runtime/command_stream/command_stream_receiver_hw.h b/runtime/command_stream/command_stream_receiver_hw.h index 476802c771..2943e837dd 100644 --- a/runtime/command_stream/command_stream_receiver_hw.h +++ b/runtime/command_stream/command_stream_receiver_hw.h @@ -74,6 +74,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void blitBuffer(const BlitProperties &blitProperites) override; + bool isMultiOsContextCapable() const override; + protected: void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags); void programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config); diff --git a/runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl b/runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl index 1fa9dcd14b..7ed2ba39ec 100644 --- a/runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl +++ b/runtime/command_stream/command_stream_receiver_hw_bdw_plus.inl @@ -65,4 +65,9 @@ size_t CommandStreamReceiverHw::getCmdSizeForEpilogueCommands(const D return 0u; } +template +bool CommandStreamReceiverHw::isMultiOsContextCapable() const { + return false; +} + } // namespace NEO diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_1_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_1_tests.cpp index 0008746681..0ef286eae0 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_1_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_1_tests.cpp @@ -82,7 +82,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenconfigureCSRtoNonDirtyStateWh HWTEST_F(CommandStreamReceiverFlushTaskTests, givenSpecialCommandStreamReceiverWhenFlushTaskIsCalledThenCommandStreamReceiverStreamIsUsed) { configureCSRtoNonDirtyState(); auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); - commandStreamReceiver.executionEnvironment.specialCommandStreamReceiver.reset(&commandStreamReceiver); + commandStreamReceiver.multiOsContextCapable = true; commandStream.getSpace(4); flushTask(commandStreamReceiver); diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index 0d4ead1419..b0c0165de7 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -56,15 +56,6 @@ struct CommandStreamReceiverTest : public DeviceFixture, InternalAllocationStorage *internalAllocationStorage; }; -TEST_F(CommandStreamReceiverTest, whenCommandStreamReceiverIsSetAsSpecialCommandStreamReceiverInExecutionEnvironmentThenItIsMulitOsContextCapable) { - EXPECT_FALSE(commandStreamReceiver->isMultiOsContextCapable()); - - auto executionEnvironment = pDevice->getExecutionEnvironment(); - executionEnvironment->specialCommandStreamReceiver.reset(commandStreamReceiver); - EXPECT_TRUE(commandStreamReceiver->isMultiOsContextCapable()); - executionEnvironment->specialCommandStreamReceiver.release(); -} - HWTEST_F(CommandStreamReceiverTest, testCtor) { auto &csr = pDevice->getUltCommandStreamReceiver(); EXPECT_EQ(0u, csr.peekTaskLevel()); diff --git a/unit_tests/kernel/kernel_tests.cpp b/unit_tests/kernel/kernel_tests.cpp index 6eec086b36..99fc89b3c2 100644 --- a/unit_tests/kernel/kernel_tests.cpp +++ b/unit_tests/kernel/kernel_tests.cpp @@ -458,6 +458,9 @@ class CommandStreamReceiverMock : public CommandStreamReceiver { using CommandStreamReceiver::executionEnvironment; using BaseClass::CommandStreamReceiver; + + bool isMultiOsContextCapable() const override { return false; } + CommandStreamReceiverMock() : BaseClass(*(new ExecutionEnvironment)) { this->mockExecutionEnvironment.reset(&this->executionEnvironment); executionEnvironment.initializeMemoryManager(); diff --git a/unit_tests/libult/ult_command_stream_receiver.h b/unit_tests/libult/ult_command_stream_receiver.h index 82ca24a197..fb432efb96 100644 --- a/unit_tests/libult/ult_command_stream_receiver.h +++ b/unit_tests/libult/ult_command_stream_receiver.h @@ -188,6 +188,10 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw, publ return result; } + bool isMultiOsContextCapable() const override { + return multiOsContextCapable; + } + std::atomic recursiveLockCounter; bool createPageTableManagerCalled = false; bool recordFlusheBatchBuffer = false; @@ -204,5 +208,6 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw, publ uint32_t createPerDssBackedBufferCalled = 0; std::atomic latestWaitForCompletionWithTimeoutTaskCount{0}; DispatchFlags recordedDispatchFlags; + bool multiOsContextCapable = false; }; } // namespace NEO diff --git a/unit_tests/mocks/mock_csr.h b/unit_tests/mocks/mock_csr.h index 6acf1d165d..7cbcd53a5c 100644 --- a/unit_tests/mocks/mock_csr.h +++ b/unit_tests/mocks/mock_csr.h @@ -252,6 +252,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { std::vector instructionHeapReserveredData; int *flushBatchedSubmissionsCallCounter = nullptr; uint32_t waitForCompletionWithTimeoutCalled = 0; + bool multiOsContextCapable = false; ~MockCommandStreamReceiver() { } @@ -262,6 +263,8 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { } FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override; + bool isMultiOsContextCapable() const { return multiOsContextCapable; } + CompletionStamp flushTask( LinearStream &commandStream, size_t commandStreamStart,