Move HwHelper tests to shared

Signed-off-by: Rafal Maziejuk <rafal.maziejuk@intel.com>
This commit is contained in:
Rafal Maziejuk
2022-11-29 13:33:04 +00:00
committed by Compute-Runtime-Automation
parent 5d6caa6b79
commit f7cb924d2d
8 changed files with 47 additions and 28 deletions

View File

@ -7,11 +7,11 @@
if(TESTS_PVC)
set(IGDRCL_SRCS_tests_xe_hpc_core_pvc
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/cl_hw_helper_tests_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/command_stream_receiver_hw_tests_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_device_info_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_device_caps_pvc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_pvc.cpp
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_xe_hpc_core_pvc})
add_subdirectories()

View File

@ -0,0 +1,34 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/xe_hpc_core/hw_cmds_pvc.h"
#include "shared/test/common/helpers/ult_hw_config.h"
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.h"
namespace NEO {
using ClHwHelperTestsPvcXt = Test<ClHwHelperXeHpcCoreFixture>;
PVCTEST_F(ClHwHelperTestsPvcXt, givenSingleTileCsrOnPvcXtWhenAllocatingCsrSpecificAllocationsAndIsNotBaseDieA0ThenStoredInProperMemoryPool) {
auto hwInfo = *defaultHwInfo;
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
hwInfo.platform.usDeviceID = pvcXtDeviceIds.front();
hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); // not BD A0
checkIfSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInProperMemoryPool(&hwInfo);
}
PVCTEST_F(ClHwHelperTestsPvcXt, givenMultiTileCsrOnPvcWhenAllocatingCsrSpecificAllocationsAndIsNotBaseDieA0ThenStoredInLocalMemoryPool) {
auto hwInfo = *defaultHwInfo;
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
hwInfo.platform.usDeviceID = pvcXtDeviceIds.front();
hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); // not BD A0
checkIfMultiTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInLocalMemoryPool(&hwInfo);
}
} // namespace NEO

View File

@ -1,172 +0,0 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/xe_hpc_core/hw_cmds_pvc.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/ult_hw_config.h"
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
#include "shared/test/common/test_macros/test.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "opencl/test/unit_test/xe_hpc_core/xe_hpc_core_test_ocl_fixtures.h"
namespace NEO {
using HwHelperTestsPvcXt = Test<HwHelperTestsXeHpcCore>;
PVCTEST_F(HwHelperTestsPvcXt, givenSingleTileCsrOnPvcXtWhenAllocatingCsrSpecificAllocationsAndIsNotBaseDieA0ThenStoredInProperMemoryPool) {
auto hwInfo = *defaultHwInfo;
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
hwInfo.platform.usDeviceID = pvcXtDeviceIds.front();
hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); // not BD A0
checkIfSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInProperMemoryPool(&hwInfo);
}
PVCTEST_F(HwHelperTestsPvcXt, givenMultiTileCsrOnPvcWhenAllocatingCsrSpecificAllocationsAndIsNotBaseDieA0ThenStoredInLocalMemoryPool) {
auto hwInfo = *defaultHwInfo;
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
hwInfo.platform.usDeviceID = pvcXtDeviceIds.front();
hwInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(REVISION_B, hwInfo); // not BD A0
checkIfMultiTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInLocalMemoryPool(&hwInfo);
}
using HwHelperTestsPvc = Test<HwHelperTestsXeHpcCore>;
PVCTEST_F(HwHelperTestsPvc, givenRevisionEnumAndPlatformFamilyTypeThenProperValueForIsWorkaroundRequiredIsReturned) {
uint32_t steppings[] = {
REVISION_A0,
REVISION_B,
REVISION_C,
REVISION_D,
CommonConstants::invalidStepping,
};
const auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
const auto &hwInfoConfig = *HwInfoConfig::get(hardwareInfo.platform.eProductFamily);
for (auto stepping : steppings) {
hardwareInfo.platform.usRevId = hwInfoConfig.getHwRevIdFromStepping(stepping, hardwareInfo);
if (stepping == REVISION_A0) {
EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo));
EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo));
} else if (stepping == REVISION_B) {
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo));
EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo));
EXPECT_TRUE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo));
} else {
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_B, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_C, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_C, hardwareInfo));
}
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_A0, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_C, REVISION_A0, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_C, REVISION_B, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_D, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_D, REVISION_A0, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A0, REVISION_A1, hardwareInfo));
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_A1, REVISION_A0, hardwareInfo));
}
}
PVCTEST_F(HwHelperTestsPvc, givenDefaultMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) {
using MI_SEMAPHORE_WAIT = typename XeHpcCoreFamily::MI_SEMAPHORE_WAIT;
EXPECT_EQ(sizeof(MI_SEMAPHORE_WAIT), MemorySynchronizationCommands<XeHpcCoreFamily>::getSizeForAdditonalSynchronization(*defaultHwInfo));
}
PVCTEST_F(HwHelperTestsPvc, givenDebugMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) {
DebugManagerStateRestore restorer;
DebugManager.flags.DisablePipeControlPrecedingPostSyncCommand.set(1);
using MI_SEMAPHORE_WAIT = typename XeHpcCoreFamily::MI_SEMAPHORE_WAIT;
EXPECT_EQ(2 * sizeof(MI_SEMAPHORE_WAIT), MemorySynchronizationCommands<XeHpcCoreFamily>::getSizeForAdditonalSynchronization(*defaultHwInfo));
}
PVCTEST_F(HwHelperTestsPvc, givenRevisionIdWhenGetComputeUnitsUsedForScratchThenReturnValidValue) {
auto &coreHelper = pDevice->getRootDeviceEnvironment().getHelper<CoreHelper>();
auto &hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo();
hwInfo.gtSystemInfo.EUCount *= 2;
uint32_t expectedValue = hwInfo.gtSystemInfo.MaxSubSlicesSupported * hwInfo.gtSystemInfo.MaxEuPerSubSlice;
struct {
unsigned short revId;
uint32_t expectedRatio;
} testInputs[] = {
{0x0, 8},
{0x1, 8},
{0x3, 16},
{0x5, 16},
{0x6, 16},
{0x7, 16},
};
for (auto &testInput : testInputs) {
hwInfo.platform.usRevId = testInput.revId;
EXPECT_EQ(expectedValue * testInput.expectedRatio, coreHelper.getComputeUnitsUsedForScratch(pDevice->getRootDeviceEnvironment()));
}
}
PVCTEST_F(HwHelperTestsPvcXt, givenMemorySynchronizationCommandsWhenAddingSynchronizationThenCorrectMethodIsUsed) {
using MI_MEM_FENCE = typename FamilyType::MI_MEM_FENCE;
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
struct {
unsigned short revisionId;
int32_t programGlobalFenceAsMiMemFenceCommandInCommandStream;
bool expectMiSemaphoreWait;
} testInputs[] = {
{0x0, -1, true},
{0x3, -1, false},
{0x0, 0, true},
{0x3, 0, true},
{0x0, 1, false},
{0x3, 1, false},
};
DebugManagerStateRestore debugRestorer;
auto hardwareInfo = *defaultHwInfo;
hardwareInfo.featureTable.flags.ftrLocalMemory = true;
uint8_t buffer[128] = {};
uint64_t gpuAddress = 0x12345678;
for (auto &testInput : testInputs) {
hardwareInfo.platform.usRevId = testInput.revisionId;
DebugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(
testInput.programGlobalFenceAsMiMemFenceCommandInCommandStream);
LinearStream commandStream(buffer, 128);
auto synchronizationSize = MemorySynchronizationCommands<FamilyType>::getSizeForSingleAdditionalSynchronization(hardwareInfo);
MemorySynchronizationCommands<FamilyType>::addAdditionalSynchronization(commandStream, gpuAddress, false, hardwareInfo);
HardwareParse hwParser;
hwParser.parseCommands<FamilyType>(commandStream);
EXPECT_EQ(1u, hwParser.cmdList.size());
if (testInput.expectMiSemaphoreWait) {
EXPECT_EQ(sizeof(MI_SEMAPHORE_WAIT), synchronizationSize);
auto semaphoreCmd = genCmdCast<MI_SEMAPHORE_WAIT *>(*hwParser.cmdList.begin());
ASSERT_NE(nullptr, semaphoreCmd);
EXPECT_EQ(static_cast<uint32_t>(-2), semaphoreCmd->getSemaphoreDataDword());
EXPECT_EQ(gpuAddress, semaphoreCmd->getSemaphoreGraphicsAddress());
EXPECT_EQ(MI_SEMAPHORE_WAIT::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD, semaphoreCmd->getCompareOperation());
} else {
EXPECT_EQ(sizeof(MI_MEM_FENCE), synchronizationSize);
auto fenceCmd = genCmdCast<MI_MEM_FENCE *>(*hwParser.cmdList.begin());
ASSERT_NE(nullptr, fenceCmd);
EXPECT_EQ(MI_MEM_FENCE::FENCE_TYPE::FENCE_TYPE_RELEASE, fenceCmd->getFenceType());
}
}
}
} // namespace NEO

View File

@ -15,12 +15,12 @@
namespace NEO {
void HwHelperTestsXeHpcCore::setupDeviceIdAndRevision(HardwareInfo *hwInfo, ClDevice &clDevice) {
void ClHwHelperXeHpcCoreFixture::setupDeviceIdAndRevision(HardwareInfo *hwInfo, ClDevice &clDevice) {
auto deviceHwInfo = clDevice.getExecutionEnvironment()->rootDeviceEnvironments[0]->getMutableHardwareInfo();
deviceHwInfo->platform.usDeviceID = hwInfo->platform.usDeviceID;
deviceHwInfo->platform.usRevId = hwInfo->platform.usRevId;
}
void HwHelperTestsXeHpcCore::checkIfSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInProperMemoryPool(HardwareInfo *hwInfo) {
void ClHwHelperXeHpcCoreFixture::checkIfSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInProperMemoryPool(HardwareInfo *hwInfo) {
const uint32_t numDevices = 4u;
const uint32_t tileIndex = 2u;
const DeviceBitfield singleTileMask{static_cast<uint32_t>(1u << tileIndex)};
@ -48,7 +48,7 @@ void HwHelperTestsXeHpcCore::checkIfSingleTileCsrWhenAllocatingCsrSpecificAlloca
EXPECT_EQ(commandBufferAllocation->getMemoryPool(), MemoryPool::LocalMemory);
}
void HwHelperTestsXeHpcCore::checkIfMultiTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInLocalMemoryPool(HardwareInfo *hwInfo) {
void ClHwHelperXeHpcCoreFixture::checkIfMultiTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInLocalMemoryPool(HardwareInfo *hwInfo) {
const uint32_t numDevices = 4u;
const DeviceBitfield tile0Mask{0x1};
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;

View File

@ -13,7 +13,7 @@
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
namespace NEO {
struct HwHelperTestsXeHpcCore : public ClDeviceFixture {
struct ClHwHelperXeHpcCoreFixture : public ClDeviceFixture {
void checkIfSingleTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInProperMemoryPool(HardwareInfo *hwInfo);
void checkIfMultiTileCsrWhenAllocatingCsrSpecificAllocationsThenStoredInLocalMemoryPool(HardwareInfo *hwInfo);
void setupDeviceIdAndRevision(HardwareInfo *hwInfo, ClDevice &clDevice);