Add OCL xe_hp_core unit tests - part 2

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-08-10 14:35:03 +00:00
committed by Compute-Runtime-Automation
parent 14c93a6432
commit 23b72decc3
13 changed files with 2548 additions and 1 deletions

View File

@ -45,6 +45,16 @@ set(IGDRCL_SRCS_tests_helpers
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/unit_test_helper.inl
)
if(TESTS_XEHP_PLUS)
list(APPEND IGDRCL_SRCS_tests_helpers
${CMAKE_CURRENT_SOURCE_DIR}/aub_helper_hw_tests_xehp_plus.cpp
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests_xehp_plus.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_xehp_plus.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_preamble_xehp_plus.cpp
${NEO_SOURCE_DIR}/shared/test/common/helpers/unit_test_helper_xehp_plus.inl
)
endif()
get_property(NEO_CORE_PREAMBLE_TESTS GLOBAL PROPERTY NEO_CORE_PREAMBLE_TESTS)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_helpers})

View File

@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/aub/aub_helper.h"
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
#include "test.h"
#include "aub_mem_dump.h"
using namespace NEO;
using AubHelperHwTestXeHPPlus = Test<ClDeviceFixture>;
HWCMDTEST_F(IGFX_XE_HP_CORE, AubHelperHwTestXeHPPlus, givenAubHelperWhenGetDataHintForPml4EntryIsCalledThenTracePpgttLevel4IsReturned) {
AubHelperHw<FamilyType> aubHelper(true);
EXPECT_EQ(AubMemDump::DataTypeHintValues::TracePpgttLevel4, aubHelper.getDataHintForPml4Entry());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, AubHelperHwTestXeHPPlus, givenAubHelperWhenGetDataHintForPml4EntryIsCalledThenTracePpgttLevel3IsReturned) {
AubHelperHw<FamilyType> aubHelper(true);
EXPECT_EQ(AubMemDump::DataTypeHintValues::TracePpgttLevel3, aubHelper.getDataHintForPdpEntry());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, AubHelperHwTestXeHPPlus, givenAubHelperWhenGetDataHintForPml4EntryIsCalledThenTracePpgttLevel2IsReturned) {
AubHelperHw<FamilyType> aubHelper(true);
EXPECT_EQ(AubMemDump::DataTypeHintValues::TracePpgttLevel2, aubHelper.getDataHintForPdEntry());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, AubHelperHwTestXeHPPlus, givenAubHelperWhenGetDataHintForPml4EntryIsCalledThenTracePpgttLevel1IsReturned) {
AubHelperHw<FamilyType> aubHelper(true);
EXPECT_EQ(AubMemDump::DataTypeHintValues::TracePpgttLevel1, aubHelper.getDataHintForPtEntry());
}

View File

@ -0,0 +1,21 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/engine_node_helper.h"
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
#include "test.h"
using namespace NEO;
using EngineNodeHelperTestsXeHPPlus = ::Test<ClDeviceFixture>;
HWCMDTEST_F(IGFX_XE_HP_CORE, EngineNodeHelperTestsXeHPPlus, WhenGetBcsEngineTypeIsCalledThenBcsEngineIsReturned) {
const auto hwInfo = pDevice->getHardwareInfo();
auto &selectorCopyEngine = pDevice->getDeviceById(0)->getSelectorCopyEngine();
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, EngineHelpers::getBcsEngineType(hwInfo, selectorCopyEngine));
}

View File

@ -1301,3 +1301,91 @@ HWTEST_F(KernelCacheFlushTests, givenLocallyUncachedBufferWhenGettingAllocations
clReleaseMemObject(bufferLocallyUncached);
clReleaseMemObject(bufferRegular);
}
using HardwareCommandsTestXeHpPlus = HardwareCommandsTest;
HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsTestXeHpPlus, givenIndirectHeapNotAllocatedFromInternalPoolWhenSendCrossThreadDataIsCalledThenOffsetZeroIsReturned) {
auto nonInternalAllocation = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
IndirectHeap indirectHeap(nonInternalAllocation, false);
auto expectedOffset = is64bit ? 0u : indirectHeap.getHeapGpuBase();
auto sizeCrossThreadData = mockKernelWithInternal->mockKernel->getCrossThreadDataSize();
auto offset = HardwareCommandsHelper<FamilyType>::sendCrossThreadData(
indirectHeap,
*mockKernelWithInternal->mockKernel,
false,
nullptr,
sizeCrossThreadData);
EXPECT_EQ(expectedOffset, offset);
pDevice->getMemoryManager()->freeGraphicsMemory(nonInternalAllocation);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsTestXeHpPlus, givenIndirectHeapAllocatedFromInternalPoolWhenSendCrossThreadDataIsCalledThenHeapBaseOffsetIsReturned) {
auto internalAllocation = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties(pDevice->getRootDeviceIndex(), true, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::INTERNAL_HEAP, pDevice->getDeviceBitfield()));
IndirectHeap indirectHeap(internalAllocation, true);
auto expectedOffset = is64bit ? internalAllocation->getGpuAddressToPatch() : 0u;
auto sizeCrossThreadData = mockKernelWithInternal->mockKernel->getCrossThreadDataSize();
auto offset = HardwareCommandsHelper<FamilyType>::sendCrossThreadData(
indirectHeap,
*mockKernelWithInternal->mockKernel,
false,
nullptr,
sizeCrossThreadData);
EXPECT_EQ(expectedOffset, offset);
pDevice->getMemoryManager()->freeGraphicsMemory(internalAllocation);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsTestXeHpPlus, givenSendCrossThreadDataWhenWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoDataOffsetsAreMoved) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true);
CommandQueueHw<FamilyType> cmdQ(pContext, pClDevice, 0, false);
MockContext context;
MockProgram program(&context, false, toClDeviceVector(*pClDevice));
auto kernelInfo = std::make_unique<KernelInfo>();
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, *kernelInfo, *pClDevice));
auto &indirectHeap = cmdQ.getIndirectHeap(IndirectHeap::INDIRECT_OBJECT, 8192);
indirectHeap.getSpace(128u);
PatchInfoData patchInfoData1 = {0xaaaaaaaa, 0, PatchInfoAllocationType::KernelArg, 0xbbbbbbbb, 0, PatchInfoAllocationType::IndirectObjectHeap};
PatchInfoData patchInfoData2 = {0xcccccccc, 0, PatchInfoAllocationType::IndirectObjectHeap, 0xdddddddd, 0, PatchInfoAllocationType::Default};
kernel->getPatchInfoDataList().push_back(patchInfoData1);
kernel->getPatchInfoDataList().push_back(patchInfoData2);
auto sizeCrossThreadData = kernel->getCrossThreadDataSize();
auto offsetCrossThreadData = HardwareCommandsHelper<FamilyType>::sendCrossThreadData(
indirectHeap,
*kernel,
false,
nullptr,
sizeCrossThreadData);
auto expectedOffsetRelativeToIohBase = 128u;
auto iohBaseAddress = is64bit ? 0u : indirectHeap.getHeapGpuBase();
ASSERT_NE(0u, offsetCrossThreadData);
EXPECT_EQ(iohBaseAddress + expectedOffsetRelativeToIohBase, offsetCrossThreadData);
ASSERT_EQ(2u, kernel->getPatchInfoDataList().size());
EXPECT_EQ(0xaaaaaaaa, kernel->getPatchInfoDataList()[0].sourceAllocation);
EXPECT_EQ(0u, kernel->getPatchInfoDataList()[0].sourceAllocationOffset);
EXPECT_EQ(PatchInfoAllocationType::KernelArg, kernel->getPatchInfoDataList()[0].sourceType);
EXPECT_NE(0xbbbbbbbb, kernel->getPatchInfoDataList()[0].targetAllocation);
EXPECT_EQ(indirectHeap.getGraphicsAllocation()->getGpuAddress(), kernel->getPatchInfoDataList()[0].targetAllocation);
EXPECT_NE(0u, kernel->getPatchInfoDataList()[0].targetAllocationOffset);
EXPECT_EQ(expectedOffsetRelativeToIohBase, kernel->getPatchInfoDataList()[0].targetAllocationOffset);
EXPECT_EQ(PatchInfoAllocationType::IndirectObjectHeap, kernel->getPatchInfoDataList()[0].targetType);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HardwareCommandsTestXeHpPlus, whenGetSizeRequiredForCacheFlushIsCalledThenExceptionIsThrown) {
CommandQueueHw<FamilyType> cmdQ(pContext, pClDevice, 0, false);
EXPECT_ANY_THROW(HardwareCommandsHelper<FamilyType>::getSizeRequiredForCacheFlush(cmdQ, nullptr, 0));
}

View File

@ -0,0 +1,407 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/engine_node_helper.h"
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/ult_hw_helper.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "opencl/source/command_queue/gpgpu_walker.h"
#include "opencl/source/helpers/hardware_commands_helper.h"
#include "opencl/test/unit_test/helpers/hw_helper_tests.h"
#include "engine_node.h"
#include "pipe_control_args.h"
using HwHelperTestXeHPPlus = HwHelperTest;
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, WhenGettingMaxBarriersPerSliceThen32IsReturned) {
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_EQ(32u, helper.getMaxBarrierRegisterPerSlice());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, whenCapabilityCoherencyFlagSetTrueThenOverrideToFalse) {
auto &helper = HwHelper::get(renderCoreFamily);
bool coherency = true;
helper.setCapabilityCoherencyFlag(&hardwareInfo, coherency);
EXPECT_FALSE(coherency);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenHwHelperWhenGetGpuTimeStampInNSIsCalledThenOnlyLow32BitsFromTimeStampAreUsedAndCorrectValueIsReturned) {
auto &helper = HwHelper::get(renderCoreFamily);
auto timeStamp = 0x00ff'ffff'ffff;
auto frequency = 123456.0;
auto result = static_cast<uint64_t>((timeStamp & 0xffff'ffff) * frequency);
EXPECT_EQ(result, helper.getGpuTimeStampInNS(timeStamp, frequency));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, GivenNoCcsNodeThenDefaultEngineTypeIsRcs) {
hardwareInfo.featureTable.ftrCCSNode = false;
auto &helper = HwHelper::get(renderCoreFamily);
helper.adjustDefaultEngineType(&hardwareInfo);
auto expectedEngine = EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, hardwareInfo);
EXPECT_EQ(expectedEngine, hardwareInfo.capabilityTable.defaultEngineType);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, GiveCcsNodeThenDefaultEngineTypeIsCcs) {
hardwareInfo.featureTable.ftrCCSNode = true;
auto &helper = HwHelper::get(renderCoreFamily);
helper.adjustDefaultEngineType(&hardwareInfo);
EXPECT_EQ(aub_stream::ENGINE_CCS, hardwareInfo.capabilityTable.defaultEngineType);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenXeHPPlusPlatformWhenSetupHardwareCapabilitiesIsCalledThenThenSpecificImplementationIsUsed) {
hardwareInfo.featureTable.ftrLocalMemory = true;
HardwareCapabilities hwCaps = {0};
auto &helper = HwHelper::get(renderCoreFamily);
helper.setupHardwareCapabilities(&hwCaps, hardwareInfo);
EXPECT_EQ(16384u, hwCaps.image3DMaxHeight);
EXPECT_EQ(16384u, hwCaps.image3DMaxWidth);
EXPECT_TRUE(hwCaps.isStatelesToStatefullWithOffsetSupported);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenXeHPPlusPlatformWithLocalMemoryFeatureWhenIsLocalMemoryEnabledIsCalledThenTrueIsReturned) {
hardwareInfo.featureTable.ftrLocalMemory = true;
auto &helper = reinterpret_cast<HwHelperHw<FamilyType> &>(HwHelperHw<FamilyType>::get());
EXPECT_TRUE(helper.isLocalMemoryEnabled(hardwareInfo));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenXeHPPlusPlatformWithoutLocalMemoryFeatureWhenIsLocalMemoryEnabledIsCalledThenFalseIsReturned) {
hardwareInfo.featureTable.ftrLocalMemory = false;
auto &helper = reinterpret_cast<HwHelperHw<FamilyType> &>(HwHelperHw<FamilyType>::get());
EXPECT_FALSE(helper.isLocalMemoryEnabled(hardwareInfo));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenXeHPPlusPlatformWhenCheckingIfHvAlign4IsRequiredThenReturnFalse) {
auto &helper = HwHelperHw<FamilyType>::get();
EXPECT_FALSE(helper.hvAlign4Required());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenXeHPPlusPlatformWhenCheckTimestampPacketWriteThenReturnTrue) {
auto &hwHelper = HwHelperHw<FamilyType>::get();
EXPECT_TRUE(hwHelper.timestampPacketWriteSupported());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenAllFlagsSetWhenGetGpgpuEnginesThenReturnThreeRcsEnginesFourCcsEnginesAndOneBcsEngine) {
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.featureTable.ftrCCSNode = true;
hwInfo.featureTable.ftrBcsInfo = 1;
hwInfo.featureTable.ftrRcsNode = true;
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS;
hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
EXPECT_EQ(9u, device->engines.size());
auto &engines = HwHelperHw<FamilyType>::get().getGpgpuEngineInstances(hwInfo);
EXPECT_EQ(9u, engines.size());
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0].first);
EXPECT_EQ(hwInfo.capabilityTable.defaultEngineType, engines[1].first); // low priority
EXPECT_EQ(EngineUsage::LowPriority, engines[1].second);
EXPECT_EQ(hwInfo.capabilityTable.defaultEngineType, engines[2].first); // internal
EXPECT_EQ(EngineUsage::Internal, engines[2].second);
EXPECT_EQ(aub_stream::ENGINE_CCS, engines[3].first);
EXPECT_EQ(aub_stream::ENGINE_CCS1, engines[4].first);
EXPECT_EQ(aub_stream::ENGINE_CCS2, engines[5].first);
EXPECT_EQ(aub_stream::ENGINE_CCS3, engines[6].first);
EXPECT_EQ(aub_stream::ENGINE_BCS, engines[7].first);
EXPECT_EQ(aub_stream::ENGINE_BCS, engines[8].first);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenBcsDisabledWhenGetGpgpuEnginesThenReturnThreeRcsEnginesFourCcsEngines) {
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.featureTable.ftrCCSNode = true;
hwInfo.featureTable.ftrBcsInfo = 0;
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS;
hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
EXPECT_EQ(7u, device->engines.size());
auto &engines = HwHelperHw<FamilyType>::get().getGpgpuEngineInstances(hwInfo);
EXPECT_EQ(7u, engines.size());
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0].first);
EXPECT_EQ(hwInfo.capabilityTable.defaultEngineType, engines[1].first); // low priority
EXPECT_EQ(aub_stream::ENGINE_CCS, engines[2].first);
EXPECT_EQ(aub_stream::ENGINE_CCS, engines[3].first);
EXPECT_EQ(aub_stream::ENGINE_CCS1, engines[4].first);
EXPECT_EQ(aub_stream::ENGINE_CCS2, engines[5].first);
EXPECT_EQ(aub_stream::ENGINE_CCS3, engines[6].first);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenCcsDisabledWhenGetGpgpuEnginesThenReturnRcsAndOneBcsEngine) {
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.featureTable.ftrCCSNode = false;
hwInfo.featureTable.ftrBcsInfo = 1;
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS;
hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 0;
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
EXPECT_EQ(5u, device->engines.size());
auto &engines = HwHelperHw<FamilyType>::get().getGpgpuEngineInstances(hwInfo);
EXPECT_EQ(5u, engines.size());
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0].first);
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[1].first);
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[2].first);
EXPECT_EQ(aub_stream::ENGINE_BCS, engines[3].first);
EXPECT_EQ(aub_stream::ENGINE_BCS, engines[4].first);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenCcsDisabledAndNumberOfCcsEnabledWhenGetGpgpuEnginesThenReturnRcsAndOneBcsEngine) {
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.featureTable.ftrCCSNode = false;
hwInfo.featureTable.ftrBcsInfo = 1;
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS;
hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 4;
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
EXPECT_EQ(5u, device->engines.size());
auto &engines = HwHelperHw<FamilyType>::get().getGpgpuEngineInstances(hwInfo);
EXPECT_EQ(5u, engines.size());
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0].first);
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[1].first);
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[2].first);
EXPECT_EQ(aub_stream::ENGINE_BCS, engines[3].first);
EXPECT_EQ(aub_stream::ENGINE_BCS, engines[4].first);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenVariousCachesRequestProperMOCSIndexesAreBeingReturned) {
DebugManagerStateRestore restore;
auto &helper = HwHelper::get(renderCoreFamily);
auto gmmHelper = this->pDevice->getRootDeviceEnvironment().getGmmHelper();
auto expectedMocsForL3off = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) >> 1;
auto expectedMocsForL3on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1;
auto expectedMocsForL3andL1on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST) >> 1;
auto mocsIndex = helper.getMocsIndex(*gmmHelper, false, true);
EXPECT_EQ(expectedMocsForL3off, mocsIndex);
mocsIndex = helper.getMocsIndex(*gmmHelper, true, false);
EXPECT_EQ(expectedMocsForL3andL1on, mocsIndex);
mocsIndex = helper.getMocsIndex(*gmmHelper, true, true);
EXPECT_EQ(expectedMocsForL3andL1on, mocsIndex);
DebugManager.flags.ForceL1Caching.set(0u);
mocsIndex = helper.getMocsIndex(*gmmHelper, true, false);
EXPECT_EQ(expectedMocsForL3on, mocsIndex);
mocsIndex = helper.getMocsIndex(*gmmHelper, true, true);
expectedMocsForL3andL1on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST) >> 1;
EXPECT_EQ(expectedMocsForL3andL1on, mocsIndex);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenStoreRegMemCommandWhenAdjustingThenSetRemapEnabled) {
typename FamilyType::MI_STORE_REGISTER_MEM_CMD storeRegMem = {};
storeRegMem.setMmioRemapEnable(false);
GpgpuWalkerHelper<FamilyType>::adjustMiStoreRegMemMode(&storeRegMem);
EXPECT_TRUE(storeRegMem.getMmioRemapEnable());
}
using PipeControlHelperTestsXeHPPlus = ::testing::Test;
HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPPlus, WhenAddingPipeControlWAThenCorrectCommandsAreProgrammed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
uint8_t buffer[128];
uint64_t address = 0x1234567887654321;
HardwareInfo hardwareInfo = *defaultHwInfo;
bool requiresMemorySynchronization = (MemorySynchronizationCommands<FamilyType>::getSizeForAdditonalSynchronization(hardwareInfo) > 0) ? true : false;
for (auto ftrLocalMemory : ::testing::Bool()) {
LinearStream stream(buffer, 128);
hardwareInfo.featureTable.ftrLocalMemory = ftrLocalMemory;
MemorySynchronizationCommands<FamilyType>::addPipeControlWA(stream, address, hardwareInfo);
if (MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired(hardwareInfo) == false) {
EXPECT_EQ(0u, stream.getUsed());
continue;
}
GenCmdList cmdList;
FamilyType::PARSE::parseCommandBuffer(cmdList, stream.getCpuBase(), stream.getUsed());
EXPECT_EQ(requiresMemorySynchronization ? 2u : 1u, cmdList.size());
PIPE_CONTROL expectedPipeControl = FamilyType::cmdInitPipeControl;
expectedPipeControl.setCommandStreamerStallEnable(true);
expectedPipeControl.setHdcPipelineFlush(true);
auto it = cmdList.begin();
auto pPipeControl = genCmdCast<PIPE_CONTROL *>(*it);
ASSERT_NE(nullptr, pPipeControl);
EXPECT_TRUE(memcmp(&expectedPipeControl, pPipeControl, sizeof(PIPE_CONTROL)) == 0);
if (requiresMemorySynchronization) {
if (UnitTestHelper<FamilyType>::isAdditionalMiSemaphoreWaitRequired(hardwareInfo)) {
MI_SEMAPHORE_WAIT expectedMiSemaphoreWait;
EncodeSempahore<FamilyType>::programMiSemaphoreWait(&expectedMiSemaphoreWait, address,
EncodeSempahore<FamilyType>::invalidHardwareTag,
MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD,
false);
auto pMiSemaphoreWait = genCmdCast<MI_SEMAPHORE_WAIT *>(*(++it));
ASSERT_NE(nullptr, pMiSemaphoreWait);
EXPECT_TRUE(memcmp(&expectedMiSemaphoreWait, pMiSemaphoreWait, sizeof(MI_SEMAPHORE_WAIT)) == 0);
}
}
}
}
HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPPlus, WhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) {
HardwareInfo hardwareInfo = *defaultHwInfo;
EXPECT_EQ(0u, UltMemorySynchronizationCommands<FamilyType>::getSizeForAdditonalSynchronization(hardwareInfo));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPPlus, WhenSettingExtraPipeControlPropertiesThenCorrectValuesAreSet) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
for (auto ftrLocalMemory : ::testing::Bool()) {
HardwareInfo hardwareInfo = *defaultHwInfo;
hardwareInfo.featureTable.ftrLocalMemory = ftrLocalMemory;
PipeControlArgs args{};
MemorySynchronizationCommands<FamilyType>::setPostSyncExtraProperties(args, hardwareInfo);
if (ftrLocalMemory) {
EXPECT_TRUE(args.hdcPipelineFlush);
} else {
EXPECT_FALSE(args.hdcPipelineFlush);
}
}
}
HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPPlus, whenSettingCacheFlushExtraFieldsThenExpectHdcFlushSet) {
PipeControlArgs args;
MemorySynchronizationCommands<FamilyType>::setCacheFlushExtraProperties(args);
EXPECT_TRUE(args.hdcPipelineFlush);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPPlus, givenRequestedCacheFlushesWhenProgrammingPipeControlThenFlushHdc) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {};
LinearStream stream(buffer, sizeof(buffer));
PipeControlArgs args;
args.hdcPipelineFlush = true;
args.compressionControlSurfaceCcsFlush = true;
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
auto pipeControl = reinterpret_cast<PIPE_CONTROL *>(buffer);
EXPECT_TRUE(pipeControl->getHdcPipelineFlush());
EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPPlus, givenDebugVariableSetWhenProgrammingPipeControlThenFlushHdc) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
DebugManagerStateRestore restore;
DebugManager.flags.FlushAllCaches.set(true);
uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {};
LinearStream stream(buffer, sizeof(buffer));
PipeControlArgs args;
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
auto pipeControl = reinterpret_cast<PIPE_CONTROL *>(buffer);
EXPECT_TRUE(pipeControl->getHdcPipelineFlush());
EXPECT_TRUE(pipeControl->getCompressionControlSurfaceCcsFlush());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, PipeControlHelperTestsXeHPPlus, givenDebugDisableCacheFlushWhenProgrammingPipeControlWithCacheFlushThenExpectDebugOverrideFlushHdc) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
DebugManagerStateRestore restore;
DebugManager.flags.DoNotFlushCaches.set(true);
uint32_t buffer[sizeof(PIPE_CONTROL) * 2] = {};
LinearStream stream(buffer, sizeof(buffer));
PipeControlArgs args;
args.hdcPipelineFlush = true;
args.compressionControlSurfaceCcsFlush = true;
MemorySynchronizationCommands<FamilyType>::addPipeControl(stream, args);
auto pipeControl = reinterpret_cast<PIPE_CONTROL *>(buffer);
EXPECT_FALSE(pipeControl->getHdcPipelineFlush());
EXPECT_FALSE(pipeControl->getCompressionControlSurfaceCcsFlush());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenHwHelperXeCoreWhenGettingGlobalTimeStampBitsThen32IsReturned) {
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_EQ(helper.getGlobalTimeStampBits(), 32U);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenHwHelperWhenGettingPlanarYuvHeightThenHelperReturnsCorrectValue) {
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_EQ(helper.getPlanarYuvMaxHeight(), 16128u);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, WhenIsPipeControlWArequiredIsCalledThenCorrectValueIsReturned) {
auto hwInfo = pDevice->getHardwareInfo();
for (auto ftrLocalMemory : ::testing::Bool()) {
hwInfo.featureTable.ftrLocalMemory = ftrLocalMemory;
EXPECT_EQ(UnitTestHelper<FamilyType>::isPipeControlWArequired(hwInfo),
MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired(hwInfo));
}
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, whenGettingPreferenceForSmallKernelsThenCertainThresholdIsTested) {
DebugManagerStateRestore restorer;
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_TRUE(helper.preferSmallWorkgroupSizeForKernel(512u, this->pClDevice->getHardwareInfo()));
EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(10000u, this->pClDevice->getHardwareInfo()));
EXPECT_TRUE(helper.preferSmallWorkgroupSizeForKernel(2047u, this->pClDevice->getHardwareInfo()));
EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(2048u, this->pClDevice->getHardwareInfo()));
DebugManager.flags.OverrideKernelSizeLimitForSmallDispatch.set(1u);
EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(1u, this->pClDevice->getHardwareInfo()));
EXPECT_TRUE(helper.preferSmallWorkgroupSizeForKernel(0u, this->pClDevice->getHardwareInfo()));
DebugManager.flags.OverrideKernelSizeLimitForSmallDispatch.set(0u);
EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(1u, this->pClDevice->getHardwareInfo()));
EXPECT_FALSE(helper.preferSmallWorkgroupSizeForKernel(0u, this->pClDevice->getHardwareInfo()));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, HwHelperTestXeHPPlus, givenHwHelperWhenGettingBindlessSurfaceExtendedMessageDescriptorValueThenCorrectValueIsReturned) {
auto &hwHelper = HwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily);
auto value = hwHelper.getBindlessSurfaceExtendedMessageDescriptorValue(0x200);
typename FamilyType::DataPortBindlessSurfaceExtendedMessageDescriptor messageExtDescriptor = {};
messageExtDescriptor.setBindlessSurfaceOffset(0x200);
EXPECT_EQ(messageExtDescriptor.getBindlessSurfaceOffsetToPatch(), value);
EXPECT_EQ(0x200u, value);
}

View File

@ -0,0 +1,581 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/state_base_address.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/preamble/preamble_fixture.h"
#include "opencl/source/helpers/hardware_commands_helper.h"
#include "opencl/source/mem_obj/buffer.h"
#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h"
#include "opencl/test/unit_test/mocks/mock_kernel.h"
#include "reg_configs_common.h"
#include "test_traits_common.h"
using namespace NEO;
using ThreadArbitrationXeHPPlus = PreambleFixture;
HWCMDTEST_F(IGFX_XE_HP_CORE, ThreadArbitrationXeHPPlus, givenPolicyWhenThreadArbitrationProgrammedThenDoNothing) {
LinearStream &cs = linearStream;
PreambleHelper<FamilyType>::programThreadArbitration(&cs, ThreadArbitrationPolicy::RoundRobin);
EXPECT_EQ(0u, cs.getUsed());
EXPECT_EQ(0u, HwHelperHw<FamilyType>::get().getDefaultThreadArbitrationPolicy());
}
using ProgramPipelineXeHPPlus = PreambleFixture;
HWCMDTEST_F(IGFX_XE_HP_CORE, ProgramPipelineXeHPPlus, whenCleanStateInPreambleIsSetAndProgramPipelineSelectIsCalledThenExtraPipelineSelectAndTwoExtraPipeControlsAdded) {
typedef typename FamilyType::PIPELINE_SELECT PIPELINE_SELECT;
typedef typename FamilyType::PIPE_CONTROL PIPE_CONTROL;
DebugManagerStateRestore stateRestore;
DebugManager.flags.CleanStateInPreamble.set(true);
LinearStream &cs = linearStream;
PipelineSelectArgs pipelineArgs;
auto hwInfo = pDevice->getHardwareInfo();
PreambleHelper<FamilyType>::programPipelineSelect(&cs, pipelineArgs, hwInfo);
parseCommands<FamilyType>(cs, 0);
auto numPipeControl = getCommandsList<PIPE_CONTROL>().size();
EXPECT_EQ(2u, numPipeControl);
auto numPipelineSelect = getCommandsList<PIPELINE_SELECT>().size();
EXPECT_EQ(2u, numPipelineSelect);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, ProgramPipelineXeHPPlus, givenDebugVariableWhenProgramPipelineSelectIsCalledThenItHasProperFieldsSet) {
typedef typename FamilyType::PIPELINE_SELECT PIPELINE_SELECT;
DebugManagerStateRestore stateRestore;
DebugManager.flags.OverrideSystolicPipelineSelect.set(1);
LinearStream &cs = linearStream;
PipelineSelectArgs pipelineArgs;
auto hwInfo = pDevice->getHardwareInfo();
PreambleHelper<FamilyType>::programPipelineSelect(&cs, 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_TRUE(cmd->getSystolicModeEnable());
}
using PreemptionWatermarkXeHPPlus = PreambleFixture;
HWCMDTEST_F(IGFX_XE_HP_CORE, PreemptionWatermarkXeHPPlus, givenPreambleThenPreambleWorkAroundsIsNotProgrammed) {
PreambleHelper<FamilyType>::programGenSpecificPreambleWorkArounds(&linearStream, *defaultHwInfo);
parseCommands<FamilyType>(linearStream);
auto cmd = findMmioCmd<FamilyType>(cmdList.begin(), cmdList.end(), FfSliceCsChknReg2::address);
ASSERT_EQ(nullptr, cmd);
MockDevice mockDevice;
mockDevice.setDebuggerActive(false);
size_t expectedSize = PreemptionHelper::getRequiredPreambleSize<FamilyType>(mockDevice);
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
mockDevice.setDebuggerActive(true);
expectedSize += PreambleHelper<FamilyType>::getKernelDebuggingCommandsSize(mockDevice.isDebuggerActive());
EXPECT_EQ(expectedSize, PreambleHelper<FamilyType>::getAdditionalCommandsSize(mockDevice));
}
struct KernelCommandsXeHPPlus : public PreambleVfeState,
public ClDeviceFixture {
void SetUp() override {
PreambleVfeState::SetUp();
ClDeviceFixture::SetUp();
program = std::make_unique<MockProgram>(toClDeviceVector(*pClDevice));
}
void TearDown() override {
ClDeviceFixture::TearDown();
PreambleVfeState::TearDown();
}
std::unique_ptr<MockProgram> program;
KernelInfo kernelInfo;
};
HWCMDTEST_F(IGFX_XE_HP_CORE, KernelCommandsXeHPPlus, whenKernelSizeIsRequiredThenReturnZero) {
MockKernel kernel(program.get(), kernelInfo, *pClDevice);
size_t expectedSize = 0;
size_t actualSize = HardwareCommandsHelper<FamilyType>::getSizeRequiredCS();
EXPECT_EQ(expectedSize, actualSize);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, KernelCommandsXeHPPlus, whenPipeControlForWaIsRequiredThenReturnFalse) {
auto &hwInfo = pDevice->getHardwareInfo();
EXPECT_EQ(UnitTestHelper<FamilyType>::isPipeControlWArequired(hwInfo), MemorySynchronizationCommands<FamilyType>::isPipeControlWArequired(hwInfo));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, KernelCommandsXeHPPlus, whenMediaInterfaceDescriptorLoadIsRequiredThenDoNotProgramNonExistingCommand) {
size_t expectedSize = 0;
EXPECT_EQ(expectedSize, linearStream.getUsed());
HardwareCommandsHelper<FamilyType>::sendMediaInterfaceDescriptorLoad(linearStream, 0, 0);
EXPECT_EQ(expectedSize, linearStream.getUsed());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, KernelCommandsXeHPPlus, whenMediaStateFlushIsRequiredThenDoNotProgramNonExistingCommand) {
size_t expectedSize = 0;
EXPECT_EQ(expectedSize, linearStream.getUsed());
HardwareCommandsHelper<FamilyType>::sendMediaStateFlush(linearStream, 0);
EXPECT_EQ(expectedSize, linearStream.getUsed());
}
using PreambleCfeStateXeHPPlus = PreambleFixture;
HWCMDTEST_F(IGFX_XE_HP_CORE, PreambleCfeStateXeHPPlus, givenScratchEnabledWhenPreambleCfeStateIsProgrammedThenCheckMaxThreadsAddressFieldsAreProgrammed) {
using CFE_STATE = typename FamilyType::CFE_STATE;
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, AdditionalKernelExecInfo::NotApplicable, 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(expectedMaxThreads, cfeState->getMaximumNumberOfThreads());
uint64_t address = cfeState->getScratchSpaceBuffer();
EXPECT_EQ(expectedAddress, address);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, PreambleCfeStateXeHPPlus, 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 fusedEuDispach = cfeState->getFusedEuDispatch();
uint32_t overDispatchControl = static_cast<uint32_t>(cfeState->getOverDispatchControl());
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, AdditionalKernelExecInfo::NotApplicable, emptyProperties);
uint32_t maximumNumberOfThreads = cfeState->getMaximumNumberOfThreads();
EXPECT_EQ(numberOfWalkers, cfeState->getNumberOfWalkers());
EXPECT_EQ(fusedEuDispach, cfeState->getFusedEuDispatch());
EXPECT_NE(expectedMaxThreads, maximumNumberOfThreads);
EXPECT_EQ(overDispatchControl, static_cast<uint32_t>(cfeState->getOverDispatchControl()));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, PreambleCfeStateXeHPPlus, 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, AdditionalKernelExecInfo::NotApplicable, 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->getFusedEuDispatch());
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 XeHpCommandStreamReceiverFlushTaskTests = UltCommandStreamReceiverTest;
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, whenFlushingCommandStreamReceiverThenExpectStateBaseAddressEqualsIndirectObjectBaseAddress) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
if constexpr (is64bit) {
EXPECT_EQ(commandStreamReceiver.getMemoryManager()->getInternalHeapBaseAddress(commandStreamReceiver.rootDeviceIndex, ioh.getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
stateBaseAddress->getGeneralStateBaseAddress());
} else {
EXPECT_EQ(0u, stateBaseAddress->getGeneralStateBaseAddress());
}
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, whenFlushCalledThenStateBaseAddressHasAllCachesOn) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
auto gmmHelper = pDevice->getRootDeviceEnvironment().getGmmHelper();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto expectedMocsIndexForStateless = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST);
auto expectedMocsIndexForL1EnabledResource = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_INLINE_CONST_HDC);
auto expectedMocsIndexForHeap = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER);
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getSurfaceStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getDynamicStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getGeneralStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getInstructionMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getBindlessSurfaceStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getBindlessSamplerStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForStateless, stateBaseAddress->getStatelessDataPortAccessMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForL1EnabledResource, stateBaseAddress->getIndirectObjectMemoryObjectControlStateIndexToMocsTables());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, whenFlushCalledThenStateBaseAddressHasAllCachesOffWhenDebugFlagIsPresent) {
DebugManagerStateRestore restorer;
DebugManager.flags.DisableCachingForHeaps.set(1);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
auto gmmHelper = pDevice->getRootDeviceEnvironment().getGmmHelper();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto expectedMocsIndexForHeap = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED);
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getSurfaceStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getDynamicStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getGeneralStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getInstructionMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getBindlessSurfaceStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getBindlessSamplerStateMemoryObjectControlStateIndexToMocsTables());
EXPECT_EQ(expectedMocsIndexForHeap, stateBaseAddress->getIndirectObjectMemoryObjectControlStateIndexToMocsTables());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenL3ToL1DebugFlagWhenStatelessMocsIsProgrammedThenItHasL1CachingOn) {
DebugManagerStateRestore restore;
DebugManager.flags.ForceL1Caching.set(1u);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto expectedMocs = pDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST);
EXPECT_EQ(expectedMocs, stateBaseAddress->getStatelessDataPortAccessMemoryObjectControlState());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenForceL1CachingDebugFlagDisabledWhenStatelessMocsIsProgrammedThenItHasL3CachingOn) {
DebugManagerStateRestore restore;
DebugManager.flags.ForceL1Caching.set(0u);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto expectedMocs = pDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
EXPECT_EQ(expectedMocs, stateBaseAddress->getStatelessDataPortAccessMemoryObjectControlState());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, whenFlushingCommandStreamReceiverThenExpectBindlessBaseAddressEqualSurfaceStateBaseAddress) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto surfaceStateBaseAddress = ssh.getHeapGpuBase();
EXPECT_EQ(surfaceStateBaseAddress, stateBaseAddress->getBindlessSurfaceStateBaseAddress());
EXPECT_EQ(surfaceStateBaseAddress, stateBaseAddress->getSurfaceStateBaseAddress());
uint32_t bindlessSurfaceSize = static_cast<uint32_t>(ssh.getMaxAvailableSpace() / sizeof(RENDER_SURFACE_STATE)) - 1;
EXPECT_EQ(bindlessSurfaceSize, stateBaseAddress->getBindlessSurfaceStateSize());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, whenFlushingCommandStreamReceiverThenSetBindlessSamplerStateBaseAddressModifyEnable) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
EXPECT_TRUE(stateBaseAddress->getBindlessSamplerStateBaseAddressModifyEnable());
EXPECT_EQ(0u, stateBaseAddress->getBindlessSamplerStateMemoryObjectControlStateReserved());
EXPECT_EQ(0u, stateBaseAddress->getBindlessSamplerStateBaseAddress());
EXPECT_EQ(0u, stateBaseAddress->getBindlessSamplerStateBufferSize());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenMultEngineQueueFalseWhenFlushingCommandStreamReceiverThenSetPartialWriteFieldsTrue) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
EXPECT_TRUE(stateBaseAddress->getDisableSupportForMultiGpuAtomicsForStatelessAccesses());
EXPECT_TRUE(stateBaseAddress->getDisableSupportForMultiGpuPartialWritesForStatelessMessages());
}
struct MultiGpuGlobalAtomicsTest : public XeHpCommandStreamReceiverFlushTaskTests,
public ::testing::WithParamInterface<std::tuple<bool, bool, bool, bool>> {
};
HWCMDTEST_P(IGFX_XE_HP_CORE, MultiGpuGlobalAtomicsTest, givenFlushingCommandStreamReceiverThenDisableSupportForMultiGpuAtomicsForStatelessAccessesIsSetCorrectly) {
bool isMultiOsContextCapable, useGlobalAtomics, areMultipleSubDevicesInContext, enableMultiGpuAtomicsOptimization;
std::tie(isMultiOsContextCapable, useGlobalAtomics, areMultipleSubDevicesInContext, enableMultiGpuAtomicsOptimization) = GetParam();
DebugManagerStateRestore stateRestore;
DebugManager.flags.EnableMultiGpuAtomicsOptimization.set(enableMultiGpuAtomicsOptimization);
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.multiOsContextCapable = isMultiOsContextCapable;
flushTaskFlags.useGlobalAtomics = useGlobalAtomics;
flushTaskFlags.areMultipleSubDevicesInContext = areMultipleSubDevicesInContext;
flushTask(commandStreamReceiver, false, 0, false, false);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto enabled = isMultiOsContextCapable;
if (enableMultiGpuAtomicsOptimization) {
enabled = useGlobalAtomics && (enabled || areMultipleSubDevicesInContext);
}
EXPECT_EQ(!enabled, stateBaseAddress->getDisableSupportForMultiGpuAtomicsForStatelessAccesses());
}
INSTANTIATE_TEST_CASE_P(MultiGpuGlobalAtomics,
MultiGpuGlobalAtomicsTest,
::testing::Combine(
::testing::Bool(),
::testing::Bool(),
::testing::Bool(),
::testing::Bool()));
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenDebugKeysThatOverrideMultiGpuSettingWhenStateBaseAddressIsProgrammedThenValuesMatch) {
DebugManagerStateRestore restorer;
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
DebugManager.flags.ForceMultiGpuAtomics.set(0);
DebugManager.flags.ForceMultiGpuPartialWrites.set(0);
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
EXPECT_EQ(0u, stateBaseAddress->getDisableSupportForMultiGpuAtomicsForStatelessAccesses());
EXPECT_EQ(0u, stateBaseAddress->getDisableSupportForMultiGpuPartialWritesForStatelessMessages());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenMultEngineQueueTrueWhenFlushingCommandStreamReceiverThenSetPartialWriteFieldsFalse) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
commandStreamReceiver.multiOsContextCapable = true;
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
EXPECT_TRUE(stateBaseAddress->getDisableSupportForMultiGpuAtomicsForStatelessAccesses());
EXPECT_FALSE(stateBaseAddress->getDisableSupportForMultiGpuPartialWritesForStatelessMessages());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenDefaultIndirectHeapCachingSettingWhenFlushingCsrThenExpectL1CachingPolicySelected) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
int32_t defaultRegValue = DebugManager.flags.UseCachingPolicyForIndirectObjectHeap.get();
EXPECT_EQ(-1, defaultRegValue);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto actualMocs = stateBaseAddress->getIndirectObjectMemoryObjectControlStateIndexToMocsTables();
auto expectedMocs = pDevice->getRootDeviceEnvironment().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_INLINE_CONST_HDC);
EXPECT_EQ(expectedMocs, actualMocs);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenUncachedIndirectHeapCachingSettingWhenFlushingCsrThenExpectUncachedCachingPolicySelected) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
DebugManagerStateRestore dbgRestore;
DebugManager.flags.UseCachingPolicyForIndirectObjectHeap.set(0);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto actualMocs = stateBaseAddress->getIndirectObjectMemoryObjectControlStateIndexToMocsTables();
auto expectedMocs = pDevice->getRootDeviceEnvironment().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED);
EXPECT_EQ(expectedMocs, actualMocs);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenL3IndirectHeapCachingSettingWhenFlushingCsrThenExpectL3CachingPolicySelected) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
DebugManagerStateRestore dbgRestore;
DebugManager.flags.UseCachingPolicyForIndirectObjectHeap.set(1);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto actualMocs = stateBaseAddress->getIndirectObjectMemoryObjectControlStateIndexToMocsTables();
auto expectedMocs = pDevice->getRootDeviceEnvironment().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER);
EXPECT_EQ(expectedMocs, actualMocs);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHpCommandStreamReceiverFlushTaskTests, givenL1IndirectHeapCachingSettingWhenFlushingCsrThenExpectL1CachingPolicySelected) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
DebugManagerStateRestore dbgRestore;
DebugManager.flags.UseCachingPolicyForIndirectObjectHeap.set(2);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);
HardwareParse hwParserCsr;
hwParserCsr.parseCommands<FamilyType>(commandStreamReceiver.commandStream, 0);
hwParserCsr.findHardwareCommands<FamilyType>();
ASSERT_NE(nullptr, hwParserCsr.cmdStateBaseAddress);
auto stateBaseAddress = static_cast<STATE_BASE_ADDRESS *>(hwParserCsr.cmdStateBaseAddress);
auto actualMocs = stateBaseAddress->getIndirectObjectMemoryObjectControlStateIndexToMocsTables();
auto expectedMocs = pDevice->getRootDeviceEnvironment().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_INLINE_CONST_HDC);
EXPECT_EQ(expectedMocs, actualMocs);
}
using StateBaseAddressXeHPPlusTests = XeHpCommandStreamReceiverFlushTaskTests;
struct CompressionParamsSupportedMatcher {
template <PRODUCT_FAMILY productFamily>
static constexpr bool isMatched() {
if constexpr (HwMapper<productFamily>::GfxProduct::supportsCmdSet(IGFX_XE_HP_CORE)) {
return TestTraits<NEO::ToGfxCoreFamily<productFamily>::get()>::surfaceStateCompressionParamsSupported;
}
return false;
}
};
HWTEST2_F(StateBaseAddressXeHPPlusTests, givenMemoryCompressionEnabledWhenAppendingSbaThenEnableStatelessCompressionForAllStatelessAccesses, CompressionParamsSupportedMatcher) {
auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
AllocationProperties properties(pDevice->getRootDeviceIndex(), 1, GraphicsAllocation::AllocationType::BUFFER, pDevice->getDeviceBitfield());
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
IndirectHeap indirectHeap(allocation, 1);
for (auto memoryCompressionState : {MemoryCompressionState::NotApplicable, MemoryCompressionState::Disabled, MemoryCompressionState::Enabled}) {
auto sbaCmd = FamilyType::cmdInitStateBaseAddress;
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(&sbaCmd, &indirectHeap, true, 0,
pDevice->getRootDeviceEnvironment().getGmmHelper(), false, memoryCompressionState, true, false, 1u);
if (memoryCompressionState == MemoryCompressionState::Enabled) {
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::ENABLE_MEMORY_COMPRESSION_FOR_ALL_STATELESS_ACCESSES_ENABLED, sbaCmd.getEnableMemoryCompressionForAllStatelessAccesses());
} else {
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::ENABLE_MEMORY_COMPRESSION_FOR_ALL_STATELESS_ACCESSES_DISABLED, sbaCmd.getEnableMemoryCompressionForAllStatelessAccesses());
}
}
memoryManager->freeGraphicsMemory(allocation);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, StateBaseAddressXeHPPlusTests, givenNonZeroInternalHeapBaseAddressWhenSettingIsDisabledThenExpectCommandValueZero) {
auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
AllocationProperties properties(pDevice->getRootDeviceIndex(), 1, GraphicsAllocation::AllocationType::BUFFER, pDevice->getDeviceBitfield());
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
IndirectHeap indirectHeap(allocation, 1);
auto sbaCmd = FamilyType::cmdInitStateBaseAddress;
uint64_t ihba = 0x80010000ull;
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(&sbaCmd, &indirectHeap, false, ihba,
pDevice->getRootDeviceEnvironment().getGmmHelper(), false,
MemoryCompressionState::NotApplicable, true, false, 1u);
EXPECT_EQ(0ull, sbaCmd.getGeneralStateBaseAddress());
memoryManager->freeGraphicsMemory(allocation);
}
using RenderSurfaceStateXeHPPlusTests = XeHpCommandStreamReceiverFlushTaskTests;
HWCMDTEST_F(IGFX_XE_HP_CORE, RenderSurfaceStateXeHPPlusTests, givenSpecificProductFamilyWhenAppendingRssThenProgramGpuCoherency) {
auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get();
size_t allocationSize = MemoryConstants::pageSize;
AllocationProperties properties(pDevice->getRootDeviceIndex(), allocationSize, GraphicsAllocation::AllocationType::BUFFER, pDevice->getDeviceBitfield());
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
auto rssCmd = FamilyType::cmdInitRenderSurfaceState;
MockContext context(pClDevice);
auto multiGraphicsAllocation = MultiGraphicsAllocation(pClDevice->getRootDeviceIndex());
multiGraphicsAllocation.addAllocation(allocation);
std::unique_ptr<BufferHw<FamilyType>> buffer(static_cast<BufferHw<FamilyType> *>(
BufferHw<FamilyType>::create(&context, {}, 0, 0, allocationSize, nullptr, nullptr, multiGraphicsAllocation, false, false, false)));
EncodeSurfaceState<FamilyType>::encodeBuffer(&rssCmd, allocation->getGpuAddress(), allocation->getUnderlyingBufferSize(),
buffer->getMocsValue(false, false, pClDevice->getRootDeviceIndex()), false, false, false,
pClDevice->getNumAvailableDevices(), allocation, pClDevice->getGmmHelper(), false, 1u);
EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, rssCmd.getCoherencyType());
}

View File

@ -3222,3 +3222,39 @@ HWTEST_F(KernelLargeGrfTests, GivenLargeGrfWhenGettingMaxWorkGroupSizeThenCorrec
EXPECT_EQ(pDevice->getDeviceInfo().maxWorkGroupSize >> 1, kernel.maxKernelWorkGroupSize);
}
}
HWTEST2_F(KernelConstantSurfaceTest, givenKernelWithConstantSurfaceWhenKernelIsCreatedThenConstantMemorySurfaceStateIsPatchedWithMocs, IsAtLeastXeHpCore) {
auto pKernelInfo = std::make_unique<MockKernelInfo>();
pKernelInfo->kernelDescriptor.kernelAttributes.simdSize = 32;
pKernelInfo->setGlobalConstantsSurface(8, 0, 0);
char buffer[MemoryConstants::pageSize64k];
GraphicsAllocation gfxAlloc(0, GraphicsAllocation::AllocationType::CONSTANT_SURFACE, buffer,
MemoryConstants::pageSize64k, (osHandle)8, MemoryPool::MemoryNull, mockMaxOsContextCount);
MockContext context(pClDevice);
MockProgram program(&context, false, toClDeviceVector(*pClDevice));
program.setConstantSurface(&gfxAlloc);
// create kernel
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
// setup surface state heap
char surfaceStateHeap[0x80];
pKernelInfo->heapInfo.SurfaceStateHeapSize = sizeof(surfaceStateHeap);
pKernelInfo->heapInfo.pSsh = surfaceStateHeap;
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
auto surfaceState = reinterpret_cast<const RENDER_SURFACE_STATE *>(
ptrOffset(pKernel->getSurfaceStateHeap(),
pKernelInfo->kernelDescriptor.payloadMappings.implicitArgs.globalConstantsSurfaceAddress.bindful));
auto actualMocs = surfaceState->getMemoryObjectControlState();
const auto expectedMocs = context.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST);
EXPECT_EQ(expectedMocs, actualMocs);
program.setConstantSurface(nullptr);
}

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@ -11,6 +11,7 @@ set(IGDRCL_SRCS_tests_mem_obj
${CMAKE_CURRENT_SOURCE_DIR}/buffer_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/buffer_bcs_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/create_image_format_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/create_image_in_local_memory_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/destructor_callback_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_mem_object_info_subbuffer_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_mem_object_info_tests.cpp
@ -41,5 +42,13 @@ set(IGDRCL_SRCS_tests_mem_obj
${CMAKE_CURRENT_SOURCE_DIR}/sub_buffer_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/zero_copy_tests.cpp
)
if(TESTS_XEHP_PLUS)
list(APPEND IGDRCL_SRCS_tests_mem_obj
${CMAKE_CURRENT_SOURCE_DIR}/buffer_tests_xehp_plus.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image_tests_xehp_plus.cpp
)
endif()
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_mem_obj})
add_subdirectories()

View File

@ -0,0 +1,575 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_container/implicit_scaling.h"
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/device/sub_device.h"
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_device.h"
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/helpers/memory_properties_helpers.h"
#include "opencl/source/mem_obj/buffer.h"
#include "opencl/test/unit_test/mocks/mock_buffer.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_gmm.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "test.h"
#include <functional>
using namespace NEO;
typedef ::testing::Test XeHPPlusBufferTests;
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenContextTypeDefaultWhenBufferIsWritableAndOnlyOneTileIsAvailableThenRemainFlagsToTrue) {
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleSubDevices.set(1);
initPlatform();
EXPECT_EQ(1u, platform()->getClDevice(0)->getNumAvailableDevices());
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context(platform()->getClDevice(0));
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(
Buffer::create(
&context,
CL_MEM_READ_WRITE,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
surfaceState.setDisableSupportForMultiGpuPartialWrites(false);
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenDebugFlagSetWhenProgramingSurfaceStateThenForceCompressionFormat) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
DebugManagerStateRestore restorer;
uint32_t compressionFormat = 3;
MockContext context;
auto gmmContext = context.getDevice(0)->getGmmHelper()->getClientContext();
uint32_t defaultCompressionFormat = gmmContext->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT);
auto retVal = CL_SUCCESS;
auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false);
gmm->isCompressionEnabled = true;
auto buffer = std::unique_ptr<Buffer>(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal));
buffer->getGraphicsAllocation(0)->setGmm(gmm, 0);
buffer->getGraphicsAllocation(0)->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
{
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_EQ(defaultCompressionFormat, surfaceState.getCompressionFormat());
}
{
DebugManager.flags.ForceBufferCompressionFormat.set(compressionFormat);
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_EQ(compressionFormat, surfaceState.getCompressionFormat());
}
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenContextTypeDefaultWhenBufferIsWritableThenFlipPartialFlagsToFalse) {
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleSubDevices.set(4);
initPlatform();
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context(platform()->getClDevice(0));
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(
Buffer::create(
&context,
CL_MEM_READ_WRITE,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), true, true);
EXPECT_FALSE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_FALSE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenContextTypeUnrestrictiveWhenBufferIsWritableThenFlipPartialFlagsToFalse) {
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleSubDevices.set(4);
initPlatform();
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context(platform()->getClDevice(0));
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(
Buffer::create(
&context,
CL_MEM_READ_WRITE,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), true, true);
EXPECT_FALSE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_FALSE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenContextTypeDefaultWhenBufferIsNotWritableThenRemainPartialFlagsToTrue) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context;
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(Buffer::create(
&context,
CL_MEM_READ_ONLY,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
surfaceState.setDisableSupportForMultiGpuPartialWrites(false);
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), true, false);
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenContextTypeSpecializedWhenBufferIsWritableThenRemainPartialFlagsToTrue) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context;
context.contextType = ContextType::CONTEXT_TYPE_SPECIALIZED;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(Buffer::create(
&context,
CL_MEM_READ_WRITE,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
surfaceState.setDisableSupportForMultiGpuPartialWrites(false);
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenDebugFlagForMultiTileSupportWhenSurfaceStateIsSetThenValuesMatch) {
DebugManagerStateRestore restore;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context;
context.contextType = ContextType::CONTEXT_TYPE_SPECIALIZED;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(Buffer::create(
&context,
CL_MEM_READ_WRITE,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
DebugManager.flags.ForceMultiGpuAtomics.set(0);
DebugManager.flags.ForceMultiGpuPartialWrites.set(0);
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_EQ(0u, surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_EQ(0u, surfaceState.getDisableSupportForMultiGpuPartialWrites());
DebugManager.flags.ForceMultiGpuAtomics.set(1);
DebugManager.flags.ForceMultiGpuPartialWrites.set(1);
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_EQ(1u, surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_EQ(1u, surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenNullContextWhenBufferAllocationIsNullThenRemainPartialFlagsToTrue) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
auto size = MemoryConstants::pageSize;
auto ptr = alignedMalloc(size, MemoryConstants::pageSize);
surfaceState.setDisableSupportForMultiGpuAtomics(false);
surfaceState.setDisableSupportForMultiGpuPartialWrites(false);
Buffer::setSurfaceState(device.get(), &surfaceState, false, false, size, ptr, 0, nullptr, 0, 0, false, false);
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
alignedFree(ptr);
}
struct MultiGpuGlobalAtomicsBufferTest : public XeHPPlusBufferTests,
public ::testing::WithParamInterface<std::tuple<unsigned int, unsigned int, bool, bool, bool>> {
};
HWCMDTEST_P(IGFX_XE_HP_CORE, MultiGpuGlobalAtomicsBufferTest, givenSetArgStatefulCalledThenDisableSupportForMultiGpuAtomicsIsSetCorrectly) {
unsigned int numAvailableDevices, bufferFlags;
bool useGlobalAtomics, areMultipleSubDevicesInContext, enableMultiGpuAtomicsOptimization;
std::tie(numAvailableDevices, bufferFlags, useGlobalAtomics, areMultipleSubDevicesInContext, enableMultiGpuAtomicsOptimization) = GetParam();
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleSubDevices.set(numAvailableDevices);
DebugManager.flags.EnableMultiGpuAtomicsOptimization.set(enableMultiGpuAtomicsOptimization);
initPlatform();
EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumAvailableDevices());
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context(platform()->getClDevice(0));
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(
Buffer::create(
&context,
bufferFlags,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), useGlobalAtomics, areMultipleSubDevicesInContext);
DeviceBitfield deviceBitfield{static_cast<uint32_t>(maxNBitValue(numAvailableDevices))};
bool implicitScaling = ImplicitScalingHelper::isImplicitScalingEnabled(deviceBitfield, true);
bool enabled = implicitScaling;
if (enableMultiGpuAtomicsOptimization) {
enabled = useGlobalAtomics && (enabled || areMultipleSubDevicesInContext);
}
EXPECT_EQ(!enabled, surfaceState.getDisableSupportForMultiGpuAtomics());
}
HWCMDTEST_P(IGFX_XE_HP_CORE, MultiGpuGlobalAtomicsBufferTest, givenSetSurfaceStateCalledThenDisableSupportForMultiGpuAtomicsIsSetCorrectly) {
unsigned int numAvailableDevices, bufferFlags;
bool useGlobalAtomics, areMultipleSubDevicesInContext, enableMultiGpuAtomicsOptimization;
std::tie(numAvailableDevices, bufferFlags, useGlobalAtomics, areMultipleSubDevicesInContext, enableMultiGpuAtomicsOptimization) = GetParam();
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleSubDevices.set(numAvailableDevices);
DebugManager.flags.EnableMultiGpuAtomicsOptimization.set(enableMultiGpuAtomicsOptimization);
initPlatform();
EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumAvailableDevices());
auto size = MemoryConstants::pageSize;
auto ptr = alignedMalloc(size, MemoryConstants::pageSize);
MockGraphicsAllocation gfxAllocation(ptr, size);
gfxAllocation.setMemObjectsAllocationWithWritableFlags(bufferFlags == CL_MEM_READ_WRITE);
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
Buffer::setSurfaceState(&platform()->getClDevice(0)->getDevice(), &surfaceState, false, false, 0, nullptr, 0, &gfxAllocation, bufferFlags, 0, useGlobalAtomics, areMultipleSubDevicesInContext);
DeviceBitfield deviceBitfield{static_cast<uint32_t>(maxNBitValue(numAvailableDevices))};
bool implicitScaling = ImplicitScalingHelper::isImplicitScalingEnabled(deviceBitfield, true);
bool enabled = implicitScaling;
if (enableMultiGpuAtomicsOptimization) {
enabled = useGlobalAtomics && (enabled || areMultipleSubDevicesInContext);
}
EXPECT_EQ(!enabled, surfaceState.getDisableSupportForMultiGpuAtomics());
alignedFree(ptr);
}
static unsigned int numAvailableDevices[] = {1, 2};
static unsigned int bufferFlags[] = {CL_MEM_READ_ONLY, CL_MEM_READ_WRITE};
INSTANTIATE_TEST_CASE_P(MultiGpuGlobalAtomicsBufferTest,
MultiGpuGlobalAtomicsBufferTest,
::testing::Combine(
::testing::ValuesIn(numAvailableDevices),
::testing::ValuesIn(bufferFlags),
::testing::Bool(),
::testing::Bool(),
::testing::Bool()));
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenBufferAllocationInDeviceMemoryWhenStatelessCompressionIsEnabledThenSetSurfaceStateWithCompressionSettings) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableLocalMemory.set(1);
DebugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1);
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
MockContext context;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(
Buffer::create(
&context,
CL_MEM_READ_WRITE,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
auto allocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
auto gmm = new MockGmm();
gmm->isCompressionEnabled = true;
allocation->setDefaultGmm(gmm);
EXPECT_TRUE(!MemoryPool::isSystemMemoryPool(allocation->getMemoryPool()));
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, surfaceState.getCoherencyType());
EXPECT_TRUE(EncodeSurfaceState<FamilyType>::isAuxModeEnabled(&surfaceState, allocation->getDefaultGmm()));
EXPECT_EQ(static_cast<uint32_t>(DebugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()), surfaceState.getCompressionFormat());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenBufferAllocationInHostMemoryWhenStatelessCompressionIsEnabledThenDontSetSurfaceStateWithCompressionSettings) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1);
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
MockContext context;
size_t size = 0x1000;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(
Buffer::create(
&context,
CL_MEM_READ_WRITE,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(MemoryPool::isSystemMemoryPool(buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getMemoryPool()));
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, surfaceState.getCoherencyType());
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, surfaceState.getAuxiliarySurfaceMode());
EXPECT_EQ(0u, surfaceState.getCompressionFormat());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenBufferAllocationWithoutGraphicsAllocationWhenStatelessCompressionIsEnabledThenDontSetSurfaceStateWithCompressionSettings) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1);
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
MockContext context;
cl_float srcMemory[] = {1.0f, 2.0f, 3.0f, 4.0f};
std::unique_ptr<Buffer> buffer(Buffer::createBufferHw(
&context,
MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context.getDevice(0)->getDevice()),
0,
0,
sizeof(srcMemory),
srcMemory,
srcMemory,
0,
false,
false,
false));
ASSERT_NE(nullptr, buffer);
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
EXPECT_EQ(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT, surfaceState.getCoherencyType());
EXPECT_EQ(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE, surfaceState.getAuxiliarySurfaceMode());
EXPECT_EQ(0u, surfaceState.getCompressionFormat());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenDebugVariableForcingL1CachingWhenBufferSurfaceStateIsSetThenItIsCachedInL1) {
DebugManagerStateRestore restorer;
DebugManager.flags.ForceL1Caching.set(1u);
MockContext context;
const auto size = MemoryConstants::pageSize;
const auto flags = CL_MEM_READ_WRITE;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(Buffer::create(
&context,
flags,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
const auto expectedMocs = context.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST);
const auto actualMocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(expectedMocs, actualMocs);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenDebugVariableForcingL1CachingDisabledWhenBufferSurfaceStateIsSetThenItIsCachedInL3) {
DebugManagerStateRestore restorer;
DebugManager.flags.ForceL1Caching.set(0u);
MockContext context;
const auto size = MemoryConstants::pageSize;
const auto flags = CL_MEM_READ_WRITE;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(Buffer::create(
&context,
flags,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
const auto expectedMocs = context.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
const auto actualMocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(expectedMocs, actualMocs);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenBufferWhenArgumentIsConstAndAuxModeIsOnThenL3DisabledPolicyIsChoosen) {
MockContext context;
const auto size = MemoryConstants::pageSize;
const auto flags = CL_MEM_READ_ONLY;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(Buffer::create(
&context,
flags,
size,
nullptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
buffer->setArgStateful(&surfaceState, true, true, false, false, context.getDevice(0)->getDevice(), false, false);
const auto expectedMocs = context.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED);
const auto actualMocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(expectedMocs, actualMocs);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenBufferSetSurfaceThatMemoryPtrAndSizeIsAlignedToCachelineThenL1CacheShouldBeOn) {
MockContext context;
auto size = MemoryConstants::pageSize;
auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize);
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
RENDER_SURFACE_STATE surfaceState = {};
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
Buffer::setSurfaceState(device.get(), &surfaceState, false, false, size, ptr, 0, nullptr, 0, 0, false, false);
auto mocs = surfaceState.getMemoryObjectControlState();
auto gmmHelper = device.get()->getGmmHelper();
EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST), mocs);
alignedFree(ptr);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusBufferTests, givenAlignedCacheableNonReadOnlyBufferThenChooseOclBufferPolicy) {
MockContext context;
const auto size = MemoryConstants::pageSize;
const auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize);
const auto flags = CL_MEM_USE_HOST_PTR;
auto retVal = CL_SUCCESS;
auto buffer = std::unique_ptr<Buffer>(Buffer::create(
&context,
flags,
size,
ptr,
retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false);
const auto expectedMocs = context.getDevice(0)->getDevice().getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST);
const auto actualMocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(expectedMocs, actualMocs);
alignedFree(ptr);
}

View File

@ -0,0 +1,91 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/memory_manager/memory_pool.h"
#include "shared/test/common/mocks/mock_device.h"
#include "opencl/source/helpers/memory_properties_helpers.h"
#include "opencl/source/mem_obj/image.h"
#include "opencl/source/platform/platform.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "test.h"
using namespace NEO;
class ImageInLocalMemoryTest : public testing::Test {
public:
ImageInLocalMemoryTest() = default;
protected:
void SetUp() override {
HardwareInfo inputPlatformDevice = *defaultHwInfo;
inputPlatformDevice.featureTable.ftrLocalMemory = true;
platformsImpl->clear();
auto executionEnvironment = constructPlatform()->peekExecutionEnvironment();
executionEnvironment->prepareRootDeviceEnvironments(1u);
executionEnvironment->rootDeviceEnvironments[0]->setHwInfo(&inputPlatformDevice);
executionEnvironment->rootDeviceEnvironments[0]->initGmm();
gmockMemoryManager = new ::testing::NiceMock<GMockMemoryManagerFailFirstAllocation>(true, *executionEnvironment);
executionEnvironment->memoryManager.reset(gmockMemoryManager);
ON_CALL(*gmockMemoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
.WillByDefault(::testing::Invoke(gmockMemoryManager, &GMockMemoryManagerFailFirstAllocation::baseAllocateGraphicsMemoryInDevicePool));
device = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
context = std::make_unique<MockContext>(device.get());
imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D;
imageDesc.image_width = 1;
imageDesc.image_height = 1;
imageDesc.image_row_pitch = sizeof(memory);
imageFormat.image_channel_data_type = CL_UNSIGNED_INT8;
imageFormat.image_channel_order = CL_R;
}
void TearDown() override {}
::testing::NiceMock<GMockMemoryManagerFailFirstAllocation> *gmockMemoryManager = nullptr;
cl_image_desc imageDesc{};
cl_image_format imageFormat = {};
std::unique_ptr<MockClDevice> device;
std::unique_ptr<MockContext> context;
char memory[10];
};
TEST_F(ImageInLocalMemoryTest, givenImageWithoutHostPtrWhenLocalMemoryIsEnabledThenImageAllocationIsInLocalMemoryAndGpuAddressIsInStandard64KHeap) {
cl_int retVal = 0;
cl_mem_flags flags = CL_MEM_READ_WRITE;
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
EXPECT_CALL(*gmockMemoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
.WillRepeatedly(::testing::Invoke(gmockMemoryManager, &GMockMemoryManagerFailFirstAllocation::baseAllocateGraphicsMemoryInDevicePool));
std::unique_ptr<Image> image(Image::create(
context.get(), MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
flags, 0, surfaceFormat, &imageDesc, memory, retVal));
ASSERT_NE(nullptr, image);
auto imgGfxAlloc = image->getGraphicsAllocation(device->getRootDeviceIndex());
ASSERT_NE(nullptr, imgGfxAlloc);
EXPECT_EQ(MemoryPool::LocalMemory, imgGfxAlloc->getMemoryPool());
EXPECT_LE(imageDesc.image_width * surfaceFormat->surfaceFormat.ImageElementSizeInBytes, imgGfxAlloc->getUnderlyingBufferSize());
EXPECT_EQ(GraphicsAllocation::AllocationType::IMAGE, imgGfxAlloc->getAllocationType());
EXPECT_FALSE(imgGfxAlloc->getDefaultGmm()->useSystemMemoryPool);
EXPECT_LT(GmmHelper::canonize(gmockMemoryManager->getGfxPartition(imgGfxAlloc->getRootDeviceIndex())->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), imgGfxAlloc->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(gmockMemoryManager->getGfxPartition(imgGfxAlloc->getRootDeviceIndex())->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), imgGfxAlloc->getGpuAddress());
EXPECT_EQ(0llu, imgGfxAlloc->getGpuBaseAddress());
}

View File

@ -0,0 +1,661 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "opencl/test/unit_test/fixtures/image_fixture.h"
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_gmm.h"
#include "opencl/test/unit_test/mocks/mock_platform.h"
#include "test.h"
#include "mock_gmm_client_context.h"
#include "test_traits_common.h"
#include <functional>
using namespace NEO;
using XeHPPlusImageTests = ::testing::Test;
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenContextTypeDefaultWhenImageIsWritableAndOnlyOneTileIsAvailableThenRemainFlagsToTrue) {
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleSubDevices.set(1);
initPlatform();
EXPECT_EQ(1u, platform()->getClDevice(0)->getNumAvailableDevices());
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context(platform()->getClDevice(0));
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
auto surfaceFormat = Image::getSurfaceFormatFromTable(
CL_MEM_READ_WRITE, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
&context, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()),
CL_MEM_READ_WRITE, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
surfaceState.setDisableSupportForMultiGpuPartialWrites(false);
imageHw->appendSurfaceStateParams(&surfaceState, context.getDevice(0)->getRootDeviceIndex(), true);
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenContextTypeDefaultWhenImageIsWritableThenFlipPartialFlagsToFalse) {
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleSubDevices.set(4);
initPlatform();
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context(platform()->getClDevice(0));
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
auto surfaceFormat = Image::getSurfaceFormatFromTable(
CL_MEM_READ_WRITE, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
&context, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()),
CL_MEM_READ_WRITE, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
imageHw->appendSurfaceStateParams(&surfaceState, context.getDevice(0)->getRootDeviceIndex(), true);
EXPECT_FALSE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_FALSE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenDebugFlagForMultiTileSupportWhenSurfaceStateIsProgrammedThenItHasDesiredValues) {
DebugManagerStateRestore restorer;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context;
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
auto surfaceFormat = Image::getSurfaceFormatFromTable(
CL_MEM_READ_ONLY, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
&context, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()),
CL_MEM_READ_WRITE, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
DebugManager.flags.ForceMultiGpuAtomics.set(0);
DebugManager.flags.ForceMultiGpuPartialWrites.set(0);
imageHw->appendSurfaceStateParams(&surfaceState, context.getDevice(0)->getRootDeviceIndex(), true);
EXPECT_EQ(0u, surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_EQ(0u, surfaceState.getDisableSupportForMultiGpuPartialWrites());
DebugManager.flags.ForceMultiGpuAtomics.set(1);
DebugManager.flags.ForceMultiGpuPartialWrites.set(1);
imageHw->appendSurfaceStateParams(&surfaceState, context.getDevice(0)->getRootDeviceIndex(), true);
EXPECT_EQ(1u, surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_EQ(1u, surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenContextTypeUnrestrictiveWhenImageIsWritableThenFlipPartialFlagsToFalse) {
DebugManagerStateRestore restorer;
DebugManager.flags.CreateMultipleSubDevices.set(4);
initPlatform();
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context(platform()->getClDevice(0));
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
auto surfaceFormat = Image::getSurfaceFormatFromTable(
CL_MEM_READ_WRITE, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
&context, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()),
CL_MEM_READ_WRITE, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
imageHw->appendSurfaceStateParams(&surfaceState, context.getDevice(0)->getRootDeviceIndex(), true);
EXPECT_FALSE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_FALSE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenContextTypeDefaultWhenImageIsNotWritableThenRemainPartialFlagsToTrue) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context;
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
auto surfaceFormat = Image::getSurfaceFormatFromTable(
CL_MEM_READ_ONLY, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
&context, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()),
CL_MEM_READ_WRITE, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
surfaceState.setDisableSupportForMultiGpuPartialWrites(false);
imageHw->appendSurfaceStateParams(&surfaceState, context.getDevice(0)->getRootDeviceIndex(), true);
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenContextTypeSpecializedWhenImageIsWritableThenRemainPartialFlagsToTrue) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context;
context.contextType = ContextType::CONTEXT_TYPE_SPECIALIZED;
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
auto surfaceFormat = Image::getSurfaceFormatFromTable(
CL_MEM_READ_WRITE, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
&context, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()),
CL_MEM_READ_WRITE, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
surfaceState.setDisableSupportForMultiGpuPartialWrites(false);
imageHw->appendSurfaceStateParams(&surfaceState, context.getDevice(0)->getRootDeviceIndex(), true);
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuPartialWrites());
}
struct MultiGpuGlobalAtomicsImageTest : public XeHPPlusImageTests,
public ::testing::WithParamInterface<std::tuple<unsigned int, unsigned int, ContextType, bool, bool>> {
};
HWCMDTEST_P(IGFX_XE_HP_CORE, MultiGpuGlobalAtomicsImageTest, givenAppendSurfaceStateParamCalledThenDisableSupportForMultiGpuAtomicsIsSetCorrectly) {
unsigned int numAvailableDevices, memFlags;
ContextType contextType;
bool useGlobalAtomics, enableMultiGpuAtomicsOptimization;
std::tie(numAvailableDevices, memFlags, contextType, useGlobalAtomics, enableMultiGpuAtomicsOptimization) = GetParam();
DebugManagerStateRestore restorer;
DebugManager.flags.EnableMultiGpuAtomicsOptimization.set(enableMultiGpuAtomicsOptimization);
DebugManager.flags.CreateMultipleSubDevices.set(numAvailableDevices);
initPlatform();
EXPECT_EQ(numAvailableDevices, platform()->getClDevice(0)->getNumAvailableDevices());
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
MockContext context(platform()->getClDevice(0));
context.contextType = contextType;
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
auto surfaceFormat = Image::getSurfaceFormatFromTable(
memFlags, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
&context, MemoryPropertiesHelper::createMemoryProperties(memFlags, 0, 0, &context.getDevice(0)->getDevice()),
memFlags, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
RENDER_SURFACE_STATE surfaceState = FamilyType::cmdInitRenderSurfaceState;
EXPECT_TRUE(surfaceState.getDisableSupportForMultiGpuAtomics());
surfaceState.setDisableSupportForMultiGpuAtomics(false);
surfaceState.setDisableSupportForMultiGpuPartialWrites(false);
imageHw->appendSurfaceStateParams(&surfaceState, context.getDevice(0)->getRootDeviceIndex(), useGlobalAtomics);
bool enableGlobalAtomics = (contextType != ContextType::CONTEXT_TYPE_SPECIALIZED) && (numAvailableDevices > 1);
if (enableMultiGpuAtomicsOptimization) {
enableGlobalAtomics &= useGlobalAtomics;
}
EXPECT_EQ(!enableGlobalAtomics, surfaceState.getDisableSupportForMultiGpuAtomics());
}
static unsigned int numAvailableDevices[] = {1, 2};
static unsigned int memFlags[] = {CL_MEM_READ_ONLY, CL_MEM_READ_WRITE};
static ContextType contextTypes[] = {ContextType::CONTEXT_TYPE_DEFAULT, ContextType::CONTEXT_TYPE_SPECIALIZED, ContextType::CONTEXT_TYPE_UNRESTRICTIVE};
INSTANTIATE_TEST_CASE_P(MultiGpuGlobalAtomicsImageTest,
MultiGpuGlobalAtomicsImageTest,
::testing::Combine(
::testing::ValuesIn(numAvailableDevices),
::testing::ValuesIn(memFlags),
::testing::ValuesIn(contextTypes),
::testing::Bool(),
::testing::Bool()));
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, WhenAppendingSurfaceStateParamsThenDoNothing) {
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
MockContext context;
auto image = std::unique_ptr<Image>(ImageHelper<Image1dDefaults>::create(&context));
auto surfaceStateBefore = FamilyType::cmdInitRenderSurfaceState;
auto surfaceStateAfter = FamilyType::cmdInitRenderSurfaceState;
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
EXPECT_EQ(0, memcmp(&surfaceStateBefore, &surfaceStateAfter, sizeof(RENDER_SURFACE_STATE)));
imageHw->appendSurfaceStateParams(&surfaceStateAfter, context.getDevice(0)->getRootDeviceIndex(), true);
EXPECT_EQ(0, memcmp(&surfaceStateBefore, &surfaceStateAfter, sizeof(RENDER_SURFACE_STATE)));
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenCompressionEnabledWhenAppendingSurfaceStateParamsThenProgramCompressionFormat) {
MockContext context;
auto mockGmmClient = static_cast<MockGmmClientContext *>(context.getDevice(0)->getRootDeviceEnvironment().getGmmClientContext());
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
auto image = std::unique_ptr<Image>(ImageHelper<Image2dDefaults>::create(&context));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
mockGmmClient->capturedFormat = GMM_FORMAT_INVALID;
auto surfaceState = FamilyType::cmdInitRenderSurfaceState;
surfaceState.setAuxiliarySurfaceMode(RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
imageHw->setImageArg(&surfaceState, false, 0, context.getDevice(0)->getRootDeviceIndex(), false);
EXPECT_EQ(0u, surfaceState.getCompressionFormat());
EXPECT_EQ(GMM_FORMAT_INVALID, mockGmmClient->capturedFormat);
auto gmm = image->getMultiGraphicsAllocation().getDefaultGraphicsAllocation()->getDefaultGmm();
gmm->isCompressionEnabled = true;
surfaceState = FamilyType::cmdInitRenderSurfaceState;
imageHw->setImageArg(&surfaceState, false, 0, context.getDevice(0)->getRootDeviceIndex(), false);
EXPECT_TRUE(EncodeSurfaceState<FamilyType>::isAuxModeEnabled(&surfaceState, gmm));
EXPECT_NE(0u, surfaceState.getCompressionFormat());
EXPECT_EQ(image->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()->gmmResourceInfo->getResourceFormat(), mockGmmClient->capturedFormat);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenCompressionWhenAppendingImageFromBufferThenTwoIsSetAsCompressionFormat) {
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
MockContext context;
uint32_t compressionFormat = context.getDevice(0)->getGmmHelper()->getClientContext()->getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT::GMM_FORMAT_GENERIC_8BIT);
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
imageDesc.mem_object = clCreateBuffer(&context, CL_MEM_READ_WRITE, 128 * 256 * 4, nullptr, &retVal);
auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false);
gmm->isCompressionEnabled = true;
auto buffer = castToObject<Buffer>(imageDesc.mem_object);
buffer->getGraphicsAllocation(0)->setGmm(gmm, 0);
buffer->getGraphicsAllocation(0)->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
auto surfaceFormat = Image::getSurfaceFormatFromTable(
CL_MEM_READ_WRITE, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(
&context, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()),
CL_MEM_READ_WRITE, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
auto surfaceState = FamilyType::cmdInitRenderSurfaceState;
imageHw->setImageArg(&surfaceState, false, 0, context.getDevice(0)->getRootDeviceIndex(), false);
EXPECT_TRUE(EncodeSurfaceState<FamilyType>::isAuxModeEnabled(&surfaceState, gmm));
EXPECT_EQ(compressionFormat, surfaceState.getCompressionFormat());
clReleaseMemObject(imageDesc.mem_object);
}
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusImageTests, givenImageFromBufferWhenSettingSurfaceStateThenPickCompressionFormatFromDebugVariable) {
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
DebugManagerStateRestore restorer;
uint32_t bufferCompressionFormat = 3;
DebugManager.flags.ForceBufferCompressionFormat.set(bufferCompressionFormat);
MockContext context;
cl_int retVal = CL_SUCCESS;
cl_image_format imageFormat = {};
cl_image_desc imageDesc = {};
imageFormat.image_channel_data_type = CL_UNORM_INT8;
imageFormat.image_channel_order = CL_RGBA;
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_height = 128;
imageDesc.image_width = 256;
imageDesc.mem_object = clCreateBuffer(&context, CL_MEM_READ_WRITE, 128 * 256 * 4, nullptr, &retVal);
auto gmm = new Gmm(context.getDevice(0)->getGmmHelper()->getClientContext(), nullptr, 1, 0, false);
gmm->isCompressionEnabled = true;
auto buffer = castToObject<Buffer>(imageDesc.mem_object);
buffer->getGraphicsAllocation(0)->setGmm(gmm, 0);
buffer->getGraphicsAllocation(0)->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
auto surfaceFormat = Image::getSurfaceFormatFromTable(CL_MEM_READ_WRITE, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = std::unique_ptr<Image>(Image::create(&context, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_READ_WRITE, 0, 0, &context.getDevice(0)->getDevice()),
CL_MEM_READ_WRITE, 0, surfaceFormat, &imageDesc, NULL, retVal));
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
auto surfaceState = FamilyType::cmdInitRenderSurfaceState;
imageHw->setImageArg(&surfaceState, false, 0, context.getDevice(0)->getRootDeviceIndex(), false);
EXPECT_TRUE(EncodeSurfaceState<FamilyType>::isAuxModeEnabled(&surfaceState, gmm));
EXPECT_EQ(bufferCompressionFormat, surfaceState.getCompressionFormat());
clReleaseMemObject(imageDesc.mem_object);
}
struct CompressionParamsSupportedMatcher {
template <PRODUCT_FAMILY productFamily>
static constexpr bool isMatched() {
if constexpr (HwMapper<productFamily>::GfxProduct::supportsCmdSet(IGFX_XE_HP_CORE)) {
return TestTraits<NEO::ToGfxCoreFamily<productFamily>::get()>::surfaceStateCompressionParamsSupported;
}
return false;
}
};
HWTEST2_F(XeHPPlusImageTests, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapabilityAndMCSThenProgramAuxFieldsForCcs, CompressionParamsSupportedMatcher) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE;
MockContext context;
McsSurfaceInfo msi = {10, 20, 3};
auto mcsAlloc = context.getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{context.getDevice(0)->getRootDeviceIndex(), MemoryConstants::pageSize});
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
imgDesc.num_samples = 8;
std::unique_ptr<Image> image(Image2dHelper<>::create(&context, &imgDesc));
auto surfaceState = FamilyType::cmdInitRenderSurfaceState;
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
mcsAlloc->setDefaultGmm(new Gmm(context.getDevice(0)->getRootDeviceEnvironment().getGmmClientContext(), nullptr, 1, 0, false));
surfaceState.setSurfaceBaseAddress(0xABCDEF1000);
imageHw->setMcsSurfaceInfo(msi);
imageHw->setMcsAllocation(mcsAlloc);
auto mockResource = static_cast<MockGmmResourceInfo *>(mcsAlloc->getDefaultGmm()->gmmResourceInfo.get());
mockResource->setUnifiedAuxTranslationCapable();
mockResource->setMultisampleControlSurface();
EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress());
imageHw->setAuxParamsForMultisamples(&surfaceState);
EXPECT_NE(0u, surfaceState.getAuxiliarySurfaceBaseAddress());
EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_MCS_LCE);
}
HWTEST2_F(ImageClearColorFixture, givenImageForXeHPPlusWhenClearColorParametersAreSetThenClearColorSurfaceInSurfaceStateIsSet, CompressionParamsSupportedMatcher) {
this->setUpImpl<FamilyType>();
auto surfaceState = this->getSurfaceState<FamilyType>();
surfaceState.setSurfaceBaseAddress(0xABCDEF1000);
EXPECT_EQ(false, surfaceState.getClearValueAddressEnable());
EXPECT_EQ(0u, surfaceState.getClearColorAddress());
EXPECT_EQ(0u, surfaceState.getClearColorAddressHigh());
std::unique_ptr<ImageHw<FamilyType>> imageHw(static_cast<ImageHw<FamilyType> *>(ImageHelper<Image2dDefaults>::create(&context)));
auto gmm = imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm();
gmm->gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = 1;
EncodeSurfaceState<FamilyType>::setClearColorParams(&surfaceState, gmm);
EXPECT_EQ(true, surfaceState.getClearValueAddressEnable());
EXPECT_NE(0u, surfaceState.getClearColorAddress());
EXPECT_NE(0u, surfaceState.getClearColorAddressHigh());
}
struct CompressionClearColorAddressMatcher {
template <PRODUCT_FAMILY productFamily>
static constexpr bool isMatched() {
if constexpr (HwMapper<productFamily>::GfxProduct::supportsCmdSet(IGFX_XE_HP_CORE)) {
return TestTraits<NEO::ToGfxCoreFamily<productFamily>::get()>::clearColorAddressMatcher;
}
return false;
}
};
HWTEST2_F(ImageClearColorFixture, givenImageForXeHPPlusWhenCanonicalAddresForClearColorIsUsedThenItsConvertedToNonCanonicalForm, CompressionClearColorAddressMatcher) {
this->setUpImpl<FamilyType>();
auto surfaceState = this->getSurfaceState<FamilyType>();
uint64_t canonicalAddress = 0xffffABCDABCDE000;
EXPECT_THROW(surfaceState.setClearColorAddressHigh(static_cast<uint32_t>(canonicalAddress >> 32)), std::exception);
surfaceState.setSurfaceBaseAddress(canonicalAddress);
std::unique_ptr<ImageHw<FamilyType>> imageHw(static_cast<ImageHw<FamilyType> *>(ImageHelper<Image2dDefaults>::create(&context)));
auto gmm = imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm();
gmm->gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = 1;
EXPECT_NO_THROW(EncodeSurfaceState<FamilyType>::setClearColorParams(&surfaceState, gmm));
uint64_t nonCanonicalAddress = ((static_cast<uint64_t>(surfaceState.getClearColorAddressHigh()) << 32) | surfaceState.getClearColorAddress());
EXPECT_EQ(GmmHelper::decanonize(canonicalAddress), nonCanonicalAddress);
}
HWTEST2_F(XeHPPlusImageTests, givenMediaCompressionWhenAppendingNewAllocationThenNotZeroIsSetAsCompressionType, CompressionParamsSupportedMatcher) {
MockContext context;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
auto hwInfo = defaultHwInfo.get();
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
imgDesc.num_samples = 8;
std::unique_ptr<Image> image(Image2dHelper<>::create(&context, &imgDesc));
auto surfaceState = FamilyType::cmdInitRenderSurfaceState;
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true;
surfaceState.setAuxiliarySurfaceMode(RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
EncodeSurfaceState<FamilyType>::setImageAuxParamsForCCS(&surfaceState, imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm());
imageHw->setImageArg(&surfaceState, false, 0, context.getDevice(0)->getRootDeviceIndex(), false);
if (hwInfo->featureTable.ftrFlatPhysCCS) {
EXPECT_NE(surfaceState.getCompressionFormat(), GMM_FLATCCS_FORMAT::GMM_FLATCCS_FORMAT_INVALID);
} else {
EXPECT_NE(surfaceState.getCompressionFormat(), GMM_E2ECOMP_FORMAT::GMM_E2ECOMP_FORMAT_INVALID);
}
EXPECT_TRUE(surfaceState.getMemoryCompressionEnable());
EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
}
HWTEST2_F(XeHPPlusImageTests, givenRenderCompressionWhenAppendingNewAllocationThenNotZeroIsSetAsCompressionType, CompressionParamsSupportedMatcher) {
MockContext context;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
auto hwInfo = defaultHwInfo.get();
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
imgDesc.num_samples = 8;
std::unique_ptr<Image> image(Image2dHelper<>::create(&context, &imgDesc));
auto surfaceState = FamilyType::cmdInitRenderSurfaceState;
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
surfaceState.setAuxiliarySurfaceMode(RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
auto gmm = imageHw->getGraphicsAllocation(rootDeviceIndex)->getDefaultGmm();
gmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = true;
gmm->isCompressionEnabled = true;
auto mcsGmm = new MockGmm();
mcsGmm->isCompressionEnabled = true;
mcsGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = true;
mcsGmm->gmmResourceInfo->getResourceFlags()->Gpu.UnifiedAuxSurface = true;
mcsGmm->gmmResourceInfo->getResourceFlags()->Gpu.CCS = true;
auto mcsAlloc = context.getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, 1});
mcsAlloc->setDefaultGmm(mcsGmm);
imageHw->setMcsAllocation(mcsAlloc);
imageHw->setImageArg(&surfaceState, false, 0, rootDeviceIndex, false);
if (hwInfo->featureTable.ftrFlatPhysCCS) {
EXPECT_NE(surfaceState.getCompressionFormat(), GMM_FLATCCS_FORMAT::GMM_FLATCCS_FORMAT_INVALID);
} else {
EXPECT_NE(surfaceState.getCompressionFormat(), GMM_E2ECOMP_FORMAT::GMM_E2ECOMP_FORMAT_INVALID);
}
EXPECT_FALSE(surfaceState.getMemoryCompressionEnable());
EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
}
HWTEST2_F(XeHPPlusImageTests, givenNoCompressionWhenProgramingImageSurfaceStateThenCompressionIsDisabled, CompressionParamsSupportedMatcher) {
MockContext context;
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
std::unique_ptr<Image> image(Image2dHelper<>::create(&context, &imgDesc));
auto surfaceState = FamilyType::cmdInitRenderSurfaceState;
surfaceState.setMemoryCompressionEnable(true);
surfaceState.setAuxiliarySurfaceMode(RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
auto imageHw = static_cast<ImageHw<FamilyType> *>(image.get());
imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()->isCompressionEnabled = false;
imageHw->setImageArg(&surfaceState, false, 0, 0, false);
EXPECT_FALSE(surfaceState.getMemoryCompressionEnable());
EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE);
}
struct XeHPPlusImageHelperTests : ::testing::Test {
void SetUp() override {
context = std::make_unique<MockContext>();
image.reset(ImageHelper<Image2dDefaults>::create(context.get()));
mockGmmResourceInfo = static_cast<MockGmmResourceInfo *>(image->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex())->getDefaultGmm()->gmmResourceInfo.get());
gmmClientContext = static_cast<MockGmmClientContext *>(context->getDevice(0)->getGmmHelper()->getClientContext());
}
std::unique_ptr<MockContext> context;
std::unique_ptr<Image> image;
MockGmmResourceInfo *mockGmmResourceInfo;
MockGmmClientContext *gmmClientContext;
uint8_t mockCompressionFormat = 3u;
};
HWTEST2_F(XeHPPlusImageHelperTests, givenMediaCompressedImageWhenAppendingSurfaceStateParamsForCompressionThenCallAppriopriateFunction, CompressionParamsSupportedMatcher) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
RENDER_SURFACE_STATE rss{};
platformsImpl->clear();
rss.setMemoryCompressionEnable(true);
mockGmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true;
gmmClientContext->compressionFormatToReturn = mockCompressionFormat;
const auto expectedGetSurfaceStateCompressionFormatCalled = gmmClientContext->getSurfaceStateCompressionFormatCalled;
const auto expectedGetMediaSurfaceStateCompressionFormatCalled = gmmClientContext->getMediaSurfaceStateCompressionFormatCalled + 1;
EncodeSurfaceState<FamilyType>::appendImageCompressionParams(&rss, image->getMultiGraphicsAllocation().getDefaultGraphicsAllocation(),
context->getDevice(0)->getGmmHelper(), false);
EXPECT_EQ(platform(), nullptr);
EXPECT_EQ(mockCompressionFormat, rss.getCompressionFormat());
EXPECT_EQ(expectedGetSurfaceStateCompressionFormatCalled, gmmClientContext->getSurfaceStateCompressionFormatCalled);
EXPECT_EQ(expectedGetMediaSurfaceStateCompressionFormatCalled, gmmClientContext->getMediaSurfaceStateCompressionFormatCalled);
}
HWTEST2_F(XeHPPlusImageHelperTests, givenNotMediaCompressedImageWhenAppendingSurfaceStateParamsForCompressionThenCallAppriopriateFunction, CompressionParamsSupportedMatcher) {
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
RENDER_SURFACE_STATE rss{};
platformsImpl->clear();
rss.setMemoryCompressionEnable(true);
mockGmmResourceInfo->getResourceFlags()->Info.MediaCompressed = false;
gmmClientContext->compressionFormatToReturn = mockCompressionFormat;
const auto expectedGetSurfaceStateCompressionFormatCalled = gmmClientContext->getSurfaceStateCompressionFormatCalled + 1;
const auto expectedGetMediaSurfaceStateCompressionFormatCalled = gmmClientContext->getMediaSurfaceStateCompressionFormatCalled;
EncodeSurfaceState<FamilyType>::appendImageCompressionParams(&rss, image->getMultiGraphicsAllocation().getDefaultGraphicsAllocation(),
context->getDevice(0)->getGmmHelper(), false);
EXPECT_EQ(platform(), nullptr);
EXPECT_EQ(mockCompressionFormat, rss.getCompressionFormat());
EXPECT_EQ(expectedGetSurfaceStateCompressionFormatCalled, gmmClientContext->getSurfaceStateCompressionFormatCalled);
EXPECT_EQ(expectedGetMediaSurfaceStateCompressionFormatCalled, gmmClientContext->getMediaSurfaceStateCompressionFormatCalled);
}

View File

@ -10,5 +10,12 @@ set(IGDRCL_SRCS_tests_sampler
${CMAKE_CURRENT_SOURCE_DIR}/sampler_set_arg_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sampler_tests.cpp
)
if(TESTS_XEHP_PLUS)
list(APPEND IGDRCL_SRCS_tests_sampler
${CMAKE_CURRENT_SOURCE_DIR}/sampler_tests_xehp_plus.cpp
)
endif()
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_sampler})
add_subdirectories()

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/utilities/base_object_utils.h"
#include "opencl/source/sampler/sampler.h"
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "test.h"
#include <memory>
using namespace NEO;
using XeHPPlusSamplerTest = Test<ClDeviceFixture>;
HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPPlusSamplerTest, GivenDefaultThenLowQualityFilterIsDisabled) {
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
auto state = FamilyType::cmdInitSamplerState;
EXPECT_EQ(SAMPLER_STATE::LOW_QUALITY_FILTER_DISABLE, state.getLowQualityFilter());
}