Refactor addPipeControlWA, PipeControlWArequired

Related-To: NEO-3210
Change-Id: I0516154b323e29eeb697bf2253ca08ae1ce150d8
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2019-08-14 09:33:51 +02:00
committed by sys_ocldev
parent c961157fde
commit 62b0f0a220
33 changed files with 82 additions and 59 deletions

View File

@@ -1374,7 +1374,7 @@ HWTEST_P(ProfilingCommandsTest, givenKernelWhenProfilingCommandStartIsTakenThenT
auto hwTimeStamp1 = timeStampAllocator.getTag();
ASSERT_NE(nullptr, hwTimeStamp1);
if (checkForStart) {
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsStart(*hwTimeStamp1, &cmdStream);
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsStart(*hwTimeStamp1, &cmdStream, pDevice->getHardwareInfo());
} else {
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsEnd(*hwTimeStamp1, &cmdStream);
}
@@ -1382,7 +1382,7 @@ HWTEST_P(ProfilingCommandsTest, givenKernelWhenProfilingCommandStartIsTakenThenT
auto hwTimeStamp2 = timeStampAllocator.getTag();
ASSERT_NE(nullptr, hwTimeStamp2);
if (checkForStart) {
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsStart(*hwTimeStamp2, &cmdStream);
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsStart(*hwTimeStamp2, &cmdStream, pDevice->getHardwareInfo());
} else {
GpgpuWalkerHelper<FamilyType>::dispatchProfilingCommandsEnd(*hwTimeStamp2, &cmdStream);
}
@@ -1413,7 +1413,7 @@ HWTEST_P(ProfilingCommandsTest, givenKernelWhenProfilingCommandStartIsTakenThenT
if (checkForStart) {
auto itorPipeCtrl = find<typename FamilyType::PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), itorPipeCtrl);
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired()) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
itorPipeCtrl++;
}
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*itorPipeCtrl);
@@ -1425,7 +1425,7 @@ HWTEST_P(ProfilingCommandsTest, givenKernelWhenProfilingCommandStartIsTakenThenT
itorPipeCtrl++;
itorPipeCtrl = find<typename FamilyType::PIPE_CONTROL *>(itorPipeCtrl, cmdList.end());
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired()) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
itorPipeCtrl++;
}
ASSERT_NE(cmdList.end(), itorPipeCtrl);

View File

@@ -124,7 +124,7 @@ HWTEST_F(EnqueueHandlerTest, GivenCommandStreamWithoutKernelAndZeroSurfacesWhenE
mockCmdQ->commandRequireCacheFlush = true;
mockCmdQ->template enqueueHandler<CL_COMMAND_MARKER>(nullptr, 0, false, nullptr, 0, nullptr, nullptr);
auto requiredCmdStreamSize = alignUp(PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(),
auto requiredCmdStreamSize = alignUp(PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(pDevice->getHardwareInfo()),
MemoryConstants::cacheLineSize);
EXPECT_EQ(mockCmdQ->getCS(0).getUsed(), requiredCmdStreamSize);

View File

@@ -742,7 +742,7 @@ HWTEST_F(EnqueueAuxKernelTests, givenMultipleArgsWhenAuxTranslationIsRequiredThe
auto pipeControls = findAll<typename FamilyType::PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
auto additionalPcCount = PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation() / sizeof(typename FamilyType::PIPE_CONTROL);
auto additionalPcCount = PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(pDevice->getHardwareInfo()) / sizeof(typename FamilyType::PIPE_CONTROL);
// |AuxToNonAux|NDR|NonAuxToAux|
ASSERT_EQ(4u + additionalPcCount, pipeControls.size());

View File

@@ -40,7 +40,7 @@ HWTEST_F(IOQWithTwoWalkers, shouldHaveAPipecontrolBetweenWalkers2) {
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
auto WaNeeded = HardwareCommandsHelper<FamilyType>::isPipeControlWArequired();
auto WaNeeded = HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo());
auto itorCmd = find<PIPE_CONTROL *>(itorWalker1, itorWalker2);
ASSERT_NE(itorWalker2, itorCmd);

View File

@@ -14,6 +14,7 @@
#include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/image_fixture.h"
#include "unit_tests/helpers/unit_test_helper.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_kernel.h"
@@ -1024,7 +1025,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueMapImageTypeTest, blockingEnqueueRequiresPCWi
auto *cmd = (PIPE_CONTROL *)*itorCmd;
EXPECT_NE(cmdList.end(), itorCmd);
if (::renderCoreFamily == IGFX_GEN9_CORE) {
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
// SKL: two PIPE_CONTROLs following GPGPU_WALKER: first has DcFlush and second has Write HwTag
EXPECT_FALSE(cmd->getDcFlushEnable());
// Move to next PPC

View File

@@ -298,7 +298,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadBufferRectTest, blockingRequiresPipeContr
auto *cmd = (PIPE_CONTROL *)*itorCmd;
EXPECT_NE(cmdList.end(), itorCmd);
if (::renderCoreFamily == IGFX_GEN9_CORE) {
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
// SKL: two PIPE_CONTROLs following GPGPU_WALKER: first has DcFlush and second has Write HwTag
EXPECT_FALSE(cmd->getDcFlushEnable());
// Move to next PPC

View File

@@ -264,7 +264,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadBufferTypeTest, blockingRequiresPipeContr
auto *cmd = (PIPE_CONTROL *)*itorCmd;
EXPECT_NE(cmdList.end(), itorCmd);
if (::renderCoreFamily == IGFX_GEN9_CORE) {
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
// SKL: two PIPE_CONTROLs following GPGPU_WALKER: first has DcFlush and second has Write HwTag
EXPECT_FALSE(cmd->getDcFlushEnable());
// Move to next PPC

View File

@@ -205,7 +205,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadImageTest, blockingEnqueueRequiresPCWithD
auto *cmd = (PIPE_CONTROL *)*itorCmd;
EXPECT_NE(cmdList.end(), itorCmd);
if (::renderCoreFamily == IGFX_GEN9_CORE) {
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
// SKL: two PIPE_CONTROLs following GPGPU_WALKER: first has DcFlush and second has Write HwTag
EXPECT_FALSE(cmd->getDcFlushEnable());
// Move to next PPC

View File

@@ -71,7 +71,7 @@ HWTEST_F(GetSizeRequiredTest, enqueueMarker) {
size_t expectedStreamSize = 0;
if (pCmdQ->getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) {
expectedStreamSize = alignUp(PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(),
expectedStreamSize = alignUp(PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(pDevice->getHardwareInfo()),
+MemoryConstants::cacheLineSize);
}
EXPECT_EQ(expectedStreamSize, commandStream.getUsed() - usedBeforeCS);
@@ -97,7 +97,7 @@ HWTEST_F(GetSizeRequiredTest, enqueueBarrierDoesntConsumeAnySpace) {
size_t expectedStreamSize = 0;
if (pCmdQ->getGpgpuCommandStreamReceiver().peekTimestampPacketWriteEnabled()) {
expectedStreamSize = alignUp(PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(),
expectedStreamSize = alignUp(PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(pDevice->getHardwareInfo()),
+MemoryConstants::cacheLineSize);
}

View File

@@ -11,6 +11,7 @@
#include "runtime/os_interface/os_context.h"
#include "test.h"
#include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h"
#include "unit_tests/helpers/unit_test_helper.h"
#include "unit_tests/mocks/mock_buffer.h"
#include "unit_tests/mocks/mock_command_queue.h"
#include "unit_tests/mocks/mock_csr.h"
@@ -915,7 +916,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, FlushTaskBlockingHasPipeControlWit
auto &commandStreamReceiver = commandQueue.getGpgpuCommandStreamReceiver();
size_t pipeControlCount = PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation() / sizeof(PIPE_CONTROL);
size_t pipeControlCount = PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(pDevice->getHardwareInfo()) / sizeof(PIPE_CONTROL);
auto &commandStreamTask = commandQueue.getCS(1024);
@@ -939,7 +940,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, FlushTaskBlockingHasPipeControlWit
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itorPC);
if (::renderCoreFamily == IGFX_GEN9_CORE) {
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
// Verify that the dcFlushEnabled bit is set in PC
auto pCmdWA = reinterpret_cast<PIPE_CONTROL *>(*itorPC);
EXPECT_FALSE(pCmdWA->getDcFlushEnable());
@@ -992,7 +993,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelRequiringDCFlush
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itorPC);
if (::renderCoreFamily == IGFX_GEN9_CORE) {
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
itorPC++;
itorPC = find<PIPE_CONTROL *>(itorPC, cmdList.end());
EXPECT_NE(cmdList.end(), itorPC);

View File

@@ -15,6 +15,7 @@
#include "runtime/os_interface/os_context.h"
#include "test.h"
#include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h"
#include "unit_tests/helpers/unit_test_helper.h"
#include "unit_tests/mocks/mock_allocation_properties.h"
#include "unit_tests/mocks/mock_buffer.h"
#include "unit_tests/mocks/mock_command_queue.h"
@@ -61,7 +62,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelNotRequiringDCFl
auto itorPC = find<PIPE_CONTROL *>(cmdList.begin(), cmdList.end());
EXPECT_NE(cmdList.end(), itorPC);
if (::renderCoreFamily == IGFX_GEN9_CORE) {
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
itorPC++;
itorPC = find<PIPE_CONTROL *>(itorPC, cmdList.end());
EXPECT_NE(cmdList.end(), itorPC);
@@ -338,7 +339,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests,
auto cmdPC = genCmdCast<PIPE_CONTROL *>(*itorCmd);
ASSERT_NE(nullptr, cmdPC);
if (::renderCoreFamily == IGFX_GEN9_CORE) {
if (UnitTestHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
// SKL: two PIPE_CONTROLs following GPGPU_WALKER: first has DcFlush and second has Write HwTag
EXPECT_FALSE(cmdPC->getDcFlushEnable());
auto itorCmdP = ++((GenCmdList::iterator)itorCmd);

View File

@@ -76,7 +76,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskGmockTests, givenCsrInBatchingModeThreeRe
dispatchFlags.outOfOrderExecutionAllowed = true;
EXPECT_CALL(*mockHelper, setPatchInfoData(::testing::_)).Times(10);
size_t removePatchInfoDataCount = 4 * PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation() / sizeof(PIPE_CONTROL);
size_t removePatchInfoDataCount = 4 * PipeControlHelper<FamilyType>::getSizeForPipeControlWithPostSyncOperation(pDevice->getHardwareInfo()) / sizeof(PIPE_CONTROL);
EXPECT_CALL(*mockHelper, removePatchInfoData(::testing::_)).Times(static_cast<int>(removePatchInfoDataCount));
EXPECT_CALL(*mockHelper, registerCommandChunk(::testing::_)).Times(4);
EXPECT_CALL(*mockHelper, registerBatchBufferStartAddress(::testing::_, ::testing::_)).Times(3);

View File

@@ -90,7 +90,7 @@ HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhe
it = hwParserExCmdBuffer.cmdList.begin();
GenCmdList::iterator end = hwParserExCmdBuffer.cmdList.end();
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired()) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
//1st PIPE_CONTROL with CS Stall
ASSERT_NE(end, it);
pipeControl = genCmdCast<PIPE_CONTROL *>(*it);
@@ -120,7 +120,7 @@ HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhe
EXPECT_EQ(exAllocationGpuAddr, semaphoreCmd->getSemaphoreGraphicsAddress());
EXPECT_EQ(MI_SEMAPHORE_WAIT::COMPARE_OPERATION_SAD_EQUAL_SDD, semaphoreCmd->getCompareOperation());
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired()) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
//3rd PIPE_CONTROL with CS stall
it++;
ASSERT_NE(end, it);
@@ -218,7 +218,7 @@ HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhe
hwParserExCmdBuffer.parseCommands<FamilyType>(*mockExCmdBuffer->currentStream, cmbBufferOffset);
it = hwParserExCmdBuffer.cmdList.begin();
GenCmdList::iterator end = hwParserExCmdBuffer.cmdList.end();
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired()) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
it++;
}
//2nd PIPE_CONTROL
@@ -233,7 +233,7 @@ HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhe
EXPECT_EQ(expectedTsAddress, pipeControl->getAddress());
EXPECT_EQ(expectedTsAddressHigh, pipeControl->getAddressHigh());
//omit SEMAPHORE_WAIT and 3rd PIPE_CONTROL
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired()) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(pDevice->getHardwareInfo())) {
it++;
}
it++;

View File

@@ -10,6 +10,12 @@
#include "unit_tests/helpers/unit_test_helper.inl"
namespace NEO {
using Family = SKLFamily;
template struct UnitTestHelper<SKLFamily>;
template <>
bool UnitTestHelper<Family>::isPipeControlWArequired(const HardwareInfo &hwInfo) {
return true;
}
template struct UnitTestHelper<Family>;
} // namespace NEO

View File

@@ -196,9 +196,10 @@ HWTEST_F(PipeControlHelperTests, givenPostSyncWriteTimestampModeWhenHelperIsUsed
expectedPipeControl.setPostSyncOperation(PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP);
expectedPipeControl.setAddress(static_cast<uint32_t>(address & 0x0000FFFFFFFFULL));
expectedPipeControl.setAddressHigh(static_cast<uint32_t>(address >> 32));
HardwareInfo hardwareInfo = *platformDevices[0];
auto pipeControl = PipeControlHelper<FamilyType>::obtainPipeControlAndProgramPostSyncOperation(stream, PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP, address, immediateData, false);
auto additionalPcSize = HardwareCommandsHelper<FamilyType>::isPipeControlWArequired() ? sizeof(PIPE_CONTROL) : 0u;
auto pipeControl = PipeControlHelper<FamilyType>::obtainPipeControlAndProgramPostSyncOperation(stream, PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_TIMESTAMP, address, immediateData, false, hardwareInfo);
auto additionalPcSize = HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(hardwareInfo) ? sizeof(PIPE_CONTROL) : 0u;
EXPECT_EQ(sizeof(PIPE_CONTROL) + additionalPcSize, stream.getUsed());
EXPECT_EQ(pipeControl, ptrOffset(stream.getCpuBase(), additionalPcSize));
@@ -219,10 +220,10 @@ HWTEST_F(PipeControlHelperTests, givenPostSyncWriteImmediateDataModeWhenHelperIs
expectedPipeControl.setAddress(static_cast<uint32_t>(address & 0x0000FFFFFFFFULL));
expectedPipeControl.setAddressHigh(static_cast<uint32_t>(address >> 32));
expectedPipeControl.setImmediateData(immediateData);
HardwareInfo hardwareInfo = *platformDevices[0];
auto pipeControl = PipeControlHelper<FamilyType>::obtainPipeControlAndProgramPostSyncOperation(stream, PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, address, immediateData, false);
auto additionalPcSize = HardwareCommandsHelper<FamilyType>::isPipeControlWArequired() ? sizeof(PIPE_CONTROL) : 0u;
auto pipeControl = PipeControlHelper<FamilyType>::obtainPipeControlAndProgramPostSyncOperation(stream, PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA, address, immediateData, false, hardwareInfo);
auto additionalPcSize = HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(hardwareInfo) ? sizeof(PIPE_CONTROL) : 0u;
EXPECT_EQ(sizeof(PIPE_CONTROL) + additionalPcSize, stream.getUsed());
EXPECT_EQ(pipeControl, ptrOffset(stream.getCpuBase(), additionalPcSize));

View File

@@ -398,7 +398,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TimestampPacketTests, givenTimestampPacketWhenDispat
uint32_t walkersFound = 0;
for (auto it = hwParser.cmdList.begin(); it != hwParser.cmdList.end(); it++) {
if (genCmdCast<GPGPU_WALKER *>(*it)) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired()) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(*executionEnvironment->getHardwareInfo())) {
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*++it);
EXPECT_NE(nullptr, pipeControl);
}
@@ -506,7 +506,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingThe
bool walkerFound = false;
for (auto it = hwParser.cmdList.begin(); it != hwParser.cmdList.end(); it++) {
if (genCmdCast<GPGPU_WALKER *>(*it)) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired()) {
if (HardwareCommandsHelper<FamilyType>::isPipeControlWArequired(*executionEnvironment->getHardwareInfo())) {
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*++it);
EXPECT_NE(nullptr, pipeControl);
}

View File

@@ -27,5 +27,7 @@ struct UnitTestHelper {
static uint32_t getDefaultSshUsage();
static bool evaluateGshAddressForScratchSpace(uint64_t usedScratchGpuAddress, uint64_t retrievedGshAddress);
static bool isPipeControlWArequired(const HardwareInfo &hwInfo);
};
} // namespace NEO

View File

@@ -44,4 +44,9 @@ template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::evaluateGshAddressForScratchSpace(uint64_t usedScratchGpuAddress, uint64_t retrievedGshAddress) {
return usedScratchGpuAddress == retrievedGshAddress;
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isPipeControlWArequired(const HardwareInfo &hwInfo) {
return false;
}
} // namespace NEO