2021-05-18 02:46:21 +00:00
|
|
|
/*
|
2025-07-29 19:21:18 +00:00
|
|
|
* Copyright (C) 2021-2025 Intel Corporation
|
2021-05-18 02:46:21 +00:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "shared/source/command_container/command_encoder.h"
|
2022-01-12 16:57:42 +00:00
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
2021-05-18 02:46:21 +00:00
|
|
|
#include "shared/source/command_stream/stream_properties.h"
|
2022-06-24 11:02:41 +00:00
|
|
|
#include "shared/source/gen12lp/hw_cmds.h"
|
2021-07-06 13:29:10 +00:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2023-01-05 16:57:56 +00:00
|
|
|
#include "shared/test/common/mocks/mock_execution_environment.h"
|
2022-06-29 19:17:47 +00:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2021-05-18 02:46:21 +00:00
|
|
|
using namespace NEO;
|
|
|
|
|
|
|
|
|
|
using CommandEncodeGen12LpTest = ::testing::Test;
|
|
|
|
|
|
|
|
|
|
GEN12LPTEST_F(CommandEncodeGen12LpTest, whenProgrammingStateComputeModeThenProperFieldsAreSet) {
|
|
|
|
|
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
|
|
|
|
|
uint8_t buffer[64]{};
|
2023-01-05 16:57:56 +00:00
|
|
|
MockExecutionEnvironment executionEnvironment{};
|
|
|
|
|
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
2021-05-18 02:46:21 +00:00
|
|
|
StateComputeModeProperties properties;
|
|
|
|
|
auto pLinearStream = std::make_unique<LinearStream>(buffer, sizeof(buffer));
|
2023-09-12 17:51:43 +00:00
|
|
|
EncodeComputeMode<FamilyType>::programComputeModeCommand(*pLinearStream, properties, rootDeviceEnvironment);
|
2021-05-18 02:46:21 +00:00
|
|
|
auto pScm = reinterpret_cast<STATE_COMPUTE_MODE *>(pLinearStream->getCpuBase());
|
2022-03-07 14:31:53 +00:00
|
|
|
EXPECT_EQ(FamilyType::stateComputeModeForceNonCoherentMask, pScm->getMaskBits());
|
|
|
|
|
EXPECT_EQ(STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_GPU_NON_COHERENT, pScm->getForceNonCoherent());
|
2021-05-18 02:46:21 +00:00
|
|
|
|
2022-03-07 14:31:53 +00:00
|
|
|
properties.isCoherencyRequired.value = 1;
|
2021-05-18 02:46:21 +00:00
|
|
|
pLinearStream = std::make_unique<LinearStream>(buffer, sizeof(buffer));
|
2023-09-12 17:51:43 +00:00
|
|
|
EncodeComputeMode<FamilyType>::programComputeModeCommand(*pLinearStream, properties, rootDeviceEnvironment);
|
2021-05-18 02:46:21 +00:00
|
|
|
pScm = reinterpret_cast<STATE_COMPUTE_MODE *>(pLinearStream->getCpuBase());
|
|
|
|
|
EXPECT_EQ(FamilyType::stateComputeModeForceNonCoherentMask, pScm->getMaskBits());
|
2022-03-07 14:31:53 +00:00
|
|
|
EXPECT_EQ(STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_DISABLED, pScm->getForceNonCoherent());
|
2021-05-18 02:46:21 +00:00
|
|
|
}
|
2025-07-29 19:21:18 +00:00
|
|
|
|
|
|
|
|
GEN12LPTEST_F(CommandEncodeGen12LpTest, givenEncodeDataInMemoryWhenProgrammingFeCmdThenTakeNoAction) {
|
|
|
|
|
constexpr size_t bufferSize = 256;
|
|
|
|
|
alignas(8) uint8_t buffer[bufferSize] = {0x0};
|
2025-07-30 10:02:01 +00:00
|
|
|
void *bufferPtr = buffer;
|
2025-07-29 19:21:18 +00:00
|
|
|
alignas(8) uint8_t zeroBuffer[bufferSize] = {0x0};
|
|
|
|
|
LinearStream cmdStream(buffer, bufferSize);
|
|
|
|
|
|
|
|
|
|
MockExecutionEnvironment executionEnvironment{};
|
|
|
|
|
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
|
|
|
|
|
StreamProperties properties;
|
|
|
|
|
|
|
|
|
|
uint64_t dstGpuAddress = 0x1000;
|
|
|
|
|
|
2025-07-30 10:02:01 +00:00
|
|
|
EncodeDataMemory<FamilyType>::programFrontEndState(bufferPtr, dstGpuAddress, rootDeviceEnvironment, 0x0, 0x0, 0x40, properties);
|
2025-07-29 19:21:18 +00:00
|
|
|
EXPECT_EQ(0, memcmp(buffer, zeroBuffer, bufferSize));
|
|
|
|
|
|
|
|
|
|
EncodeDataMemory<FamilyType>::programFrontEndState(cmdStream, dstGpuAddress, rootDeviceEnvironment, 0x0, 0x0, 0x40, properties);
|
|
|
|
|
EXPECT_EQ(0u, cmdStream.getUsed());
|
|
|
|
|
}
|