mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Add xe_hp_core shared tests
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
74e6c74071
commit
3e213c9c06
34
shared/test/common/libult/xe_hp_core.cpp
Normal file
34
shared/test/common/libult/xe_hp_core.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/populate_factory.h"
|
||||
|
||||
#include "opencl/test/unit_test/libult/ult_command_stream_receiver.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
typedef XeHpFamily Family;
|
||||
|
||||
static auto gfxCore = IGFX_XE_HP_CORE;
|
||||
|
||||
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE];
|
||||
|
||||
template <>
|
||||
void populateFactoryTable<UltCommandStreamReceiver<Family>>() {
|
||||
commandStreamReceiverFactory[IGFX_MAX_CORE + gfxCore] = UltCommandStreamReceiver<Family>::create;
|
||||
}
|
||||
|
||||
struct enableXeHpCore {
|
||||
enableXeHpCore() {
|
||||
populateFactoryTable<UltCommandStreamReceiver<Family>>();
|
||||
}
|
||||
};
|
||||
|
||||
static enableXeHpCore enable;
|
||||
|
||||
template class UltCommandStreamReceiver<XeHpFamily>;
|
||||
} // namespace NEO
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/command_stream/stream_properties.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
@@ -92,3 +93,26 @@ XEHPTEST_F(XeHPPreambleVfeState, whenProgrammingVfeStateThenDoNotAddPipeControlW
|
||||
|
||||
EXPECT_EQ(sizeBefore, sizeAfter);
|
||||
}
|
||||
|
||||
XEHPTEST_F(XeHPPreambleVfeState, WhenProgramVFEStateIsCalledThenCorrectCfeStateAddressIsReturned) {
|
||||
using CFE_STATE = typename FamilyType::CFE_STATE;
|
||||
|
||||
char buffer[64];
|
||||
MockGraphicsAllocation graphicsAllocation(buffer, sizeof(buffer));
|
||||
LinearStream preambleStream(&graphicsAllocation, graphicsAllocation.getUnderlyingBuffer(), graphicsAllocation.getUnderlyingBufferSize());
|
||||
uint64_t addressToPatch = 0xC0DEC0DE;
|
||||
uint64_t expectedAddress = 0xDEC0C0;
|
||||
|
||||
auto pCfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&preambleStream, *defaultHwInfo, EngineGroupType::RenderCompute);
|
||||
StreamProperties emptyProperties{};
|
||||
PreambleHelper<FamilyType>::programVfeState(pCfeCmd, *defaultHwInfo, 1024u, addressToPatch,
|
||||
10u, AdditionalKernelExecInfo::NotApplicable,
|
||||
emptyProperties);
|
||||
EXPECT_GE(reinterpret_cast<uintptr_t>(pCfeCmd), reinterpret_cast<uintptr_t>(preambleStream.getCpuBase()));
|
||||
EXPECT_LT(reinterpret_cast<uintptr_t>(pCfeCmd), reinterpret_cast<uintptr_t>(preambleStream.getCpuBase()) + preambleStream.getUsed());
|
||||
|
||||
auto &cfeCmd = *reinterpret_cast<CFE_STATE *>(pCfeCmd);
|
||||
EXPECT_EQ(10u, cfeCmd.getMaximumNumberOfThreads());
|
||||
EXPECT_EQ(1u, cfeCmd.getNumberOfWalkers());
|
||||
EXPECT_EQ(expectedAddress, cfeCmd.getScratchSpaceBuffer());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -9,4 +9,10 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_tests.cpp
|
||||
)
|
||||
|
||||
if(TESTS_XE_HP_CORE)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/direct_submission_tests_xe_hp_core.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/direct_submission/dispatchers/blitter_dispatcher.h"
|
||||
#include "shared/test/common/cmd_parse/hw_parse.h"
|
||||
#include "shared/test/common/fixtures/direct_submission_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_direct_submission_hw.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "hw_cmds.h"
|
||||
|
||||
using DirectSubmissionTestXE_HP_CORE = Test<DirectSubmissionFixture>;
|
||||
|
||||
XE_HP_CORE_TEST_F(DirectSubmissionTestXE_HP_CORE, givenBlitterUsedWhenDispatchingPrefetchMitigationThenExpectBbStartCmd) {
|
||||
using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
using Dispatcher = BlitterDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
EXPECT_EQ(sizeof(MI_BATCH_BUFFER_START), directSubmission.getSizePrefetchMitigation());
|
||||
|
||||
bool ret = directSubmission.allocateResources();
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
directSubmission.dispatchPrefetchMitigation();
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
hwParse.findHardwareCommands<FamilyType>();
|
||||
MI_BATCH_BUFFER_START *bbStart = hwParse.getCommand<MI_BATCH_BUFFER_START>();
|
||||
ASSERT_NE(nullptr, bbStart);
|
||||
|
||||
uint64_t exptectedJumpAddress = directSubmission.ringCommandStream.getGraphicsAllocation()->getGpuAddress();
|
||||
exptectedJumpAddress += sizeof(MI_BATCH_BUFFER_START);
|
||||
EXPECT_EQ(exptectedJumpAddress, bbStart->getBatchBufferStartAddressGraphicsaddress472());
|
||||
}
|
||||
|
||||
XE_HP_CORE_TEST_F(DirectSubmissionTestXE_HP_CORE, givenBlitterUsedWhenDispatchingPrefetchDisableTrueThenExpectArbCheckCmd) {
|
||||
using MI_ARB_CHECK = typename FamilyType::MI_ARB_CHECK;
|
||||
using Dispatcher = BlitterDispatcher<FamilyType>;
|
||||
|
||||
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
|
||||
*osContext.get());
|
||||
|
||||
EXPECT_EQ(sizeof(MI_ARB_CHECK), directSubmission.getSizeDisablePrefetcher());
|
||||
|
||||
bool ret = directSubmission.allocateResources();
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
directSubmission.dispatchDisablePrefetcher(true);
|
||||
|
||||
HardwareParse hwParse;
|
||||
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
|
||||
hwParse.findHardwareCommands<FamilyType>();
|
||||
MI_ARB_CHECK *arbCheck = hwParse.getCommand<MI_ARB_CHECK>();
|
||||
ASSERT_NE(nullptr, arbCheck);
|
||||
|
||||
EXPECT_EQ(1u, arbCheck->getPreFetchDisable());
|
||||
}
|
||||
@@ -20,4 +20,16 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_implicit_scaling.cpp
|
||||
)
|
||||
|
||||
if(TESTS_XEHP_PLUS)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_xehp_plus.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dispatch_kernel_xehp_plus.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_grf_mode_xe_hp_plus.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_implicit_scaling_xehp_plus.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_mi_flush_dw_xehp_plus.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_math_xehp_plus.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_media_interface_descriptor_xehp_plus.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using XeHPPlusHardwareCommandsTest = testing::Test;
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusHardwareCommandsTest, givenXeHPPlusPlatformWhenDoBindingTablePrefetchIsCalledThenReturnsFalse) {
|
||||
EXPECT_FALSE(EncodeSurfaceState<FamilyType>::doBindingTablePrefetch());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusHardwareCommandsTest, GivenXeHPPlusPlatformWhenSetCoherencyTypeIsCalledThenOnlyEncodingSupportedIsSingleGpuCoherent) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
using COHERENCY_TYPE = typename RENDER_SURFACE_STATE::COHERENCY_TYPE;
|
||||
|
||||
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
|
||||
for (COHERENCY_TYPE coherencyType : {RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT, RENDER_SURFACE_STATE::COHERENCY_TYPE_IA_COHERENT}) {
|
||||
EncodeSurfaceState<FamilyType>::setCoherencyType(&surfaceState, coherencyType);
|
||||
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, surfaceState.getCoherencyType());
|
||||
}
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusHardwareCommandsTest, givenXeHPPlusPlatformWhenGetAdditionalPipelineSelectSizeIsCalledThenZeroIsReturned) {
|
||||
MockDevice device;
|
||||
EXPECT_EQ(0u, EncodeWA<FamilyType>::getAdditionalPipelineSelectSize(device));
|
||||
}
|
||||
|
||||
using XeHPPlusCommandEncoderTest = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(XeHPPlusCommandEncoderTest, whenGettingRequiredSizeForStateBaseAddressCommandThenCorrectSizeIsReturned, IsAtLeastXeHpCore) {
|
||||
auto container = CommandContainer();
|
||||
size_t size = EncodeStateBaseAddress<FamilyType>::getRequiredSizeForStateBaseAddress(*pDevice, container);
|
||||
EXPECT_EQ(size, 104ul);
|
||||
}
|
||||
|
||||
HWTEST2_F(XeHPPlusCommandEncoderTest, givenCommandContainerWithDirtyHeapWhenGettingRequiredSizeForStateBaseAddressCommandThenCorrectSizeIsReturned, IsAtLeastXeHpCore) {
|
||||
auto container = CommandContainer();
|
||||
container.setHeapDirty(HeapType::SURFACE_STATE);
|
||||
size_t size = EncodeStateBaseAddress<FamilyType>::getRequiredSizeForStateBaseAddress(*pDevice, container);
|
||||
EXPECT_EQ(size, 104ul);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/stream_properties.h"
|
||||
#include "shared/source/helpers/pipeline_select_helper.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/kernel/grf_config.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/command_container_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using CommandEncodeStatesTest = Test<CommandEncodeStatesFixture>;
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenCommandContainerWhenNumGrfRequiredIsDefaultThenLargeGrfModeDisabled) {
|
||||
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
|
||||
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
|
||||
cmdContainer->lastSentNumGrfRequired = 0;
|
||||
auto stateComputeMode = cmdContainer->getCommandStream()->getSpaceForCmd<STATE_COMPUTE_MODE>();
|
||||
*stateComputeMode = FamilyType::cmdInitStateComputeMode;
|
||||
StreamProperties streamProperties{};
|
||||
streamProperties.stateComputeMode.setProperties(false, cmdContainer->lastSentNumGrfRequired + 1, 0u);
|
||||
EncodeComputeMode<FamilyType>::adjustComputeMode(*cmdContainer->getCommandStream(), stateComputeMode, streamProperties.stateComputeMode, *defaultHwInfo);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed());
|
||||
|
||||
auto itorCmd = find<STATE_COMPUTE_MODE *>(commands.begin(), commands.end());
|
||||
ASSERT_NE(itorCmd, commands.end());
|
||||
|
||||
auto cmd = genCmdCast<STATE_COMPUTE_MODE *>(*itorCmd);
|
||||
|
||||
EXPECT_FALSE(cmd->getLargeGrfMode());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesTest, givenCommandContainerWhenAdjustPipelineSelectCalledThenCommandHasGpgpuType) {
|
||||
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
|
||||
EncodeComputeMode<FamilyType>::adjustPipelineSelect(*cmdContainer.get(), descriptor);
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed());
|
||||
|
||||
auto itorCmd = find<PIPELINE_SELECT *>(commands.begin(), commands.end());
|
||||
ASSERT_NE(itorCmd, commands.end());
|
||||
|
||||
auto cmd = genCmdCast<PIPELINE_SELECT *>(*itorCmd);
|
||||
EXPECT_EQ(cmd->getPipelineSelection(), PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandEncodeStatesTest, givenLargeGrfModeProgrammedThenExpectedCommandSizeAdded, IsXeHpCore) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
|
||||
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
|
||||
|
||||
auto usedSpaceBefore = cmdContainer->getCommandStream()->getUsed();
|
||||
|
||||
auto stateComputeMode = FamilyType::cmdInitStateComputeMode;
|
||||
NEO::EncodeComputeMode<GfxFamily>::adjustPipelineSelect(*cmdContainer, descriptor);
|
||||
StreamProperties streamProperties{};
|
||||
streamProperties.stateComputeMode.setProperties(false, 256u, 0u);
|
||||
NEO::EncodeComputeMode<GfxFamily>::adjustComputeMode(*cmdContainer->getCommandStream(), &stateComputeMode, streamProperties.stateComputeMode, *defaultHwInfo);
|
||||
|
||||
auto usedSpaceAfter = cmdContainer->getCommandStream()->getUsed();
|
||||
ASSERT_GT(usedSpaceAfter, usedSpaceBefore);
|
||||
|
||||
auto expectedCmdSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPELINE_SELECT);
|
||||
auto cmdAddedSize = usedSpaceAfter - usedSpaceBefore;
|
||||
EXPECT_EQ(expectedCmdSize, cmdAddedSize);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandEncodeStatesTest, givenLargeGrfModeDisabledThenExpectedCommandsAreAdded, IsXeHpCore) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
|
||||
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
|
||||
|
||||
auto usedSpaceBefore = cmdContainer->getCommandStream()->getUsed();
|
||||
|
||||
auto stateComputeMode = FamilyType::cmdInitStateComputeMode;
|
||||
NEO::EncodeComputeMode<GfxFamily>::adjustPipelineSelect(*cmdContainer, descriptor);
|
||||
StreamProperties streamProperties{};
|
||||
streamProperties.stateComputeMode.largeGrfMode.set(0);
|
||||
NEO::EncodeComputeMode<GfxFamily>::adjustComputeMode(*cmdContainer->getCommandStream(), &stateComputeMode, streamProperties.stateComputeMode, *defaultHwInfo);
|
||||
|
||||
auto usedSpaceAfter = cmdContainer->getCommandStream()->getUsed();
|
||||
ASSERT_GT(usedSpaceAfter, usedSpaceBefore);
|
||||
|
||||
auto expectedCmdSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPELINE_SELECT);
|
||||
auto cmdAddedSize = usedSpaceAfter - usedSpaceBefore;
|
||||
EXPECT_EQ(expectedCmdSize, cmdAddedSize);
|
||||
|
||||
auto expectedPsCmd = FamilyType::cmdInitPipelineSelect;
|
||||
expectedPsCmd.setSystolicModeEnable(false);
|
||||
expectedPsCmd.setMaskBits(NEO::pipelineSelectSystolicModeEnableMaskBits);
|
||||
expectedPsCmd.setPipelineSelection(PIPELINE_SELECT::PIPELINE_SELECTION_GPGPU);
|
||||
|
||||
auto psCmd = reinterpret_cast<PIPELINE_SELECT *>(ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), usedSpaceBefore));
|
||||
EXPECT_TRUE(memcmp(&expectedPsCmd, psCmd, sizeof(PIPELINE_SELECT)) == 0);
|
||||
|
||||
auto expectedScmCmd = FamilyType::cmdInitStateComputeMode;
|
||||
expectedScmCmd.setLargeGrfMode(false);
|
||||
expectedScmCmd.setMaskBits(FamilyType::stateComputeModeLargeGrfModeMask);
|
||||
|
||||
auto scmCmd = reinterpret_cast<STATE_COMPUTE_MODE *>(ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), (usedSpaceBefore + sizeof(PIPELINE_SELECT))));
|
||||
EXPECT_TRUE(memcmp(&expectedScmCmd, scmCmd, sizeof(STATE_COMPUTE_MODE)) == 0);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/source/helpers/register_offsets.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using XeHPPlusCommandEncoderMathTest = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(XeHPPlusCommandEncoderMathTest, WhenAppendsAGreaterThanThenPredicateCorrectlySetAndRemapEnabled, IsAtLeastXeHpCore) {
|
||||
using MI_LOAD_REGISTER_MEM = typename FamilyType::MI_LOAD_REGISTER_MEM;
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
using MI_LOAD_REGISTER_REG = typename FamilyType::MI_LOAD_REGISTER_REG;
|
||||
using MI_MATH = typename FamilyType::MI_MATH;
|
||||
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
|
||||
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
|
||||
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);
|
||||
|
||||
GenCmdList commands;
|
||||
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
||||
|
||||
auto itor = commands.begin();
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_MEM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMEM = genCmdCast<MI_LOAD_REGISTER_MEM *>(*itor);
|
||||
EXPECT_EQ(CS_GPR_R0, cmdMEM->getRegisterAddress());
|
||||
EXPECT_EQ(0xDEADBEEFCAF0u, cmdMEM->getMemoryAddress());
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_IMM *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdIMM = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itor);
|
||||
EXPECT_EQ(CS_GPR_R1, cmdIMM->getRegisterOffset());
|
||||
EXPECT_EQ(17u, cmdIMM->getDataDword());
|
||||
EXPECT_TRUE(cmdIMM->getMmioRemapEnable());
|
||||
|
||||
itor = find<MI_MATH *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdMATH = genCmdCast<MI_MATH *>(*itor);
|
||||
EXPECT_EQ(cmdMATH->DW0.BitField.DwordLength, 3u);
|
||||
|
||||
itor = find<MI_LOAD_REGISTER_REG *>(itor, commands.end());
|
||||
ASSERT_NE(itor, commands.end());
|
||||
|
||||
auto cmdREG = genCmdCast<MI_LOAD_REGISTER_REG *>(*itor);
|
||||
EXPECT_EQ(cmdREG->getSourceRegisterAddress(), CS_GPR_R2);
|
||||
EXPECT_EQ(cmdREG->getDestinationRegisterAddress(), CS_PREDICATE_RESULT);
|
||||
|
||||
auto cmdALU = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(cmdMATH + 3);
|
||||
EXPECT_EQ(cmdALU->DW0.BitField.ALUOpcode,
|
||||
static_cast<uint32_t>(AluRegisters::OPCODE_SUB));
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/fixtures/command_container_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using CommandEncodeStatesTest = Test<CommandEncodeStatesFixture>;
|
||||
|
||||
HWTEST2_F(CommandEncodeStatesTest, givenCommandContainerWhenEncodingMediaDescriptorThenUsedSizeDidNotIncreased, IsAtLeastXeHpCore) {
|
||||
auto sizeBefore = cmdContainer->getCommandStream()->getUsed();
|
||||
EncodeMediaInterfaceDescriptorLoad<FamilyType>::encode(*cmdContainer.get());
|
||||
auto sizeAfter = cmdContainer->getCommandStream()->getUsed();
|
||||
EXPECT_EQ(sizeBefore, sizeAfter);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_container/command_encoder.h"
|
||||
#include "shared/test/common/fixtures/command_container_fixture.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using XeHPPlusEncodeMiFlushDWTest = Test<CommandEncodeStatesFixture>;
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusEncodeMiFlushDWTest, whenMiFlushDwIsProgrammedThenSetFlushCcsAndLlc) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
uint8_t buffer[2 * sizeof(MI_FLUSH_DW)] = {};
|
||||
LinearStream linearStream(buffer, sizeof(buffer));
|
||||
|
||||
MiFlushArgs args;
|
||||
args.commandWithPostSync = true;
|
||||
EncodeMiFlushDW<FamilyType>::programMiFlushDw(linearStream, 0x1230000, 456, args);
|
||||
auto miFlushDwCmd = reinterpret_cast<MI_FLUSH_DW *>(buffer);
|
||||
EXPECT_EQ(0u, miFlushDwCmd->getFlushCcs());
|
||||
EXPECT_EQ(0u, miFlushDwCmd->getFlushLlc());
|
||||
|
||||
miFlushDwCmd++;
|
||||
EXPECT_EQ(1u, miFlushDwCmd->getFlushCcs());
|
||||
EXPECT_EQ(1u, miFlushDwCmd->getFlushLlc());
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/fixtures/implicit_scaling_fixture.h"
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ImplicitScalingTests, GivenGetSizeWhenDispatchingCmdBufferThenConsumedSizeMatchEstimatedAndCmdBufferHasCorrectCmds) {
|
||||
using WALKER_TYPE = typename FamilyType::WALKER_TYPE;
|
||||
using POSTSYNC_DATA = typename FamilyType::POSTSYNC_DATA;
|
||||
using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
|
||||
uint64_t postSyncAddress = (1ull << 48) | (1ull << 24);
|
||||
|
||||
WALKER_TYPE walker = FamilyType::cmdInitGpgpuWalker;
|
||||
walker.setThreadGroupIdXDimension(32);
|
||||
auto &postSync = walker.getPostSync();
|
||||
postSync.setOperation(POSTSYNC_DATA::OPERATION::OPERATION_WRITE_TIMESTAMP);
|
||||
postSync.setDestinationAddress(postSyncAddress);
|
||||
|
||||
size_t expectedSize = 0;
|
||||
size_t totalBytesProgrammed = 0;
|
||||
|
||||
expectedSize = ImplicitScalingDispatch<FamilyType>::getSize(false, false, twoTile, Vec3<size_t>(0, 0, 0), Vec3<size_t>(32, 1, 1));
|
||||
|
||||
uint32_t partitionCount = 0;
|
||||
ImplicitScalingDispatch<FamilyType>::dispatchCommands(commandStream, walker, twoTile, partitionCount, true, false, false, 0u);
|
||||
totalBytesProgrammed = commandStream.getUsed();
|
||||
EXPECT_EQ(expectedSize, totalBytesProgrammed);
|
||||
EXPECT_EQ(2u, partitionCount);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(commandStream, 0);
|
||||
|
||||
GenCmdList listStartCmd = hwParser.getCommandsList<BATCH_BUFFER_START>();
|
||||
bool secondary = listStartCmd.size() == 0 ? false : true;
|
||||
for (auto &ptr : listStartCmd) {
|
||||
BATCH_BUFFER_START *startCmd = reinterpret_cast<BATCH_BUFFER_START *>(ptr);
|
||||
secondary &= static_cast<bool>(startCmd->getSecondLevelBatchBuffer());
|
||||
}
|
||||
EXPECT_TRUE(secondary);
|
||||
|
||||
GenCmdList walkerList = hwParser.getCommandsList<WALKER_TYPE>();
|
||||
auto itor = find<WALKER_TYPE *>(walkerList.begin(), walkerList.end());
|
||||
ASSERT_NE(itor, walkerList.end());
|
||||
auto walkerCmd = genCmdCast<WALKER_TYPE *>(*itor);
|
||||
EXPECT_EQ(WALKER_TYPE::PARTITION_TYPE::PARTITION_TYPE_X, walkerCmd->getPartitionType());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ImplicitScalingTests, GivenWorkgroupOneAndNoPartitionHintWhenDispatchingCmdBufferThenPartitionCountOneAndPartitionTypeDisabled) {
|
||||
using WALKER_TYPE = typename FamilyType::WALKER_TYPE;
|
||||
using POSTSYNC_DATA = typename FamilyType::POSTSYNC_DATA;
|
||||
using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
|
||||
uint64_t postSyncAddress = (1ull << 48) | (1ull << 24);
|
||||
|
||||
WALKER_TYPE walker = FamilyType::cmdInitGpgpuWalker;
|
||||
walker.setThreadGroupIdXDimension(1);
|
||||
auto &postSync = walker.getPostSync();
|
||||
postSync.setOperation(POSTSYNC_DATA::OPERATION::OPERATION_WRITE_TIMESTAMP);
|
||||
postSync.setDestinationAddress(postSyncAddress);
|
||||
|
||||
size_t expectedSize = 0;
|
||||
size_t totalBytesProgrammed = 0;
|
||||
|
||||
expectedSize = ImplicitScalingDispatch<FamilyType>::getSize(false, false, twoTile, Vec3<size_t>(0, 0, 0), Vec3<size_t>(1, 1, 1));
|
||||
|
||||
uint32_t partitionCount = 0;
|
||||
ImplicitScalingDispatch<FamilyType>::dispatchCommands(commandStream, walker, twoTile, partitionCount, false, false, false, 0u);
|
||||
totalBytesProgrammed = commandStream.getUsed();
|
||||
EXPECT_EQ(expectedSize, totalBytesProgrammed);
|
||||
EXPECT_EQ(1u, partitionCount);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(commandStream, 0);
|
||||
|
||||
GenCmdList listStartCmd = hwParser.getCommandsList<BATCH_BUFFER_START>();
|
||||
bool secondary = listStartCmd.size() == 0 ? true : false;
|
||||
for (auto &ptr : listStartCmd) {
|
||||
BATCH_BUFFER_START *startCmd = reinterpret_cast<BATCH_BUFFER_START *>(ptr);
|
||||
secondary |= static_cast<bool>(startCmd->getSecondLevelBatchBuffer());
|
||||
}
|
||||
EXPECT_FALSE(secondary);
|
||||
|
||||
GenCmdList walkerList = hwParser.getCommandsList<WALKER_TYPE>();
|
||||
auto itor = find<WALKER_TYPE *>(walkerList.begin(), walkerList.end());
|
||||
ASSERT_NE(itor, walkerList.end());
|
||||
auto walkerCmd = genCmdCast<WALKER_TYPE *>(*itor);
|
||||
EXPECT_EQ(WALKER_TYPE::PARTITION_TYPE::PARTITION_TYPE_DISABLED, walkerCmd->getPartitionType());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ImplicitScalingTests, GivenWorkgroupOneAndPartitionHintWhenDispatchingCmdBufferThenPartitionCountOneAndPartitionTypeFromHint) {
|
||||
using WALKER_TYPE = typename FamilyType::WALKER_TYPE;
|
||||
using POSTSYNC_DATA = typename FamilyType::POSTSYNC_DATA;
|
||||
using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
|
||||
uint64_t postSyncAddress = (1ull << 48) | (1ull << 24);
|
||||
|
||||
WALKER_TYPE walker = FamilyType::cmdInitGpgpuWalker;
|
||||
walker.setThreadGroupIdXDimension(1);
|
||||
DebugManager.flags.ExperimentalSetWalkerPartitionType.set(static_cast<int32_t>(WALKER_TYPE::PARTITION_TYPE::PARTITION_TYPE_X));
|
||||
auto &postSync = walker.getPostSync();
|
||||
postSync.setOperation(POSTSYNC_DATA::OPERATION::OPERATION_WRITE_TIMESTAMP);
|
||||
postSync.setDestinationAddress(postSyncAddress);
|
||||
|
||||
size_t expectedSize = 0;
|
||||
size_t totalBytesProgrammed = 0;
|
||||
|
||||
expectedSize = ImplicitScalingDispatch<FamilyType>::getSize(false, false, twoTile, Vec3<size_t>(0, 0, 0), Vec3<size_t>(1, 1, 1));
|
||||
|
||||
uint32_t partitionCount = 0;
|
||||
ImplicitScalingDispatch<FamilyType>::dispatchCommands(commandStream, walker, twoTile, partitionCount, true, false, false, 0u);
|
||||
totalBytesProgrammed = commandStream.getUsed();
|
||||
EXPECT_EQ(expectedSize, totalBytesProgrammed);
|
||||
EXPECT_EQ(1u, partitionCount);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(commandStream, 0);
|
||||
|
||||
GenCmdList listStartCmd = hwParser.getCommandsList<BATCH_BUFFER_START>();
|
||||
bool secondary = listStartCmd.size() == 0 ? false : true;
|
||||
for (auto &ptr : listStartCmd) {
|
||||
BATCH_BUFFER_START *startCmd = reinterpret_cast<BATCH_BUFFER_START *>(ptr);
|
||||
secondary &= static_cast<bool>(startCmd->getSecondLevelBatchBuffer());
|
||||
}
|
||||
EXPECT_TRUE(secondary);
|
||||
|
||||
GenCmdList walkerList = hwParser.getCommandsList<WALKER_TYPE>();
|
||||
auto itor = find<WALKER_TYPE *>(walkerList.begin(), walkerList.end());
|
||||
ASSERT_NE(itor, walkerList.end());
|
||||
auto walkerCmd = genCmdCast<WALKER_TYPE *>(*itor);
|
||||
EXPECT_EQ(WALKER_TYPE::PARTITION_TYPE::PARTITION_TYPE_X, walkerCmd->getPartitionType());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ImplicitScalingTests, GivenStaticPartitioningWhenDispatchingCmdBufferThenCorrectStaticPartitioningCommandsAreProgrammed) {
|
||||
using WALKER_TYPE = typename FamilyType::WALKER_TYPE;
|
||||
using POSTSYNC_DATA = typename FamilyType::POSTSYNC_DATA;
|
||||
using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
using MI_LOAD_REGISTER_MEM = typename FamilyType::MI_LOAD_REGISTER_MEM;
|
||||
|
||||
uint64_t workPartitionAllocationAddress = 0x987654;
|
||||
uint64_t postSyncAddress = (1ull << 48) | (1ull << 24);
|
||||
|
||||
WALKER_TYPE walker = FamilyType::cmdInitGpgpuWalker;
|
||||
walker.setThreadGroupIdXDimension(32);
|
||||
auto &postSync = walker.getPostSync();
|
||||
postSync.setOperation(POSTSYNC_DATA::OPERATION::OPERATION_WRITE_TIMESTAMP);
|
||||
postSync.setDestinationAddress(postSyncAddress);
|
||||
|
||||
size_t expectedSize = 0;
|
||||
size_t totalBytesProgrammed = 0;
|
||||
|
||||
expectedSize = ImplicitScalingDispatch<FamilyType>::getSize(false, true, twoTile, Vec3<size_t>(0, 0, 0), Vec3<size_t>(32, 1, 1));
|
||||
|
||||
uint32_t partitionCount = 0;
|
||||
ImplicitScalingDispatch<FamilyType>::dispatchCommands(commandStream, walker, twoTile, partitionCount, true, false, false, workPartitionAllocationAddress);
|
||||
totalBytesProgrammed = commandStream.getUsed();
|
||||
EXPECT_EQ(expectedSize, totalBytesProgrammed);
|
||||
EXPECT_EQ(2u, partitionCount);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(commandStream, 0);
|
||||
|
||||
GenCmdList listStartCmd = hwParser.getCommandsList<BATCH_BUFFER_START>();
|
||||
bool secondary = listStartCmd.size() == 0 ? false : true;
|
||||
for (auto &ptr : listStartCmd) {
|
||||
BATCH_BUFFER_START *startCmd = reinterpret_cast<BATCH_BUFFER_START *>(ptr);
|
||||
secondary &= static_cast<bool>(startCmd->getSecondLevelBatchBuffer());
|
||||
}
|
||||
EXPECT_TRUE(secondary);
|
||||
|
||||
GenCmdList walkerList = hwParser.getCommandsList<WALKER_TYPE>();
|
||||
auto itor = find<WALKER_TYPE *>(walkerList.begin(), walkerList.end());
|
||||
ASSERT_NE(itor, walkerList.end());
|
||||
auto walkerCmd = genCmdCast<WALKER_TYPE *>(*itor);
|
||||
EXPECT_EQ(WALKER_TYPE::PARTITION_TYPE::PARTITION_TYPE_X, walkerCmd->getPartitionType());
|
||||
|
||||
GenCmdList loadRegisterMemList = hwParser.getCommandsList<MI_LOAD_REGISTER_MEM>();
|
||||
auto itorLrm = find<MI_LOAD_REGISTER_MEM *>(loadRegisterMemList.begin(), loadRegisterMemList.end());
|
||||
ASSERT_NE(itorLrm, loadRegisterMemList.end());
|
||||
auto loadRegisterMem = genCmdCast<MI_LOAD_REGISTER_MEM *>(*itorLrm);
|
||||
EXPECT_TRUE(loadRegisterMem->getMmioRemapEnable());
|
||||
EXPECT_EQ(workPartitionAllocationAddress, loadRegisterMem->getMemoryAddress());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ImplicitScalingTests, GivenStaticPartitioningPreferredAndPartitionCountIsOneWhenDispatchingCmdBufferThenCorrectStaticPartitioningCommandsAreProgrammed) {
|
||||
using WALKER_TYPE = typename FamilyType::WALKER_TYPE;
|
||||
using POSTSYNC_DATA = typename FamilyType::POSTSYNC_DATA;
|
||||
using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START;
|
||||
using MI_LOAD_REGISTER_MEM = typename FamilyType::MI_LOAD_REGISTER_MEM;
|
||||
|
||||
uint64_t workPartitionAllocationAddress = 0x987654;
|
||||
uint64_t postSyncAddress = (1ull << 48) | (1ull << 24);
|
||||
|
||||
WALKER_TYPE walker = FamilyType::cmdInitGpgpuWalker;
|
||||
walker.setThreadGroupIdXDimension(1);
|
||||
auto &postSync = walker.getPostSync();
|
||||
postSync.setOperation(POSTSYNC_DATA::OPERATION::OPERATION_WRITE_TIMESTAMP);
|
||||
postSync.setDestinationAddress(postSyncAddress);
|
||||
|
||||
size_t expectedSize = 0;
|
||||
size_t totalBytesProgrammed = 0;
|
||||
|
||||
expectedSize = ImplicitScalingDispatch<FamilyType>::getSize(false, true, twoTile, Vec3<size_t>(0, 0, 0), Vec3<size_t>(1, 1, 1));
|
||||
|
||||
uint32_t partitionCount = 0;
|
||||
ImplicitScalingDispatch<FamilyType>::dispatchCommands(commandStream, walker, twoTile, partitionCount, true, false, false, workPartitionAllocationAddress);
|
||||
totalBytesProgrammed = commandStream.getUsed();
|
||||
EXPECT_EQ(expectedSize, totalBytesProgrammed);
|
||||
EXPECT_EQ(twoTile.count(), partitionCount);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(commandStream, 0);
|
||||
|
||||
GenCmdList listStartCmd = hwParser.getCommandsList<BATCH_BUFFER_START>();
|
||||
bool secondary = listStartCmd.size() == 0 ? false : true;
|
||||
for (auto &ptr : listStartCmd) {
|
||||
BATCH_BUFFER_START *startCmd = reinterpret_cast<BATCH_BUFFER_START *>(ptr);
|
||||
secondary &= static_cast<bool>(startCmd->getSecondLevelBatchBuffer());
|
||||
}
|
||||
EXPECT_TRUE(secondary);
|
||||
|
||||
GenCmdList walkerList = hwParser.getCommandsList<WALKER_TYPE>();
|
||||
auto itor = find<WALKER_TYPE *>(walkerList.begin(), walkerList.end());
|
||||
ASSERT_NE(itor, walkerList.end());
|
||||
auto walkerCmd = genCmdCast<WALKER_TYPE *>(*itor);
|
||||
EXPECT_EQ(WALKER_TYPE::PARTITION_TYPE::PARTITION_TYPE_X, walkerCmd->getPartitionType());
|
||||
|
||||
GenCmdList loadRegisterMemList = hwParser.getCommandsList<MI_LOAD_REGISTER_MEM>();
|
||||
auto itorLrm = find<MI_LOAD_REGISTER_MEM *>(loadRegisterMemList.begin(), loadRegisterMemList.end());
|
||||
ASSERT_NE(itorLrm, loadRegisterMemList.end());
|
||||
}
|
||||
@@ -9,4 +9,10 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preemption_tests.cpp
|
||||
)
|
||||
|
||||
if(TESTS_XEHP_PLUS)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_xehp_plus.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
115
shared/test/unit_test/preemption/test_preemption_xehp_plus.cpp
Normal file
115
shared/test/unit_test/preemption/test_preemption_xehp_plus.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
||||
#include "shared/test/common/fixtures/preemption_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_debugger.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_buffer.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_csr.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
using XeHPPlusPreemptionTests = DevicePreemptionTests;
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusPreemptionTests, whenProgramStateSipIsCalledThenStateSipCmdIsNotAddedToStream) {
|
||||
size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
EXPECT_EQ(0U, requiredSize);
|
||||
|
||||
LinearStream cmdStream{nullptr, 0};
|
||||
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device);
|
||||
EXPECT_EQ(0U, cmdStream.getUsed());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusPreemptionTests, WhenProgrammingThenWaHasExpectedSize) {
|
||||
size_t expectedSize = 0;
|
||||
EXPECT_EQ(expectedSize, PreemptionHelper::getPreemptionWaCsSize<FamilyType>(*device));
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusPreemptionTests, WhenProgrammingThenWaNotApplied) {
|
||||
size_t usedSize = 0;
|
||||
|
||||
auto requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
StackVec<char, 4096> buff(requiredSize);
|
||||
LinearStream cmdStream(buff.begin(), buff.size());
|
||||
|
||||
PreemptionHelper::applyPreemptionWaCmdsBegin<FamilyType>(&cmdStream, *device);
|
||||
EXPECT_EQ(usedSize, cmdStream.getUsed());
|
||||
PreemptionHelper::applyPreemptionWaCmdsEnd<FamilyType>(&cmdStream, *device);
|
||||
EXPECT_EQ(usedSize, cmdStream.getUsed());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusPreemptionTests, givenInterfaceDescriptorDataWhenMidThreadPreemptionModeThenSetDisableThreadPreemptionBitToDisable) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA iddArg;
|
||||
iddArg = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidThread);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE, iddArg.getThreadPreemptionDisable());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusPreemptionTests, givenInterfaceDescriptorDataWhenNoMidThreadPreemptionModeThenSetDisableThreadPreemptionBitToEnable) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA iddArg;
|
||||
iddArg = FamilyType::cmdInitInterfaceDescriptorData;
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::Disabled);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::MidBatch);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
|
||||
iddArg.setThreadPreemptionDisable(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_DISABLE);
|
||||
|
||||
PreemptionHelper::programInterfaceDescriptorDataPreemption<FamilyType>(&iddArg, PreemptionMode::ThreadGroup);
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::THREAD_PREEMPTION_DISABLE_ENABLE, iddArg.getThreadPreemptionDisable());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusPreemptionTests, WhenProgrammingPreemptionThenExpectLoadRegisterCommandRemapFlagEnabled) {
|
||||
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
||||
|
||||
const size_t bufferSize = 128;
|
||||
uint8_t buffer[bufferSize];
|
||||
LinearStream cmdStream(buffer, bufferSize);
|
||||
|
||||
PreemptionHelper::programCmdStream<FamilyType>(cmdStream, PreemptionMode::ThreadGroup, PreemptionMode::Initial, nullptr);
|
||||
auto lriCommand = genCmdCast<MI_LOAD_REGISTER_IMM *>(cmdStream.getCpuBase());
|
||||
ASSERT_NE(nullptr, lriCommand);
|
||||
EXPECT_TRUE(lriCommand->getMmioRemapEnable());
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusPreemptionTests, GivenDebuggerUsedWhenProgrammingStateSipThenStateSipIsAdded) {
|
||||
using STATE_SIP = typename FamilyType::STATE_SIP;
|
||||
device->executionEnvironment->rootDeviceEnvironments[0]->debugger.reset(new MockDebugger);
|
||||
|
||||
size_t requiredSize = PreemptionHelper::getRequiredStateSipCmdSize<FamilyType>(*device);
|
||||
EXPECT_EQ(sizeof(STATE_SIP), requiredSize);
|
||||
|
||||
const size_t bufferSize = 128;
|
||||
uint64_t buffer[bufferSize];
|
||||
|
||||
LinearStream cmdStream{buffer, bufferSize * sizeof(uint64_t)};
|
||||
PreemptionHelper::programStateSip<FamilyType>(cmdStream, *device);
|
||||
EXPECT_EQ(sizeof(STATE_SIP), cmdStream.getUsed());
|
||||
|
||||
auto sipAllocation = SipKernel::getSipKernel(*device).getSipAllocation();
|
||||
auto sipCommand = genCmdCast<STATE_SIP *>(cmdStream.getCpuBase());
|
||||
auto sipAddress = sipCommand->getSystemInstructionPointer();
|
||||
|
||||
EXPECT_EQ(sipAllocation->getGpuAddressToPatch(), sipAddress);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
# Copyright (C) 2020-2021 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -9,4 +9,10 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scratch_space_controler_tests.cpp
|
||||
)
|
||||
|
||||
if(TESTS_XEHP_PLUS)
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/scratch_space_controler_xehp_plus_tests.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/scratch_space_controller_xehp_plus.h"
|
||||
#include "shared/source/helpers/bindless_heaps_helper.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MockScratchSpaceControllerXeHPPlus : public ScratchSpaceControllerXeHPPlus {
|
||||
public:
|
||||
using ScratchSpaceControllerXeHPPlus::bindlessSS;
|
||||
using ScratchSpaceControllerXeHPPlus::scratchAllocation;
|
||||
using ScratchSpaceControllerXeHPPlus::singleSurfaceStateSize;
|
||||
|
||||
MockScratchSpaceControllerXeHPPlus(uint32_t rootDeviceIndex,
|
||||
ExecutionEnvironment &environment,
|
||||
InternalAllocationStorage &allocationStorage) : ScratchSpaceControllerXeHPPlus(rootDeviceIndex, environment, allocationStorage) {
|
||||
scratchAllocation = &alloc;
|
||||
}
|
||||
~MockScratchSpaceControllerXeHPPlus() override {
|
||||
scratchAllocation = nullptr;
|
||||
}
|
||||
void programSurfaceStateAtPtr(void *surfaceStateForScratchAllocation) override {
|
||||
wasProgramSurfaceStateAtPtrCalled = true;
|
||||
}
|
||||
void prepareScratchAllocation(uint32_t requiredPerThreadScratchSize,
|
||||
uint32_t requiredPerThreadPrivateScratchSize,
|
||||
uint32_t currentTaskCount,
|
||||
OsContext &osContext,
|
||||
bool &stateBaseAddressDirty,
|
||||
bool &scratchSurfaceDirty,
|
||||
bool &vfeStateDirty) override {
|
||||
scratchSurfaceDirty = scratchDirty;
|
||||
}
|
||||
ResidencyContainer residencyContainer;
|
||||
MockGraphicsAllocation alloc;
|
||||
bool wasProgramSurfaceStateAtPtrCalled = false;
|
||||
bool scratchDirty = false;
|
||||
};
|
||||
|
||||
using ScratchComtrolerTests = Test<DeviceFixture>;
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenBindlessModeOnWhenGetPatchedOffsetCalledThenBindlessOffsetReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
MockCsrHw2<FamilyType> csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield());
|
||||
csr.initializeTagAllocation();
|
||||
csr.setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
ExecutionEnvironment *execEnv = static_cast<ExecutionEnvironment *>(pDevice->getExecutionEnvironment());
|
||||
std::unique_ptr<MockScratchSpaceControllerXeHPPlus> scratchController = std::make_unique<MockScratchSpaceControllerXeHPPlus>(pDevice->getRootDeviceIndex(),
|
||||
*execEnv,
|
||||
*csr.getInternalAllocationStorage());
|
||||
uint64_t bindlessOffset = 0x4000;
|
||||
scratchController->bindlessSS.surfaceStateOffset = bindlessOffset;
|
||||
EXPECT_EQ(scratchController->getScratchPatchAddress(), bindlessOffset);
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenDirtyScratchAllocationOnWhenWhenProgramBindlessHeapThenProgramSurfaceStateAtPtrCalled) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
MockCommandStreamReceiver csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield());
|
||||
csr.initializeTagAllocation();
|
||||
csr.setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
ExecutionEnvironment *execEnv = static_cast<ExecutionEnvironment *>(pDevice->getExecutionEnvironment());
|
||||
std::unique_ptr<MockScratchSpaceControllerXeHPPlus> scratchController = std::make_unique<MockScratchSpaceControllerXeHPPlus>(pDevice->getRootDeviceIndex(),
|
||||
*execEnv,
|
||||
*csr.getInternalAllocationStorage());
|
||||
auto bindlessHeapHelper = std::make_unique<BindlessHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
bool gsbaStateDirty = false;
|
||||
bool frontEndStateDirty = false;
|
||||
scratchController->scratchDirty = true;
|
||||
scratchController->programBindlessSurfaceStateForScratch(bindlessHeapHelper.get(), 0, 0, 0, *pDevice->getDefaultEngine().osContext, gsbaStateDirty, frontEndStateDirty, &csr);
|
||||
EXPECT_GT(csr.makeResidentCalledTimes, 0u);
|
||||
EXPECT_TRUE(scratchController->wasProgramSurfaceStateAtPtrCalled);
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenNotDirtyScratchAllocationOnWhenWhenProgramBindlessHeapThenProgramSurfaceStateAtPtrWasNotCalled) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
MockCommandStreamReceiver csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield());
|
||||
csr.initializeTagAllocation();
|
||||
csr.setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
ExecutionEnvironment *execEnv = static_cast<ExecutionEnvironment *>(pDevice->getExecutionEnvironment());
|
||||
std::unique_ptr<MockScratchSpaceControllerXeHPPlus> scratchController = std::make_unique<MockScratchSpaceControllerXeHPPlus>(pDevice->getRootDeviceIndex(),
|
||||
*execEnv,
|
||||
*csr.getInternalAllocationStorage());
|
||||
auto bindlessHeapHelper = std::make_unique<BindlessHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
bool gsbaStateDirty = false;
|
||||
bool frontEndStateDirty = false;
|
||||
scratchController->scratchDirty = false;
|
||||
|
||||
scratchController->bindlessSS = bindlessHeapHelper->allocateSSInHeap(0x1000, nullptr, BindlessHeapsHelper::SCRATCH_SSH);
|
||||
scratchController->programBindlessSurfaceStateForScratch(bindlessHeapHelper.get(), 0, 0, 0, *pDevice->getDefaultEngine().osContext, gsbaStateDirty, frontEndStateDirty, &csr);
|
||||
EXPECT_GT(csr.makeResidentCalledTimes, 0u);
|
||||
EXPECT_FALSE(scratchController->wasProgramSurfaceStateAtPtrCalled);
|
||||
}
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchEnabledWhenWhenProgramBindlessHeapSurfaceThenSSHasDoubleSize) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
DebugManager.flags.EnablePrivateScratchSlot1.set(1);
|
||||
MockCsrHw2<FamilyType> csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield());
|
||||
csr.initializeTagAllocation();
|
||||
csr.setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
ExecutionEnvironment *execEnv = static_cast<ExecutionEnvironment *>(pDevice->getExecutionEnvironment());
|
||||
std::unique_ptr<MockScratchSpaceControllerXeHPPlus> scratchController = std::make_unique<MockScratchSpaceControllerXeHPPlus>(pDevice->getRootDeviceIndex(),
|
||||
*execEnv,
|
||||
*csr.getInternalAllocationStorage());
|
||||
auto bindlessHeapHelper = std::make_unique<BindlessHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
bool gsbaStateDirty = false;
|
||||
bool frontEndStateDirty = false;
|
||||
scratchController->scratchDirty = true;
|
||||
auto usedBefore = bindlessHeapHelper->getHeap(BindlessHeapsHelper::SCRATCH_SSH)->getUsed();
|
||||
scratchController->programBindlessSurfaceStateForScratch(bindlessHeapHelper.get(), 0, 0, 0, *pDevice->getDefaultEngine().osContext, gsbaStateDirty, frontEndStateDirty, &csr);
|
||||
auto usedAfter = bindlessHeapHelper->getHeap(BindlessHeapsHelper::SCRATCH_SSH)->getUsed();
|
||||
EXPECT_EQ(usedAfter - usedBefore, 2 * scratchController->singleSurfaceStateSize);
|
||||
}
|
||||
|
||||
HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchDisabledWhenWhenProgramBindlessHeapSurfaceThenSSHasSingleSize) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.UseBindlessMode.set(1);
|
||||
DebugManager.flags.EnablePrivateScratchSlot1.set(0);
|
||||
MockCsrHw2<FamilyType> csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield());
|
||||
csr.initializeTagAllocation();
|
||||
csr.setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
ExecutionEnvironment *execEnv = static_cast<ExecutionEnvironment *>(pDevice->getExecutionEnvironment());
|
||||
std::unique_ptr<MockScratchSpaceControllerXeHPPlus> scratchController = std::make_unique<MockScratchSpaceControllerXeHPPlus>(pDevice->getRootDeviceIndex(),
|
||||
*execEnv,
|
||||
*csr.getInternalAllocationStorage());
|
||||
auto bindlessHeapHelper = std::make_unique<BindlessHeapsHelper>(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
|
||||
bool gsbaStateDirty = false;
|
||||
bool frontEndStateDirty = false;
|
||||
scratchController->scratchDirty = true;
|
||||
auto usedBefore = bindlessHeapHelper->getHeap(BindlessHeapsHelper::SCRATCH_SSH)->getUsed();
|
||||
scratchController->programBindlessSurfaceStateForScratch(bindlessHeapHelper.get(), 0, 0, 0, *pDevice->getDefaultEngine().osContext, gsbaStateDirty, frontEndStateDirty, &csr);
|
||||
auto usedAfter = bindlessHeapHelper->getHeap(BindlessHeapsHelper::SCRATCH_SSH)->getUsed();
|
||||
EXPECT_EQ(usedAfter - usedBefore, scratchController->singleSurfaceStateSize);
|
||||
}
|
||||
Reference in New Issue
Block a user