From 1392b79b58f582144fffc56ec12c488d73fac0d5 Mon Sep 17 00:00:00 2001 From: Maciej Dziuban Date: Fri, 13 Apr 2018 11:05:09 +0200 Subject: [PATCH] L3 programming refactor 1/n - Clean up size estimation functions - Make some tests gen specific Change-Id: If9c15f311306282ba035b380e6d4cadc17584815 --- .../command_stream_receiver_hw.h | 5 +- .../command_stream_receiver_hw.inl | 37 +++-- runtime/gen8/command_stream_receiver_hw.cpp | 2 +- runtime/gen9/command_stream_receiver_hw.cpp | 2 +- unit_tests/command_stream/CMakeLists.txt | 1 + .../command_stream_receiver_hw_tests.cpp | 106 +------------- .../command_stream_receiver_hw_tests.inl | 129 ++++++++++++++++++ unit_tests/gen8/CMakeLists.txt | 1 + .../gen8/command_stream_receiver_hw_tests.cpp | 51 +++++++ .../gen9/command_stream_receiver_hw_tests.cpp | 23 ++++ 10 files changed, 243 insertions(+), 114 deletions(-) create mode 100644 unit_tests/command_stream/command_stream_receiver_hw_tests.inl create mode 100644 unit_tests/gen8/command_stream_receiver_hw_tests.cpp diff --git a/runtime/command_stream/command_stream_receiver_hw.h b/runtime/command_stream/command_stream_receiver_hw.h index 1e0f27e98f..e5dbc71e8e 100644 --- a/runtime/command_stream/command_stream_receiver_hw.h +++ b/runtime/command_stream/command_stream_receiver_hw.h @@ -52,7 +52,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void flushBatchedSubmissions() override; void addPipeControl(LinearStream &commandStream, bool dcFlush) override; - int getRequiredPipeControlSize(); + int getRequiredPipeControlSize() const; static void addBatchBufferEnd(LinearStream &commandStream, void **patchLocation); static void addBatchBufferStart(MI_BATCH_BUFFER_START *commandBufferMemory, uint64_t startAddress); @@ -60,6 +60,9 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { size_t getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags); size_t getRequiredCmdStreamSizeAligned(const DispatchFlags &dispatchFlags); + size_t getCmdSizeForPreemption(const DispatchFlags &dispatchFlags) const; + size_t getCmdSizeForL3Config() const; + size_t getCmdSizeForPipelineSelect() const; size_t getCmdSizeForCoherency(); size_t getCmdSizeForMediaSampler(bool mediaSamplerRequired) const; void programCoherency(LinearStream &csr, DispatchFlags &dispatchFlags); diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index d6396887ac..2ce070a0fd 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -80,8 +80,7 @@ inline void CommandStreamReceiverHw::alignToCacheLine(LinearStream &c template size_t getSizeRequiredPreambleCS(const Device &device) { - return sizeof(typename GfxFamily::MI_LOAD_REGISTER_IMM) + - sizeof(typename GfxFamily::PIPE_CONTROL) + + return sizeof(typename GfxFamily::PIPE_CONTROL) + sizeof(typename GfxFamily::MEDIA_VFE_STATE) + PreambleHelper::getAdditionalCommandsSize(device); } @@ -102,6 +101,14 @@ void CommandStreamReceiverHw::programPipelineSelect(LinearStream &com } } +template +inline size_t CommandStreamReceiverHw::getCmdSizeForPipelineSelect() const { + if (csrSizeRequestFlags.mediaSamplerConfigChanged || !isPreambleSent) { + return sizeof(typename GfxFamily::PIPELINE_SELECT); + } + return 0; +} + template CompletionStamp CommandStreamReceiverHw::flushTask( LinearStream &commandStreamTask, @@ -540,16 +547,13 @@ size_t CommandStreamReceiverHw::getRequiredCmdStreamSize(const Dispat sizeof(PIPE_CONTROL) + getRequiredPipeControlSize() + sizeof(typename GfxFamily::MI_BATCH_BUFFER_START); - if (csrSizeRequestFlags.mediaSamplerConfigChanged || !isPreambleSent) { - size += sizeof(typename GfxFamily::PIPELINE_SELECT); - } - if (csrSizeRequestFlags.l3ConfigChanged && this->isPreambleSent) { - size += sizeof(typename GfxFamily::PIPE_CONTROL); - } + + size += getCmdSizeForL3Config(); size += getCmdSizeForCoherency(); size += getCmdSizeForMediaSampler(dispatchFlags.mediaSamplerRequired); + size += getCmdSizeForPipelineSelect(); + size += getCmdSizeForPreemption(dispatchFlags); - size += PreemptionHelper::getRequiredCmdStreamSize(dispatchFlags.preemptionMode, this->lastPreemptionMode); if (getMemoryManager()->device->getWaTable()->waSamplerCacheFlushBetweenRedescribedSurfaceReads) { if (this->samplerCacheFlushRequired != SamplerCacheFlushState::samplerCacheFlushNotRequired) { size += sizeof(typename GfxFamily::PIPE_CONTROL); @@ -591,6 +595,11 @@ inline void CommandStreamReceiverHw::programPreemption(LinearStream & this->lastPreemptionMode = dispatchFlags.preemptionMode; } +template +inline size_t CommandStreamReceiverHw::getCmdSizeForPreemption(const DispatchFlags &dispatchFlags) const { + return PreemptionHelper::getRequiredCmdStreamSize(dispatchFlags.preemptionMode, this->lastPreemptionMode); +} + template inline void CommandStreamReceiverHw::programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config) { typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL; @@ -606,6 +615,16 @@ inline void CommandStreamReceiverHw::programL3(LinearStream &csr, Dis } } +template +inline size_t CommandStreamReceiverHw::getCmdSizeForL3Config() const { + if (!this->isPreambleSent) { + return sizeof(typename GfxFamily::MI_LOAD_REGISTER_IMM); + } else if (csrSizeRequestFlags.l3ConfigChanged) { + return sizeof(typename GfxFamily::MI_LOAD_REGISTER_IMM) + sizeof(typename GfxFamily::PIPE_CONTROL); + } + return 0; +} + template inline void CommandStreamReceiverHw::programPreamble(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config) { if (!this->isPreambleSent) { diff --git a/runtime/gen8/command_stream_receiver_hw.cpp b/runtime/gen8/command_stream_receiver_hw.cpp index e63672775f..0fcadafbd4 100644 --- a/runtime/gen8/command_stream_receiver_hw.cpp +++ b/runtime/gen8/command_stream_receiver_hw.cpp @@ -43,7 +43,7 @@ void CommandStreamReceiverHw::addPipeControlWA(LinearStream &commandStre } template <> -int CommandStreamReceiverHw::getRequiredPipeControlSize() { +int CommandStreamReceiverHw::getRequiredPipeControlSize() const { return 1 * sizeof(Family::PIPE_CONTROL); } diff --git a/runtime/gen9/command_stream_receiver_hw.cpp b/runtime/gen9/command_stream_receiver_hw.cpp index 16c0f5474e..a4719640e3 100644 --- a/runtime/gen9/command_stream_receiver_hw.cpp +++ b/runtime/gen9/command_stream_receiver_hw.cpp @@ -48,7 +48,7 @@ void CommandStreamReceiverHw::addPipeControlWA(LinearStream &commandStre } template <> -int CommandStreamReceiverHw::getRequiredPipeControlSize() { +int CommandStreamReceiverHw::getRequiredPipeControlSize() const { return 2 * sizeof(Family::PIPE_CONTROL); } diff --git a/unit_tests/command_stream/CMakeLists.txt b/unit_tests/command_stream/CMakeLists.txt index 690c140656..c53f7a7985 100644 --- a/unit_tests/command_stream/CMakeLists.txt +++ b/unit_tests/command_stream/CMakeLists.txt @@ -24,6 +24,7 @@ set(IGDRCL_SRCS_tests_command_stream ${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_tests.inl ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_with_aub_dump_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/create_command_stream_receiver_tests.cpp diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index 3a3ec6e0d0..9352b4a44d 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -62,7 +62,6 @@ using ::testing::_; HWTEST_F(UltCommandStreamReceiverTest, requiredCmdSizeForPreamble) { auto expectedCmdSize = - sizeof(typename FamilyType::MI_LOAD_REGISTER_IMM) + sizeof(typename FamilyType::PIPE_CONTROL) + sizeof(typename FamilyType::MEDIA_VFE_STATE) + PreambleHelper::getAdditionalCommandsSize(*pDevice); @@ -700,14 +699,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, flushTaskWithOnlyEnoughMemoryForPr auto &csrCS = commandStreamReceiver.getCS(); size_t sizeNeededForPreamble = getSizeRequiredPreambleCS(MockDevice(commandStreamReceiver.hwInfo)); - size_t sizeNeededForStateBaseAddress = sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL); - size_t sizeNeededForPipeControl = commandStreamReceiver.getRequiredPipeControlSize(); - size_t sizeNeededForPreemption = PreemptionHelper::getRequiredCmdStreamSize(pDevice->getPreemptionMode(), commandStreamReceiver.lastPreemptionMode); - size_t sizeNeeded = sizeNeededForPreamble + - sizeNeededForStateBaseAddress + - sizeNeededForPipeControl + - sizeNeededForPreemption + - sizeof(MI_BATCH_BUFFER_END); + size_t sizeNeeded = commandStreamReceiver.getRequiredCmdStreamSize(flushTaskFlags); sizeNeeded = alignUp(sizeNeeded, MemoryConstants::cacheLineSize); csrCS.getSpace(csrCS.getAvailableSpace() - sizeNeededForPreamble); @@ -736,13 +728,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, flushTaskWithOnlyEnoughMemoryForPr auto &csrCS = commandStreamReceiver.getCS(); size_t sizeNeededForPreamble = getSizeRequiredPreambleCS(MockDevice(commandStreamReceiver.hwInfo)); size_t sizeNeededForStateBaseAddress = sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL); - size_t sizeNeededForPipeControl = commandStreamReceiver.getRequiredPipeControlSize(); - size_t sizeNeededForPreemption = PreemptionHelper::getRequiredCmdStreamSize(pDevice->getPreemptionMode(), commandStreamReceiver.lastPreemptionMode); - size_t sizeNeeded = sizeNeededForPreamble + - sizeNeededForStateBaseAddress + - sizeNeededForPipeControl + - sizeNeededForPreemption + - sizeof(MI_BATCH_BUFFER_END); + size_t sizeNeeded = commandStreamReceiver.getRequiredCmdStreamSize(flushTaskFlags); sizeNeeded = alignUp(sizeNeeded, MemoryConstants::cacheLineSize); csrCS.getSpace(csrCS.getAvailableSpace() - sizeNeededForPreamble - sizeNeededForStateBaseAddress); @@ -1351,46 +1337,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenFlushedCallRequiringDCFlushWh retVal = clReleaseMemObject(buffer); } -HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3Config) { - typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; - typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL; - size_t GWS = 1; - MockContext ctx(pDevice); - MockKernelWithInternals kernel(*pDevice); - CommandQueueHw commandQueue(&ctx, pDevice, 0); - auto commandStreamReceiver = new MockCsrHw(*platformDevices[0]); - pDevice->resetCommandStreamReceiver(commandStreamReceiver); - - auto &commandStreamCSR = commandStreamReceiver->getCS(); - - // Mark Pramble as sent, override L3Config to invalid to programL3 - commandStreamReceiver->isPreambleSent = true; - commandStreamReceiver->lastSentL3Config = 0; - - ((MockKernel *)kernel)->setTotalSLMSize(1024); - - cmdList.clear(); - commandQueue.enqueueKernel(kernel, 1, nullptr, &GWS, nullptr, 0, nullptr, nullptr); - - // Parse command list to verify that PC was added to taskCS - parseCommands(commandStreamCSR, 0); - - auto itorCmd = findMmio(cmdList.begin(), cmdList.end(), L3CNTLRegisterOffset::registerOffset); - ASSERT_NE(cmdList.end(), itorCmd); - - auto cmdMILoad = genCmdCast(*itorCmd); - ASSERT_NE(nullptr, cmdMILoad); - - // MI_LOAD_REGISTER should be preceded by PC - EXPECT_NE(cmdList.begin(), itorCmd); - --itorCmd; - auto cmdPC = genCmdCast(*itorCmd); - ASSERT_NE(nullptr, cmdPC); - - uint32_t L3Config = PreambleHelper::getL3Config(*platformDevices[0], true); - EXPECT_EQ(L3Config, (uint32_t)cmdMILoad->getDataDword()); -} - HWTEST_F(CommandStreamReceiverFlushTaskTests, givenDefaultCommandStreamReceiverThenRoundRobinPolicyIsSelected) { MockCsrHw commandStreamReceiver(*platformDevices[0]); EXPECT_EQ(PreambleHelper::getDefaultThreadArbitrationPolicy(), commandStreamReceiver.peekThreadArbitrationPolicy()); @@ -1426,51 +1372,6 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenKernelWithSlmWhenPreviousSLML EXPECT_EQ(cmdList.end(), itorCmd); } -HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3ConfigAfterUnblocking) { - typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; - size_t GWS = 1; - MockContext ctx(pDevice); - MockKernelWithInternals kernel(*pDevice); - CommandQueueHw commandQueue(&ctx, pDevice, 0); - auto commandStreamReceiver = new MockCsrHw(*platformDevices[0]); - pDevice->resetCommandStreamReceiver(commandStreamReceiver); - cl_event blockingEvent; - MockEvent mockEvent(&ctx); - blockingEvent = &mockEvent; - - auto &commandStreamCSR = commandStreamReceiver->getCS(); - - uint32_t L3Config = PreambleHelper::getL3Config(*platformDevices[0], false); - - // Mark Pramble as sent, override L3Config to SLM config - commandStreamReceiver->isPreambleSent = true; - commandStreamReceiver->lastSentL3Config = 0; - - ((MockKernel *)kernel)->setTotalSLMSize(1024); - - commandQueue.enqueueKernel(kernel, 1, nullptr, &GWS, nullptr, 1, &blockingEvent, nullptr); - - // Expect nothing was sent - EXPECT_EQ(0u, commandStreamCSR.getUsed()); - - // Unblock Event - mockEvent.setStatus(CL_COMPLETE); - - cmdList.clear(); - // Parse command list - parseCommands(commandStreamCSR, 0); - - // Expect L3 was programmed - auto itorCmd = findMmio(cmdList.begin(), cmdList.end(), L3CNTLRegisterOffset::registerOffset); - ASSERT_NE(cmdList.end(), itorCmd); - - auto cmdMILoad = genCmdCast(*itorCmd); - ASSERT_NE(nullptr, cmdMILoad); - - L3Config = PreambleHelper::getL3Config(*platformDevices[0], true); - EXPECT_EQ(L3Config, (uint32_t)cmdMILoad->getDataDword()); -} - HWTEST_F(CommandStreamReceiverFlushTaskTests, CreateCommandStreamReceiverHw) { const HardwareInfo hwInfo = *platformDevices[0]; auto csrHw = CommandStreamReceiverHw::create(hwInfo); @@ -1914,6 +1815,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, flushTaskWithPCWhenPreambleSentAnd HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenPreambleSentThenRequiredCsrSizeDependsOnL3ConfigChanged) { typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL; + typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; UltCommandStreamReceiver &commandStreamReceiver = (UltCommandStreamReceiver &)pDevice->getCommandStreamReceiver(); CsrSizeRequestFlags csrSizeRequest = {}; DispatchFlags flags; @@ -1929,7 +1831,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenPreambleSentThenRequir EXPECT_NE(l3ConfigNotChangedSize, l3ConfigChangedSize); auto difference = l3ConfigChangedSize - l3ConfigNotChangedSize; - EXPECT_EQ(sizeof(PIPE_CONTROL), difference); + EXPECT_EQ(sizeof(PIPE_CONTROL) + sizeof(MI_LOAD_REGISTER_IMM), difference); } HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrWhenPreambleNotSentThenRequiredCsrSizeDoesntDependOnL3ConfigChanged) { diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.inl b/unit_tests/command_stream/command_stream_receiver_hw_tests.inl new file mode 100644 index 0000000000..7689d67355 --- /dev/null +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.inl @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +using namespace OCLRT; + +template +struct CommandStreamReceiverHwTest : public DeviceFixture, + public HardwareParse, + public ::testing::Test { + + void SetUp() override { + DeviceFixture::SetUp(); + HardwareParse::SetUp(); + } + + void TearDown() override { + HardwareParse::TearDown(); + DeviceFixture::TearDown(); + } + + void givenKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3ConfigImpl(); + void givenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentOnThenProgramL3WithSLML3ConfigAfterUnblockingImpl(); +}; + +template +void CommandStreamReceiverHwTest::givenKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3ConfigImpl() { + typedef typename GfxFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; + typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL; + size_t GWS = 1; + MockContext ctx(pDevice); + MockKernelWithInternals kernel(*pDevice); + CommandQueueHw commandQueue(&ctx, pDevice, 0); + auto commandStreamReceiver = new MockCsrHw(*platformDevices[0]); + pDevice->resetCommandStreamReceiver(commandStreamReceiver); + + auto &commandStreamCSR = commandStreamReceiver->getCS(); + + // Mark Preamble as sent, override L3Config to invalid to programL3 + commandStreamReceiver->isPreambleSent = true; + commandStreamReceiver->lastSentL3Config = 0; + + static_cast(kernel)->setTotalSLMSize(1024); + + cmdList.clear(); + commandQueue.enqueueKernel(kernel, 1, nullptr, &GWS, nullptr, 0, nullptr, nullptr); + + // Parse command list to verify that PC was added to taskCS + parseCommands(commandStreamCSR, 0); + + auto itorCmd = findMmio(cmdList.begin(), cmdList.end(), L3CNTLRegisterOffset::registerOffset); + ASSERT_NE(cmdList.end(), itorCmd); + + auto cmdMILoad = genCmdCast(*itorCmd); + ASSERT_NE(nullptr, cmdMILoad); + + // MI_LOAD_REGISTER should be preceded by PC + EXPECT_NE(cmdList.begin(), itorCmd); + --itorCmd; + auto cmdPC = genCmdCast(*itorCmd); + ASSERT_NE(nullptr, cmdPC); + + uint32_t L3Config = PreambleHelper::getL3Config(*platformDevices[0], true); + EXPECT_EQ(L3Config, static_cast(cmdMILoad->getDataDword())); +} + +template +void CommandStreamReceiverHwTest::givenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentOnThenProgramL3WithSLML3ConfigAfterUnblockingImpl() { + typedef typename GfxFamily::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; + size_t GWS = 1; + MockContext ctx(pDevice); + MockKernelWithInternals kernel(*pDevice); + CommandQueueHw commandQueue(&ctx, pDevice, 0); + auto commandStreamReceiver = new MockCsrHw(*platformDevices[0]); + pDevice->resetCommandStreamReceiver(commandStreamReceiver); + cl_event blockingEvent; + MockEvent mockEvent(&ctx); + blockingEvent = &mockEvent; + + auto &commandStreamCSR = commandStreamReceiver->getCS(); + + uint32_t L3Config = PreambleHelper::getL3Config(*platformDevices[0], false); + + // Mark Pramble as sent, override L3Config to SLM config + commandStreamReceiver->isPreambleSent = true; + commandStreamReceiver->lastSentL3Config = 0; + + static_cast(kernel)->setTotalSLMSize(1024); + + commandQueue.enqueueKernel(kernel, 1, nullptr, &GWS, nullptr, 1, &blockingEvent, nullptr); + + // Expect nothing was sent + EXPECT_EQ(0u, commandStreamCSR.getUsed()); + + // Unblock Event + mockEvent.setStatus(CL_COMPLETE); + + cmdList.clear(); + // Parse command list + parseCommands(commandStreamCSR, 0); + + // Expect L3 was programmed + auto itorCmd = findMmio(cmdList.begin(), cmdList.end(), L3CNTLRegisterOffset::registerOffset); + ASSERT_NE(cmdList.end(), itorCmd); + + auto cmdMILoad = genCmdCast(*itorCmd); + ASSERT_NE(nullptr, cmdMILoad); + + L3Config = PreambleHelper::getL3Config(*platformDevices[0], true); + EXPECT_EQ(L3Config, static_cast(cmdMILoad->getDataDword())); +} diff --git a/unit_tests/gen8/CMakeLists.txt b/unit_tests/gen8/CMakeLists.txt index 6d0d4fca22..bdc09342a5 100644 --- a/unit_tests/gen8/CMakeLists.txt +++ b/unit_tests/gen8/CMakeLists.txt @@ -22,6 +22,7 @@ if(TESTS_GEN8) set(IGDRCL_SRCS_tests_gen8 ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/coherency_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/device_tests_bwd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/enqueue_media_kernel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests.cpp diff --git a/unit_tests/gen8/command_stream_receiver_hw_tests.cpp b/unit_tests/gen8/command_stream_receiver_hw_tests.cpp new file mode 100644 index 0000000000..bbe6e00d03 --- /dev/null +++ b/unit_tests/gen8/command_stream_receiver_hw_tests.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "runtime/command_queue/command_queue_hw.h" +#include "runtime/command_stream/command_stream_receiver.h" +#include "runtime/command_stream/linear_stream.h" +#include "runtime/gen_common/reg_configs.h" + +#include "unit_tests/fixtures/device_fixture.h" +#include "unit_tests/helpers/hw_parse.h" +#include "unit_tests/mocks/mock_event.h" +#include "unit_tests/mocks/mock_kernel.h" +#include "unit_tests/mocks/mock_command_queue.h" +#include "unit_tests/mocks/mock_context.h" +#include "unit_tests/mocks/mock_csr.h" + +#include "test.h" +#include "gtest/gtest.h" + +using namespace OCLRT; + +#include "unit_tests/command_stream/command_stream_receiver_hw_tests.inl" + +using CommandStreamReceiverHwTestGen8 = CommandStreamReceiverHwTest; + +GEN8TEST_F(CommandStreamReceiverHwTestGen8, GivenKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3Config) { + givenKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3ConfigImpl(); +} + +GEN8TEST_F(CommandStreamReceiverHwTestGen8, GivenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentOnThenProgramL3WithSLML3ConfigAfterUnblocking) { + givenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentOnThenProgramL3WithSLML3ConfigAfterUnblockingImpl(); +} diff --git a/unit_tests/gen9/command_stream_receiver_hw_tests.cpp b/unit_tests/gen9/command_stream_receiver_hw_tests.cpp index a492ecd39b..d95162755a 100644 --- a/unit_tests/gen9/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/gen9/command_stream_receiver_hw_tests.cpp @@ -23,12 +23,27 @@ #include "runtime/built_ins/built_ins.h" #include "runtime/command_queue/command_queue_hw.h" #include "runtime/command_stream/command_stream_receiver.h" +#include "runtime/command_stream/linear_stream.h" +#include "runtime/gen_common/reg_configs.h" + +#include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h" #include "unit_tests/mocks/mock_graphics_allocation.h" +#include "unit_tests/helpers/hw_parse.h" +#include "unit_tests/mocks/mock_event.h" +#include "unit_tests/mocks/mock_kernel.h" +#include "unit_tests/mocks/mock_command_queue.h" +#include "unit_tests/mocks/mock_context.h" +#include "unit_tests/mocks/mock_csr.h" #include "test.h" +#include "gtest/gtest.h" using namespace OCLRT; +#include "unit_tests/command_stream/command_stream_receiver_hw_tests.inl" + +using CommandStreamReceiverHwTestGen9 = CommandStreamReceiverHwTest; + GEN9TEST_F(UltCommandStreamReceiverTest, givenNotSentPreambleAndMidThreadPreemptionWhenPreambleIsProgrammedThenCorrectSipKernelGpuAddressIsProgrammed) { using STATE_SIP = typename FamilyType::STATE_SIP; auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); @@ -92,3 +107,11 @@ GEN9TEST_F(UltCommandStreamReceiverTest, givenNotSentPreambleAndKernelDebuggingA auto sipAddress = stateSipCmd->getSystemInstructionPointer(); EXPECT_EQ(dbgLocalSipAllocation->getGpuAddressToPatch(), sipAddress); } + +GEN9TEST_F(CommandStreamReceiverHwTestGen9, GivenKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3Config) { + givenKernelWithSlmWhenPreviousNOSLML3WasSentThenProgramL3WithSLML3ConfigImpl(); +} + +GEN9TEST_F(CommandStreamReceiverHwTestGen9, GivenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentOnThenProgramL3WithSLML3ConfigAfterUnblocking) { + givenBlockedKernelWithSlmWhenPreviousNOSLML3WasSentOnThenProgramL3WithSLML3ConfigAfterUnblockingImpl(); +}