Add debug flag to enable specific PIPE_CONTROL fields

FlushSpecificCache equivalent in value:

dcFlushEnable 	 				0b000000000001
renderTargetCacheFlushEnable  			0b000000000010
instructionCacheInvalidateEnable  		0b000000000100
textureCacheInvalidationEnable  		0b000000001000
pipeControlFlushEnable  			0b000000010000
vfCacheInvalidationEnable  			0b000000100000
constantCacheInvalidationEnable  		0b000001000000
stateCacheInvalidationEnable  			0b000010000000
tlbInvalidation  				0b000100000000
hdcPipelineFlush 				0b001000000000
unTypedDataPortCacheFlush 			0b010000000000
compressionControlSurfaceCcsFlush 		0b100000000000

Setting multiple cache at once for example:

constantCacheInvalidationEnable
textureCacheInvalidationEnable
vfCacheInvalidationEnable 			0b000001101000

Related-To: NEO-6049
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2022-08-26 12:41:34 +00:00
committed by Compute-Runtime-Automation
parent 7e2e940d6e
commit 2e7c90e58f
14 changed files with 459 additions and 19 deletions

View File

@@ -55,6 +55,7 @@ DoCpuCopyOnWriteBuffer = -1
PauseOnEnqueue = -1
EnableDebugBreak = 1
FlushAllCaches = 0
FlushSpecificCache = -1
MakeEachEnqueueBlocking = 0
DisableResourceRecycling = 0
TrackParentEvents = 0

View File

@@ -66,6 +66,8 @@ using IsDG2 = IsProduct<IGFX_DG2>;
using IsPVC = IsProduct<IGFX_PVC>;
using IsXeHPOrAbove = IsAtLeastProduct<IGFX_XE_HP_SDV>;
using IsAtLeastSkl = IsAtLeastProduct<IGFX_SKYLAKE>;
using IsAtMostDg2 = IsAtMostProduct<IGFX_DG2>;

View File

@@ -11,12 +11,14 @@
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/gmm_helper/page_table_mngr.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/flush_specific_cache_helper.h"
#include "shared/source/memory_manager/internal_allocation_storage.h"
#include "shared/source/memory_manager/surface.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/utilities/tag_allocator.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/fixtures/command_stream_receiver_fixture.inl"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
@@ -2124,3 +2126,291 @@ using SystolicSupport = IsAnyProducts<IGFX_ALDERLAKE_P, IGFX_XE_HP_SDV, IGFX_DG2
HWTEST2_F(CommandStreamReceiverSystolicTests, givenSystolicModeChangedWhenFlushTaskCalledThenSystolicStateIsUpdated, SystolicSupport) {
testBody<FamilyType>();
}
struct CommandStreamReceiverFlushSpecificCacheHelperTest : public ::testing::Test {
template <typename FamilyType>
void programSingleBarrier() {
stream = std::make_unique<LinearStream>(buffer, sizeof(buffer));
MemorySynchronizationCommands<FamilyType>::addSingleBarrier(*stream, args);
csHwParser = std::make_unique<HardwareParse>();
csHwParser->parseCommands<FamilyType>(*stream, 0);
ASSERT_NE(nullptr, csHwParser);
}
DebugManagerStateRestore restore;
PipeControlArgs args;
uint8_t buffer[128]{};
std::unique_ptr<LinearStream> stream;
std::unique_ptr<HardwareParse> csHwParser;
};
HWTEST2_F(CommandStreamReceiverFlushSpecificCacheHelperTest, WhenFlushingSpecificCacheThenPipeControlWithProperFieldIsAdded, IsAtLeastSkl) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using FlushSpecificCacheHelperCallMask = std::bitset<12>;
FlushSpecificCacheHelperCallMask helperMask[13] = {
0b000000000001,
0b000000000010,
0b000000000100,
0b000000001000,
0b000000010000,
0b000000100000,
0b000001000000,
0b000010000000,
0b000100000000,
0b001000000000,
0b010000000000,
0b100000000000,
0b000100100010,
};
for (auto &mask : helperMask) {
auto cacheIndexes = static_cast<int>(mask.to_ulong());
DebugManager.flags.FlushSpecificCache.set(cacheIndexes);
programSingleBarrier<FamilyType>();
auto pipeControls = findAll<PIPE_CONTROL *>(csHwParser->cmdList.begin(), csHwParser->cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*(pipeControls[0]));
ASSERT_NE(nullptr, pipeControl);
switch (cacheIndexes) {
case 0b000000000001:
EXPECT_TRUE(pipeControl->getDcFlushEnable());
break;
case 0b000000000010:
EXPECT_TRUE(pipeControl->getRenderTargetCacheFlushEnable());
break;
case 0b000000000100:
EXPECT_TRUE(pipeControl->getInstructionCacheInvalidateEnable());
break;
case 0b000000001000:
EXPECT_TRUE(pipeControl->getTextureCacheInvalidationEnable());
break;
case 0b000000010000:
EXPECT_TRUE(pipeControl->getPipeControlFlushEnable());
break;
case 0b000000100000:
EXPECT_TRUE(pipeControl->getVfCacheInvalidationEnable());
break;
case 0b000001000000:
EXPECT_TRUE(pipeControl->getConstantCacheInvalidationEnable());
break;
case 0b000010000000:
EXPECT_TRUE(pipeControl->getStateCacheInvalidationEnable());
break;
case 0b000100000000:
EXPECT_TRUE(pipeControl->getTlbInvalidate());
break;
case 0b000100100010:
EXPECT_FALSE(pipeControl->getDcFlushEnable());
EXPECT_TRUE(pipeControl->getRenderTargetCacheFlushEnable());
EXPECT_FALSE(pipeControl->getInstructionCacheInvalidateEnable());
EXPECT_FALSE(pipeControl->getTextureCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getPipeControlFlushEnable());
EXPECT_TRUE(pipeControl->getVfCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getConstantCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getStateCacheInvalidationEnable());
EXPECT_TRUE(pipeControl->getTlbInvalidate());
break;
}
}
}
HWTEST_F(CommandStreamReceiverFlushSpecificCacheHelperTest, WhenFlushingSpecificCacheWithAllCachesThenPipeControlWithProperFieldsIsAdded) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
constexpr size_t flushSpecificCacheMaskSize = 12u;
// constantCacheInvalidationEnable
// textureCacheInvalidationEnable
// vfCacheInvalidationEnable set for FlushSpecificCache = 0b001101000
std::bitset<flushSpecificCacheMaskSize> cacheIndexes = 0b001101000;
DebugManager.flags.FlushSpecificCache.set(static_cast<int>(cacheIndexes.to_ulong()));
args.dcFlushEnable = 1;
args.renderTargetCacheFlushEnable = 1;
args.instructionCacheInvalidateEnable = 1;
args.textureCacheInvalidationEnable = 1;
args.pipeControlFlushEnable = 1;
args.vfCacheInvalidationEnable = 1;
args.constantCacheInvalidationEnable = 1;
args.stateCacheInvalidationEnable = 1;
args.tlbInvalidation = 1;
programSingleBarrier<FamilyType>();
auto pipeControls = findAll<PIPE_CONTROL *>(csHwParser->cmdList.begin(), csHwParser->cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*(pipeControls[0]));
ASSERT_NE(nullptr, pipeControl);
EXPECT_TRUE(pipeControl->getDcFlushEnable());
EXPECT_TRUE(pipeControl->getRenderTargetCacheFlushEnable());
EXPECT_TRUE(pipeControl->getInstructionCacheInvalidateEnable());
EXPECT_TRUE(pipeControl->getTextureCacheInvalidationEnable());
EXPECT_TRUE(pipeControl->getPipeControlFlushEnable());
EXPECT_TRUE(pipeControl->getVfCacheInvalidationEnable());
EXPECT_TRUE(pipeControl->getConstantCacheInvalidationEnable());
EXPECT_TRUE(pipeControl->getStateCacheInvalidationEnable());
EXPECT_TRUE(pipeControl->getTlbInvalidate());
}
HWTEST2_F(CommandStreamReceiverFlushSpecificCacheHelperTest, givenDebugEnablingFlushSpecificCacheWhenAddingPipeControlWithoutCacheFlushThenOverrideRequestAndEnableFlushSpecificCacheFlags, IsGen12LP) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
constexpr size_t flushSpecificCacheMaskSize = 12u;
// hdcPipelineFlushSet set for FlushSpecificCache = 0b001000000000
std::bitset<flushSpecificCacheMaskSize> cacheIndexes = 0b001000000000;
DebugManager.flags.FlushSpecificCache.set(static_cast<int>(cacheIndexes.to_ulong()));
programSingleBarrier<FamilyType>();
auto pipeControls = findAll<PIPE_CONTROL *>(csHwParser->cmdList.begin(), csHwParser->cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*(pipeControls[0]));
ASSERT_NE(nullptr, pipeControl);
EXPECT_TRUE(pipeControl->getHdcPipelineFlush());
}
HWTEST2_F(CommandStreamReceiverFlushSpecificCacheHelperTest, givenDebugEnablingFlushSpecificCacheWithAllCachesWhenAddingPipeControlThenProperFieldsAreAdded, IsGen12LP) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
constexpr size_t flushSpecificCacheMaskSize = 12u;
// hdcPipelineFlushSet set for FlushSpecificCache = 0b001000000000
std::bitset<flushSpecificCacheMaskSize> cacheIndexes = 0b001000000000;
DebugManager.flags.FlushSpecificCache.set(static_cast<int>(cacheIndexes.to_ulong()));
args.hdcPipelineFlush = 1;
programSingleBarrier<FamilyType>();
auto pipeControls = findAll<PIPE_CONTROL *>(csHwParser->cmdList.begin(), csHwParser->cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*(pipeControls[0]));
ASSERT_NE(nullptr, pipeControl);
EXPECT_TRUE(pipeControl->getHdcPipelineFlush());
}
using CommandStreamReceiverFlushTaskXeHPAndLaterTests = CommandStreamReceiverFlushSpecificCacheHelperTest;
HWTEST2_F(CommandStreamReceiverFlushTaskXeHPAndLaterTests, WhenFlushingSpecificCacheVariableIsSetAndAddPipeControlIsCalledThenFieldsAreProperlySet, IsXeHPOrAbove) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
constexpr size_t flushSpecificCacheMaskSize = 12u;
// hdcPipelineFlushSet
// compressionControlSurfaceCcsFlushSet set for FlushSpecificCache = 0b101000000000
std::bitset<flushSpecificCacheMaskSize> cacheIndexes = 0b101000000000;
DebugManager.flags.FlushSpecificCache.set(static_cast<int>(cacheIndexes.to_ulong()));
programSingleBarrier<FamilyType>();
auto pipeControls = findAll<PIPE_CONTROL *>(csHwParser->cmdList.begin(), csHwParser->cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*(pipeControls[0]));
ASSERT_NE(nullptr, pipeControl);
EXPECT_TRUE(UnitTestHelper<FamilyType>::getPipeControlHdcPipelineFlush(*pipeControl));
EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush());
}
HWTEST2_F(CommandStreamReceiverFlushTaskXeHPAndLaterTests, WhenFlushingSpecificCacheWithAllCachesAndAddPipeControlIsCalledThenFieldsAreProperlySet, IsXeHPOrAbove) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
constexpr size_t flushSpecificCacheMaskSize = 12u;
// hdcPipelineFlushSet
// compressionControlSurfaceCcsFlushSet set for FlushSpecificCache = 0b101000000000
std::bitset<flushSpecificCacheMaskSize> cacheIndexes = 0b101000000000;
DebugManager.flags.FlushSpecificCache.set(static_cast<int>(cacheIndexes.to_ulong()));
args.hdcPipelineFlush = 1;
args.compressionControlSurfaceCcsFlush = 1;
programSingleBarrier<FamilyType>();
auto pipeControls = findAll<PIPE_CONTROL *>(csHwParser->cmdList.begin(), csHwParser->cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*(pipeControls[0]));
ASSERT_NE(nullptr, pipeControl);
EXPECT_TRUE(UnitTestHelper<FamilyType>::getPipeControlHdcPipelineFlush(*pipeControl));
EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush());
}
HWTEST2_F(CommandStreamReceiverFlushSpecificCacheHelperTest, givenDebugVariableFlushSpecificCacheSetWhenProgrammingPipeControlThenFlushSpecificCacheAreSet, IsAtLeastXeHpgCore) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using FlushSpecificCacheHelperCallMask = std::bitset<12>;
FlushSpecificCacheHelperCallMask helperMask[4] = {
0b001000000000,
0b010000000000,
0b100000000000,
0b100001100000,
};
for (auto &mask : helperMask) {
auto cacheIndexes = static_cast<int>(mask.to_ulong());
DebugManager.flags.FlushSpecificCache.set(cacheIndexes);
programSingleBarrier<FamilyType>();
auto pipeControls = findAll<PIPE_CONTROL *>(csHwParser->cmdList.begin(), csHwParser->cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*(pipeControls[0]));
ASSERT_NE(nullptr, pipeControl);
switch (cacheIndexes) {
case 0b001000000000:
EXPECT_TRUE(UnitTestHelper<FamilyType>::getPipeControlHdcPipelineFlush(*pipeControl));
break;
case 0b010000000000:
EXPECT_TRUE(pipeControl->getUnTypedDataPortCacheFlush());
break;
case 0b100000000000:
EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush());
break;
case 0b100001100000:
EXPECT_FALSE(pipeControl->getDcFlushEnable());
EXPECT_FALSE(pipeControl->getRenderTargetCacheFlushEnable());
EXPECT_FALSE(pipeControl->getInstructionCacheInvalidateEnable());
EXPECT_FALSE(pipeControl->getTextureCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getPipeControlFlushEnable());
EXPECT_TRUE(pipeControl->getVfCacheInvalidationEnable());
EXPECT_TRUE(pipeControl->getConstantCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getStateCacheInvalidationEnable());
EXPECT_FALSE(pipeControl->getTlbInvalidate());
EXPECT_FALSE(UnitTestHelper<FamilyType>::getPipeControlHdcPipelineFlush(*pipeControl));
EXPECT_FALSE(pipeControl->getUnTypedDataPortCacheFlush());
EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush());
break;
}
}
}
HWTEST2_F(CommandStreamReceiverFlushSpecificCacheHelperTest, givenDebugVariablesFlushSpecificCacheAndFlushAllCachesWhenProgrammingPipeControlThenAllFlushCachesAreSet, IsAtLeastXeHpgCore) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
constexpr size_t flushSpecificCacheMaskSize = 12u;
// constantCacheInvalidationEnable
// vfCacheInvalidationEnable
// compressionControlSurfaceCcsFlush set for FlushSpecificCache = 0b100001100000
std::bitset<flushSpecificCacheMaskSize> cacheIndexes = 0b100001100000;
DebugManager.flags.FlushSpecificCache.set(static_cast<int>(cacheIndexes.to_ulong()));
args.hdcPipelineFlush = 1;
args.unTypedDataPortCacheFlush = 1;
args.compressionControlSurfaceCcsFlush = 1;
programSingleBarrier<FamilyType>();
auto pipeControls = findAll<PIPE_CONTROL *>(csHwParser->cmdList.begin(), csHwParser->cmdList.end());
auto pipeControl = genCmdCast<PIPE_CONTROL *>(*(pipeControls[0]));
ASSERT_NE(nullptr, pipeControl);
EXPECT_TRUE(UnitTestHelper<FamilyType>::getPipeControlHdcPipelineFlush(*pipeControl));
EXPECT_TRUE(pipeControl->getUnTypedDataPortCacheFlush());
EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush());
}

View File

@@ -23,6 +23,7 @@ target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/extendable_enum_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/file_io_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/flush_stamp_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/flush_specific_cache_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_gpgpu_engines_tests.inl
${CMAKE_CURRENT_SOURCE_DIR}/get_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hash_tests.cpp

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/flush_specific_cache_helper.h"
#include "gtest/gtest.h"
#include <bitset>
using namespace NEO;
TEST(FlushSpecificCacheHelperTests, WhenSettingFlushSpecificCachesIndexThenCorrectResultIsReturned) {
static constexpr size_t flushSpecificCacheMaskSize = 12u;
std::bitset<flushSpecificCacheMaskSize> flushSpecificCaches = 0b000000000001;
EXPECT_TRUE(FlushSpecificCacheHelper::isDcFlushEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b000000000010;
EXPECT_TRUE(FlushSpecificCacheHelper::isRenderTargetCacheFlushEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b000000000100;
EXPECT_TRUE(FlushSpecificCacheHelper::isInstructionCacheInvalidateEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b000000001000;
EXPECT_TRUE(FlushSpecificCacheHelper::isTextureCacheInvalidationEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b000000010000;
EXPECT_TRUE(FlushSpecificCacheHelper::isPipeControlFlushEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b000000100000;
EXPECT_TRUE(FlushSpecificCacheHelper::isVfCacheInvalidationEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b000001000000;
EXPECT_TRUE(FlushSpecificCacheHelper::isConstantCacheInvalidationEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b000010000000;
EXPECT_TRUE(FlushSpecificCacheHelper::isStateCacheInvalidationEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b000100000000;
EXPECT_TRUE(FlushSpecificCacheHelper::isTlbInvalidationSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b001000000000;
EXPECT_TRUE(FlushSpecificCacheHelper::isHdcPipelineFlushSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b010000000000;
EXPECT_TRUE(FlushSpecificCacheHelper::isUnTypedDataPortCacheFlushSet(static_cast<int>(flushSpecificCaches.to_ulong())));
flushSpecificCaches = 0b100000000000;
EXPECT_TRUE(FlushSpecificCacheHelper::isCompressionControlSurfaceCcsFlushSet(static_cast<int>(flushSpecificCaches.to_ulong())));
}
TEST(FlushSpecificCacheHelperTests, WhenSettingFlushSpecificCachesIndexesThenCorrectResultIsReturned) {
static constexpr size_t flushSpecificCacheMaskSize = 12u;
std::bitset<flushSpecificCacheMaskSize> flushSpecificCaches = 0b100000001011;
EXPECT_TRUE(FlushSpecificCacheHelper::isDcFlushEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_TRUE(FlushSpecificCacheHelper::isRenderTargetCacheFlushEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_FALSE(FlushSpecificCacheHelper::isInstructionCacheInvalidateEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_TRUE(FlushSpecificCacheHelper::isTextureCacheInvalidationEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_FALSE(FlushSpecificCacheHelper::isPipeControlFlushEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_FALSE(FlushSpecificCacheHelper::isVfCacheInvalidationEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_FALSE(FlushSpecificCacheHelper::isConstantCacheInvalidationEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_FALSE(FlushSpecificCacheHelper::isStateCacheInvalidationEnableSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_FALSE(FlushSpecificCacheHelper::isTlbInvalidationSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_FALSE(FlushSpecificCacheHelper::isHdcPipelineFlushSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_FALSE(FlushSpecificCacheHelper::isUnTypedDataPortCacheFlushSet(static_cast<int>(flushSpecificCaches.to_ulong())));
EXPECT_TRUE(FlushSpecificCacheHelper::isCompressionControlSurfaceCcsFlushSet(static_cast<int>(flushSpecificCaches.to_ulong())));
}

View File

@@ -1092,8 +1092,6 @@ HWTEST2_F(BlitTests, givenMemorySizeTwiceBiggerThanMaxWidthWhenFillPatternWithBl
}
}
using IsXeHPOrAbove = IsAtLeastProduct<IGFX_XE_HP_SDV>;
HWTEST2_F(BlitTests, givenEnabledGlobalCacheInvalidationWhenProgrammingGlobalSequencerFlushThenCommandsAreProgrammed, IsXeHPOrAbove) {
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;