2019-09-18 19:32:33 +02:00
|
|
|
/*
|
2019-12-23 14:28:33 +01:00
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
2019-09-18 19:32:33 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-03-13 13:14:28 +01:00
|
|
|
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
|
|
|
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/gen12lp/special_ult_helper_gen12lp.h"
|
|
|
|
#include "opencl/test/unit_test/helpers/hw_helper_tests.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
2019-09-18 19:32:33 +02:00
|
|
|
|
|
|
|
#include "engine_node.h"
|
|
|
|
|
|
|
|
using HwHelperTestGen12Lp = HwHelperTest;
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenTglLpThenAuxTranslationIsRequired) {
|
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
EXPECT_TRUE(helper.requiresAuxResolves());
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, getMaxBarriersPerSliceReturnsCorrectSize) {
|
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
EXPECT_EQ(32u, helper.getMaxBarrierRegisterPerSlice());
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenGen12LpSkuWhenGettingCapabilityCoherencyFlagThenExpectValidValue) {
|
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
bool coherency = false;
|
|
|
|
helper.setCapabilityCoherencyFlag(&hardwareInfo, coherency);
|
|
|
|
|
2019-09-27 13:28:04 +02:00
|
|
|
const bool checkDone = SpecialUltHelperGen12lp::additionalCoherencyCheck(hardwareInfo.platform.eProductFamily, coherency);
|
|
|
|
if (checkDone) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-18 19:32:33 +02:00
|
|
|
if (hardwareInfo.platform.eProductFamily == IGFX_TIGERLAKE_LP) {
|
|
|
|
hardwareInfo.platform.usRevId = 0x1;
|
|
|
|
helper.setCapabilityCoherencyFlag(&hardwareInfo, coherency);
|
|
|
|
EXPECT_TRUE(coherency);
|
|
|
|
hardwareInfo.platform.usRevId = 0x0;
|
|
|
|
helper.setCapabilityCoherencyFlag(&hardwareInfo, coherency);
|
|
|
|
EXPECT_FALSE(coherency);
|
|
|
|
} else {
|
|
|
|
EXPECT_TRUE(coherency);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, getPitchAlignmentForImage) {
|
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
auto stepping = hardwareInfo.platform.usRevId;
|
|
|
|
|
2019-09-27 13:28:04 +02:00
|
|
|
if (SpecialUltHelperGen12lp::shouldPerformimagePitchAlignment(hardwareInfo.platform.eProductFamily) && stepping == 0) {
|
2019-09-18 19:32:33 +02:00
|
|
|
EXPECT_EQ(64u, helper.getPitchAlignmentForImage(&hardwareInfo));
|
|
|
|
} else {
|
|
|
|
EXPECT_EQ(4u, helper.getPitchAlignmentForImage(&hardwareInfo));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, adjustDefaultEngineTypeNoCcs) {
|
|
|
|
hardwareInfo.featureTable.ftrCCSNode = false;
|
|
|
|
|
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
helper.adjustDefaultEngineType(&hardwareInfo);
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, hardwareInfo.capabilityTable.defaultEngineType);
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenGen12LpPlatformWhenSetupHardwareCapabilitiesIsCalledThenDefaultImplementationIsUsed) {
|
2019-09-27 13:28:04 +02:00
|
|
|
if (SpecialUltHelperGen12lp::shouldTestDefaultImplementationOfSetupHardwareCapabilities(hardwareInfo.platform.eProductFamily)) {
|
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
testDefaultImplementationOfSetupHardwareCapabilities(helper, hardwareInfo);
|
|
|
|
}
|
2019-09-18 19:32:33 +02:00
|
|
|
}
|
|
|
|
|
2019-10-09 17:32:35 +02:00
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenCompressionFtrEnabledWhenAskingForPageTableManagerThenReturnCorrectValue) {
|
2019-09-18 19:32:33 +02:00
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
|
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedImages = false;
|
2020-01-10 11:22:54 +01:00
|
|
|
EXPECT_FALSE(helper.isPageTableManagerSupported(hardwareInfo));
|
2019-09-18 19:32:33 +02:00
|
|
|
|
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedImages = false;
|
2020-01-10 11:22:54 +01:00
|
|
|
EXPECT_TRUE(helper.isPageTableManagerSupported(hardwareInfo));
|
2019-09-18 19:32:33 +02:00
|
|
|
|
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedImages = true;
|
2020-01-10 11:22:54 +01:00
|
|
|
EXPECT_TRUE(helper.isPageTableManagerSupported(hardwareInfo));
|
2019-09-18 19:32:33 +02:00
|
|
|
|
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
|
|
|
hardwareInfo.capabilityTable.ftrRenderCompressedImages = true;
|
2020-01-10 11:22:54 +01:00
|
|
|
EXPECT_TRUE(helper.isPageTableManagerSupported(hardwareInfo));
|
2019-10-09 17:32:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenDifferentSizesOfAllocationWhenCheckingCompressionPreferenceThenReturnCorrectValue) {
|
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
|
|
|
|
const size_t sizesToCheck[] = {128, 256, 512, 1023, 1024, 1025};
|
|
|
|
for (size_t size : sizesToCheck) {
|
2020-01-10 11:22:54 +01:00
|
|
|
EXPECT_FALSE(helper.obtainRenderBufferCompressionPreference(hardwareInfo, size));
|
2019-10-09 17:32:35 +02:00
|
|
|
}
|
2019-09-18 19:32:33 +02:00
|
|
|
}
|
|
|
|
|
2020-02-21 15:25:04 +01:00
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenFtrCcsNodeNotSetWhenGetGpgpuEnginesThenReturnThreeRcsEngines) {
|
|
|
|
HardwareInfo hwInfo = *platformDevices[0];
|
|
|
|
hwInfo.featureTable.ftrCCSNode = false;
|
|
|
|
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS;
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
|
|
|
|
EXPECT_EQ(3u, device->engines.size());
|
|
|
|
auto &engines = HwHelperHw<FamilyType>::get().getGpgpuEngineInstances(hwInfo);
|
|
|
|
EXPECT_EQ(3u, engines.size());
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0]);
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[1]);
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenFtrCcsNodeSetWhenGetGpgpuEnginesThenReturnTwoRcsAndCcsEngines) {
|
|
|
|
HardwareInfo hwInfo = *platformDevices[0];
|
|
|
|
hwInfo.featureTable.ftrCCSNode = true;
|
|
|
|
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS;
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
|
|
|
|
EXPECT_EQ(4u, device->engines.size());
|
|
|
|
auto &engines = HwHelperHw<FamilyType>::get().getGpgpuEngineInstances(hwInfo);
|
|
|
|
EXPECT_EQ(4u, engines.size());
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0]);
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[1]);
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_CCS, engines[2]);
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_CCS, engines[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenFtrCcsNodeSetAndDefaultRcsWhenGetGpgpuEnginesThenReturnThreeRcsAndCcsEngines) {
|
|
|
|
HardwareInfo hwInfo = *platformDevices[0];
|
|
|
|
hwInfo.featureTable.ftrCCSNode = true;
|
|
|
|
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_RCS;
|
|
|
|
|
|
|
|
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, 0));
|
|
|
|
EXPECT_EQ(4u, device->engines.size());
|
|
|
|
auto &engines = HwHelperHw<FamilyType>::get().getGpgpuEngineInstances(hwInfo);
|
2020-01-21 09:35:12 +01:00
|
|
|
EXPECT_EQ(4u, engines.size());
|
2019-09-18 19:32:33 +02:00
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[0]);
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[1]);
|
2020-01-21 09:35:12 +01:00
|
|
|
EXPECT_EQ(aub_stream::ENGINE_RCS, engines[2]);
|
|
|
|
EXPECT_EQ(aub_stream::ENGINE_CCS, engines[3]);
|
2019-09-18 19:32:33 +02:00
|
|
|
}
|
|
|
|
|
2020-03-13 13:14:28 +01:00
|
|
|
GEN12LPTEST_F(HwHelperTestGen12Lp, givenTgllpWhenIsFusedEuDispatchEnabledIsCalledThenResultIsCorrect) {
|
|
|
|
DebugManagerStateRestore restorer;
|
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
auto &waTable = hardwareInfo.workaroundTable;
|
|
|
|
bool wa;
|
|
|
|
int32_t debugKey;
|
|
|
|
size_t expectedResult;
|
|
|
|
|
|
|
|
const std::array<std::tuple<bool, bool, int32_t>, 6> testParams{std::make_tuple(true, false, -1),
|
|
|
|
std::make_tuple(false, true, -1),
|
|
|
|
std::make_tuple(true, false, 0),
|
|
|
|
std::make_tuple(true, true, 0),
|
|
|
|
std::make_tuple(false, false, 1),
|
|
|
|
std::make_tuple(false, true, 1)};
|
|
|
|
|
|
|
|
for (const auto ¶ms : testParams) {
|
|
|
|
std::tie(expectedResult, wa, debugKey) = params;
|
|
|
|
waTable.waDisableFusedThreadScheduling = wa;
|
|
|
|
DebugManager.flags.CFEFusedEUDispatch.set(debugKey);
|
|
|
|
|
|
|
|
EXPECT_EQ(expectedResult, helper.isFusedEuDispatchEnabled(hardwareInfo));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-18 19:32:33 +02:00
|
|
|
class HwHelperTestsGen12LpBuffer : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
void SetUp() override {
|
2020-02-03 16:18:21 +01:00
|
|
|
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
|
2020-01-14 14:32:11 +01:00
|
|
|
device = std::make_unique<MockClDevice>(Device::create<MockDevice>(executionEnvironment, 0u));
|
2019-09-18 19:32:33 +02:00
|
|
|
context = std::make_unique<MockContext>(device.get(), true);
|
2019-10-16 10:59:10 +02:00
|
|
|
context->contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
|
2019-09-18 19:32:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cl_int retVal = CL_SUCCESS;
|
2020-01-14 14:32:11 +01:00
|
|
|
std::unique_ptr<MockClDevice> device;
|
2019-09-18 19:32:33 +02:00
|
|
|
std::unique_ptr<MockContext> context;
|
|
|
|
std::unique_ptr<Buffer> buffer;
|
|
|
|
};
|
|
|
|
|
2019-11-14 14:34:34 +01:00
|
|
|
GEN12LPTEST_F(HwHelperTestsGen12LpBuffer, givenCompressedBufferThenCheckResourceCompatibilityReturnsFalse) {
|
2019-09-18 19:32:33 +02:00
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
|
|
|
|
buffer.reset(Buffer::create(context.get(), 0, MemoryConstants::cacheLineSize, nullptr, retVal));
|
|
|
|
|
|
|
|
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
|
|
|
|
2019-11-14 14:34:34 +01:00
|
|
|
EXPECT_FALSE(helper.checkResourceCompatibility(*buffer->getGraphicsAllocation()));
|
2019-09-18 19:32:33 +02:00
|
|
|
}
|
|
|
|
|
2019-11-14 14:34:34 +01:00
|
|
|
GEN12LPTEST_F(HwHelperTestsGen12LpBuffer, givenBufferThenCheckResourceCompatibilityReturnsTrue) {
|
2019-09-18 19:32:33 +02:00
|
|
|
auto &helper = HwHelper::get(renderCoreFamily);
|
|
|
|
|
|
|
|
buffer.reset(Buffer::create(context.get(), 0, MemoryConstants::cacheLineSize, nullptr, retVal));
|
|
|
|
|
|
|
|
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
|
|
|
|
2019-11-14 14:34:34 +01:00
|
|
|
EXPECT_TRUE(helper.checkResourceCompatibility(*buffer->getGraphicsAllocation()));
|
2019-09-18 19:32:33 +02:00
|
|
|
}
|
2019-10-31 16:22:41 +01:00
|
|
|
|
|
|
|
using LriHelperTestsGen12Lp = ::testing::Test;
|
|
|
|
|
|
|
|
GEN12LPTEST_F(LriHelperTestsGen12Lp, whenProgrammingLriCommandThenExpectMmioRemapEnable) {
|
|
|
|
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
|
|
|
std::unique_ptr<uint8_t> buffer(new uint8_t[128]);
|
|
|
|
|
|
|
|
LinearStream stream(buffer.get(), 128);
|
|
|
|
uint32_t address = 0x8888;
|
|
|
|
uint32_t data = 0x1234;
|
|
|
|
|
|
|
|
auto expectedLri = FamilyType::cmdInitLoadRegisterImm;
|
|
|
|
expectedLri.setRegisterOffset(address);
|
|
|
|
expectedLri.setDataDword(data);
|
|
|
|
expectedLri.setMmioRemapEnable(true);
|
|
|
|
|
|
|
|
auto lri = LriHelper<FamilyType>::program(&stream, address, data);
|
|
|
|
|
|
|
|
EXPECT_EQ(sizeof(MI_LOAD_REGISTER_IMM), stream.getUsed());
|
|
|
|
EXPECT_EQ(lri, stream.getCpuBase());
|
|
|
|
EXPECT_TRUE(memcmp(lri, &expectedLri, sizeof(MI_LOAD_REGISTER_IMM)) == 0);
|
|
|
|
}
|
2020-02-10 11:02:21 +01:00
|
|
|
|
2020-02-19 14:45:06 +01:00
|
|
|
using MemorySynchronizatiopCommandsTests = ::testing::Test;
|
2020-02-10 11:02:21 +01:00
|
|
|
|
2020-02-19 14:45:06 +01:00
|
|
|
GEN12LPTEST_F(MemorySynchronizatiopCommandsTests, whenSettingCacheFlushExtraFieldsThenExpectHdcFlushSet) {
|
2020-02-10 11:02:21 +01:00
|
|
|
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
|
|
|
|
PIPE_CONTROL pipeControl = FamilyType::cmdInitPipeControl;
|
2020-03-19 15:08:02 +01:00
|
|
|
pipeControl.setConstantCacheInvalidationEnable(true);
|
2020-02-17 12:45:24 +01:00
|
|
|
MemorySynchronizationCommands<FamilyType>::setExtraCacheFlushFields(&pipeControl);
|
2020-02-10 11:02:21 +01:00
|
|
|
EXPECT_TRUE(pipeControl.getHdcPipelineFlush());
|
2020-03-19 15:08:02 +01:00
|
|
|
EXPECT_FALSE(pipeControl.getConstantCacheInvalidationEnable());
|
2020-02-10 11:02:21 +01:00
|
|
|
}
|