Move some Xe Hpc tests from opencl to shared

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-01-21 13:15:47 +00:00
committed by Compute-Runtime-Automation
parent bbea52f3f9
commit fdef257b01
6 changed files with 14 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2021 Intel Corporation
# Copyright (C) 2021-2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -8,8 +8,12 @@ if(TESTS_XE_HPC_CORE)
set(NEO_SHARED_tests_xe_hpc_core
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/aub_command_stream_receiver_2_tests_xe_hpc_core.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_tests_xe_hpc_core.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dispatch_walker_tests_xe_hpc_core.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_cmds_xe_hpc_core_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_xe_hpc_core_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_xe_hpc_core.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_sample_xe_hpc_core.cpp
)
if(DEFINED AUB_STREAM_PROJECT_NAME)

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
using CmdParseTestsXeHpcCore = ::testing::Test;
XE_HPC_CORETEST_F(CmdParseTestsXeHpcCore, givenMiMemFenceCmdWhenParsingThenFindCommandAndsItsName) {
using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE;
uint32_t buffer[64] = {};
LinearStream cmdStream(buffer, sizeof(buffer));
auto miMemFenceCmd = cmdStream.getSpaceForCmd<MI_MEM_FENCE>();
miMemFenceCmd->init();
EXPECT_NE(nullptr, genCmdCast<MI_MEM_FENCE *>(buffer));
auto commandName = CmdParse<FamilyType>::getCommandName(buffer);
EXPECT_EQ(0, strcmp(commandName, "MI_MEM_FENCE"));
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(cmdStream, 0);
EXPECT_EQ(1u, hwParser.cmdList.size());
}
XE_HPC_CORETEST_F(CmdParseTestsXeHpcCore, givenStateSystemMemFenceAddrCmdWhenParsingThenFindCommandAndsItsName) {
using STATE_SYSTEM_MEM_FENCE_ADDRESS = typename FamilyType::STATE_SYSTEM_MEM_FENCE_ADDRESS;
uint32_t buffer[64] = {};
LinearStream cmdStream(buffer, sizeof(buffer));
auto stateSystemMemFenceCmd = cmdStream.getSpaceForCmd<STATE_SYSTEM_MEM_FENCE_ADDRESS>();
stateSystemMemFenceCmd->init();
EXPECT_NE(nullptr, genCmdCast<STATE_SYSTEM_MEM_FENCE_ADDRESS *>(buffer));
auto commandName = CmdParse<FamilyType>::getCommandName(buffer);
EXPECT_EQ(0, strcmp(commandName, "STATE_SYSTEM_MEM_FENCE_ADDRESS"));
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(cmdStream, 0);
EXPECT_EQ(1u, hwParser.cmdList.size());
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
using WalkerDispatchTestsXeHpcCore = ::testing::Test;
XE_HPC_CORETEST_F(WalkerDispatchTestsXeHpcCore, whenEncodeAdditionalWalkerFieldsThenPostSyncDataIsCorrectlySet) {
struct {
unsigned short revisionId;
int32_t programGlobalFenceAsPostSyncOperationInComputeWalker;
bool expectSystemMemoryFenceRequest;
} testInputs[] = {
{0x0, -1, false},
{0x3, -1, true},
{0x0, 0, false},
{0x3, 0, false},
{0x0, 1, true},
{0x3, 1, true},
};
DebugManagerStateRestore debugRestorer;
auto walkerCmd = FamilyType::cmdInitGpgpuWalker;
auto &postSyncData = walkerCmd.getPostSync();
auto hwInfo = *defaultHwInfo;
for (auto &testInput : testInputs) {
hwInfo.platform.usRevId = testInput.revisionId;
DebugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(
testInput.programGlobalFenceAsPostSyncOperationInComputeWalker);
postSyncData.setSystemMemoryFenceRequest(false);
EncodeDispatchKernel<FamilyType>::encodeAdditionalWalkerFields(hwInfo, walkerCmd, KernelExecutionType::Default);
EXPECT_EQ(testInput.expectSystemMemoryFenceRequest, postSyncData.getSystemMemoryFenceRequest());
}
}
XE_HPC_CORETEST_F(WalkerDispatchTestsXeHpcCore, givenPvcWhenEncodeAdditionalWalkerFieldsIsCalledThenComputeDispatchAllIsCorrectlySet) {
using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER;
DebugManagerStateRestore debugRestorer;
auto walkerCmd = FamilyType::cmdInitGpgpuWalker;
auto hwInfo = *defaultHwInfo;
{
EncodeDispatchKernel<FamilyType>::encodeAdditionalWalkerFields(hwInfo, walkerCmd, KernelExecutionType::Default);
EXPECT_FALSE(walkerCmd.getComputeDispatchAllWalkerEnable());
}
{
DebugManager.flags.ComputeDispatchAllWalkerEnableInComputeWalker.set(1);
EncodeDispatchKernel<FamilyType>::encodeAdditionalWalkerFields(hwInfo, walkerCmd, KernelExecutionType::Default);
EXPECT_TRUE(walkerCmd.getComputeDispatchAllWalkerEnable());
}
}
XE_HPC_CORETEST_F(WalkerDispatchTestsXeHpcCore, givenPvcXtTemporaryWhenEncodeAdditionalWalkerFieldsIsCalledThenComputeDispatchAllIsCorrectlySet) {
using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER;
auto hwInfo = *defaultHwInfo;
hwInfo.platform.usDeviceID = 0x0BE5;
auto walkerCmd = FamilyType::cmdInitGpgpuWalker;
{
EncodeDispatchKernel<FamilyType>::encodeAdditionalWalkerFields(hwInfo, walkerCmd, KernelExecutionType::Default);
EXPECT_FALSE(walkerCmd.getComputeDispatchAllWalkerEnable());
}
{
EncodeDispatchKernel<FamilyType>::encodeAdditionalWalkerFields(hwInfo, walkerCmd, KernelExecutionType::Concurrent);
EXPECT_TRUE(walkerCmd.getComputeDispatchAllWalkerEnable());
}
}

View File

@@ -0,0 +1,180 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/preamble/preamble_fixture.h"
using namespace NEO;
using PreambleCfeState = PreambleFixture;
XE_HPC_CORETEST_F(PreambleCfeState, givenPvcAndKernelExecutionTypeAndRevisionWhenCallingProgramVFEStateThenCFEStateParamsAreCorrectlySet) {
using CFE_STATE = typename FamilyType::CFE_STATE;
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
const auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo->platform.eProductFamily);
auto pVfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, *hwInfo, EngineGroupType::RenderCompute);
StreamProperties streamProperties{};
std::array<std::pair<uint32_t, bool>, 4> revisions = {
{{REVISION_A0, false},
{REVISION_A0, true},
{REVISION_B, false},
{REVISION_B, true}}};
for (const auto &[revision, kernelExecutionType] : revisions) {
hwInfo->platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(revision, *hwInfo);
streamProperties.frontEndState.setProperties(kernelExecutionType, false, false, *hwInfo);
PreambleHelper<FamilyType>::programVfeState(pVfeCmd, *hwInfo, 0u, 0, 0, streamProperties);
parseCommands<FamilyType>(linearStream);
auto cfeStateIt = find<CFE_STATE *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), cfeStateIt);
auto cfeState = reinterpret_cast<CFE_STATE *>(*cfeStateIt);
auto expectedValue = (HwInfoConfig::get(hwInfo->platform.eProductFamily)->getSteppingFromHwRevId(*hwInfo) >= REVISION_B) &&
(!XE_HPC_CORE::isXtTemporary(*defaultHwInfo)) &&
kernelExecutionType;
EXPECT_EQ(expectedValue, cfeState->getComputeDispatchAllWalkerEnable());
EXPECT_EQ(expectedValue, cfeState->getSingleSliceDispatchCcsMode());
EXPECT_FALSE(cfeState->getComputeOverdispatchDisable());
}
}
XE_HPC_CORETEST_F(PreambleCfeState, givenPvcXtTemporaryAndKernelExecutionTypeConcurrentAndRevisionBWhenCallingProgramVFEStateThenAllWalkerIsDisabled) {
using CFE_STATE = typename FamilyType::CFE_STATE;
auto hwInfo = *defaultHwInfo;
hwInfo.platform.usDeviceID = 0x0BE5;
const auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo);
auto pVfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, hwInfo, EngineGroupType::RenderCompute);
StreamProperties streamProperties{};
streamProperties.frontEndState.setProperties(true, false, false, hwInfo);
PreambleHelper<FamilyType>::programVfeState(pVfeCmd, hwInfo, 0u, 0, 0, streamProperties);
parseCommands<FamilyType>(linearStream);
auto cfeStateIt = find<CFE_STATE *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), cfeStateIt);
auto cfeState = reinterpret_cast<CFE_STATE *>(*cfeStateIt);
EXPECT_FALSE(cfeState->getComputeDispatchAllWalkerEnable());
EXPECT_FALSE(cfeState->getSingleSliceDispatchCcsMode());
}
XE_HPC_CORETEST_F(PreambleCfeState, givenXeHpcCoreAndSetDebugFlagWhenPreambleCfeStateIsProgrammedThenCFEStateParamsHaveSetValue) {
using CFE_STATE = typename FamilyType::CFE_STATE;
DebugManagerStateRestore dbgRestore;
uint32_t expectedValue = 1u;
DebugManager.flags.CFEComputeDispatchAllWalkerEnable.set(expectedValue);
uint64_t expectedAddress = 1 << CFE_STATE::SCRATCHSPACEBUFFER_BIT_SHIFT;
auto pVfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, *defaultHwInfo, EngineGroupType::RenderCompute);
StreamProperties emptyProperties{};
PreambleHelper<FamilyType>::programVfeState(pVfeCmd, *defaultHwInfo, 0u, expectedAddress, 16u, emptyProperties);
parseCommands<FamilyType>(linearStream);
auto cfeStateIt = find<CFE_STATE *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), cfeStateIt);
auto cfeState = reinterpret_cast<CFE_STATE *>(*cfeStateIt);
EXPECT_EQ(expectedValue, cfeState->getComputeDispatchAllWalkerEnable());
EXPECT_FALSE(cfeState->getSingleSliceDispatchCcsMode());
}
XE_HPC_CORETEST_F(PreambleCfeState, givenNotSetDebugFlagWhenPreambleCfeStateIsProgrammedThenCFEStateParamsHaveNotSetValue) {
using CFE_STATE = typename FamilyType::CFE_STATE;
auto cfeState = reinterpret_cast<CFE_STATE *>(linearStream.getSpace(sizeof(CFE_STATE)));
*cfeState = FamilyType::cmdInitCfeState;
uint32_t numberOfWalkers = cfeState->getNumberOfWalkers();
uint32_t overDispatchControl = static_cast<uint32_t>(cfeState->getOverDispatchControl());
uint32_t singleDispatchCcsMode = cfeState->getSingleSliceDispatchCcsMode();
uint64_t expectedAddress = 1 << CFE_STATE::SCRATCHSPACEBUFFER_BIT_SHIFT;
uint32_t expectedMaxThreads = HwHelper::getMaxThreadsForVfe(*defaultHwInfo);
auto pVfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, *defaultHwInfo, EngineGroupType::RenderCompute);
StreamProperties emptyProperties{};
PreambleHelper<FamilyType>::programVfeState(pVfeCmd, *defaultHwInfo, 0u, expectedAddress, expectedMaxThreads, emptyProperties);
uint32_t maximumNumberOfThreads = cfeState->getMaximumNumberOfThreads();
EXPECT_EQ(numberOfWalkers, cfeState->getNumberOfWalkers());
EXPECT_NE(expectedMaxThreads, maximumNumberOfThreads);
EXPECT_EQ(overDispatchControl, static_cast<uint32_t>(cfeState->getOverDispatchControl()));
EXPECT_EQ(singleDispatchCcsMode, cfeState->getSingleSliceDispatchCcsMode());
}
XE_HPC_CORETEST_F(PreambleCfeState, givenSetDebugFlagWhenPreambleCfeStateIsProgrammedThenCFEStateParamsHaveSetValue) {
using CFE_STATE = typename FamilyType::CFE_STATE;
uint32_t expectedValue1 = 1u;
uint32_t expectedValue2 = 2u;
DebugManagerStateRestore dbgRestore;
DebugManager.flags.CFEFusedEUDispatch.set(expectedValue1);
DebugManager.flags.CFEOverDispatchControl.set(expectedValue1);
DebugManager.flags.CFESingleSliceDispatchCCSMode.set(expectedValue1);
DebugManager.flags.CFELargeGRFThreadAdjustDisable.set(expectedValue1);
DebugManager.flags.CFENumberOfWalkers.set(expectedValue2);
DebugManager.flags.CFEMaximumNumberOfThreads.set(expectedValue2);
uint64_t expectedAddress = 1 << CFE_STATE::SCRATCHSPACEBUFFER_BIT_SHIFT;
auto pVfeCmd = PreambleHelper<FamilyType>::getSpaceForVfeState(&linearStream, *defaultHwInfo, EngineGroupType::RenderCompute);
StreamProperties emptyProperties{};
PreambleHelper<FamilyType>::programVfeState(pVfeCmd, *defaultHwInfo, 0u, expectedAddress, 16u, emptyProperties);
parseCommands<FamilyType>(linearStream);
auto cfeStateIt = find<CFE_STATE *>(cmdList.begin(), cmdList.end());
ASSERT_NE(cmdList.end(), cfeStateIt);
auto cfeState = reinterpret_cast<CFE_STATE *>(*cfeStateIt);
EXPECT_EQ(expectedValue1, cfeState->getSingleSliceDispatchCcsMode());
EXPECT_EQ(expectedValue1, static_cast<uint32_t>(cfeState->getOverDispatchControl()));
EXPECT_EQ(expectedValue1, cfeState->getLargeGRFThreadAdjustDisable());
EXPECT_EQ(expectedValue2, cfeState->getNumberOfWalkers());
EXPECT_EQ(expectedValue2, cfeState->getMaximumNumberOfThreads());
}
using PreamblePipelineSelectState = PreambleFixture;
XE_HPC_CORETEST_F(PreamblePipelineSelectState, givenRevisionBAndAboveWhenCallingProgramPipelineSelectThenSystolicModeDisabled) {
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
auto hwInfo = pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
PipelineSelectArgs pipelineArgs;
pipelineArgs.specialPipelineSelectMode = true;
struct {
unsigned short revId;
bool expectedValue;
} testInputs[] = {
{0x0, true},
{0x1, true},
{0x3, true},
{0x5, false},
{0x6, false},
{0x7, false},
};
for (auto &testInput : testInputs) {
LinearStream linearStream(&gfxAllocation);
hwInfo->platform.usRevId = testInput.revId;
PreambleHelper<FamilyType>::programPipelineSelect(&linearStream, pipelineArgs, *hwInfo);
parseCommands<FamilyType>(linearStream);
auto itorCmd = find<PIPELINE_SELECT *>(cmdList.begin(), cmdList.end());
ASSERT_NE(itorCmd, cmdList.end());
auto cmd = genCmdCast<PIPELINE_SELECT *>(*itorCmd);
EXPECT_EQ(testInput.expectedValue, cmd->getSystolicModeEnable());
}
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/test_macros/test.h"
using namespace NEO;
using PvcOnlyTest = Test<DeviceFixture>;
PVCTEST_F(PvcOnlyTest, WhenGettingHardwareInfoThenPvcIsReturned) {
EXPECT_EQ(IGFX_PVC, pDevice->getHardwareInfo().platform.eProductFamily);
}
using XeHpcCoreOnlyTest = Test<DeviceFixture>;
XE_HPC_CORETEST_F(XeHpcCoreOnlyTest, WhenGettingRenderCoreFamilyThenOnlyHpcCoreIsReturned) {
EXPECT_EQ(IGFX_XE_HPC_CORE, pDevice->getRenderCoreFamily());
}