2020-10-12 18:39:32 +08:00
|
|
|
/*
|
2023-01-17 00:40:13 +08:00
|
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
2020-10-12 18:39:32 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "shared/source/command_container/command_encoder.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/source/gen8/hw_cmds.h"
|
2020-10-12 18:39:32 +08:00
|
|
|
#include "shared/source/helpers/register_offsets.h"
|
2023-03-16 08:12:49 +08:00
|
|
|
#include "shared/source/indirect_heap/heap_size.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/cmd_parse/gen_cmd_parse.h"
|
|
|
|
#include "shared/test/common/fixtures/device_fixture.h"
|
2023-01-17 00:40:13 +08:00
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
|
|
|
|
#include "shared/test/common/test_macros/test.h"
|
2020-10-12 18:39:32 +08:00
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
2022-08-11 22:01:11 +08:00
|
|
|
using CommandEncoderMathTestGen8 = Test<DeviceFixture>;
|
2020-10-12 18:39:32 +08:00
|
|
|
|
|
|
|
GEN8TEST_F(CommandEncoderMathTestGen8, WhenAppendsAGreaterThanThenPredicateCorrectlySet) {
|
|
|
|
using MI_LOAD_REGISTER_MEM = typename FamilyType::MI_LOAD_REGISTER_MEM;
|
|
|
|
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
|
|
|
|
using MI_LOAD_REGISTER_REG = typename FamilyType::MI_LOAD_REGISTER_REG;
|
|
|
|
using MI_MATH = typename FamilyType::MI_MATH;
|
|
|
|
using MI_MATH_ALU_INST_INLINE = typename FamilyType::MI_MATH_ALU_INST_INLINE;
|
|
|
|
|
|
|
|
CommandContainer cmdContainer;
|
2023-03-16 08:12:49 +08:00
|
|
|
cmdContainer.initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false);
|
2020-10-12 18:39:32 +08:00
|
|
|
|
|
|
|
EncodeMathMMIO<FamilyType>::encodeGreaterThanPredicate(cmdContainer, 0xDEADBEEFCAF0u, 17u);
|
|
|
|
|
|
|
|
GenCmdList commands;
|
|
|
|
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer.getCommandStream()->getCpuBase(), 0), cmdContainer.getCommandStream()->getUsed());
|
|
|
|
|
|
|
|
auto itor = commands.begin();
|
|
|
|
|
|
|
|
itor = find<MI_LOAD_REGISTER_MEM *>(itor, commands.end());
|
|
|
|
ASSERT_NE(itor, commands.end());
|
|
|
|
|
|
|
|
auto cmdMEM = genCmdCast<MI_LOAD_REGISTER_MEM *>(*itor);
|
|
|
|
EXPECT_EQ(cmdMEM->getRegisterAddress(), CS_GPR_R0);
|
|
|
|
EXPECT_EQ(cmdMEM->getMemoryAddress(), 0xDEADBEEFCAF0u);
|
|
|
|
|
|
|
|
itor = find<MI_LOAD_REGISTER_IMM *>(itor, commands.end());
|
|
|
|
ASSERT_NE(itor, commands.end());
|
|
|
|
|
|
|
|
auto cmdIMM = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itor);
|
|
|
|
EXPECT_EQ(cmdIMM->getRegisterOffset(), CS_GPR_R1);
|
|
|
|
EXPECT_EQ(cmdIMM->getDataDword(), 17u);
|
|
|
|
|
|
|
|
itor = find<MI_MATH *>(itor, commands.end());
|
|
|
|
ASSERT_NE(itor, commands.end());
|
|
|
|
|
|
|
|
auto cmdMATH = genCmdCast<MI_MATH *>(*itor);
|
|
|
|
EXPECT_EQ(cmdMATH->DW0.BitField.DwordLength, 3u);
|
|
|
|
|
|
|
|
itor = find<MI_LOAD_REGISTER_REG *>(itor, commands.end());
|
|
|
|
ASSERT_NE(itor, commands.end());
|
|
|
|
|
|
|
|
auto cmdREG = genCmdCast<MI_LOAD_REGISTER_REG *>(*itor);
|
|
|
|
EXPECT_EQ(cmdREG->getSourceRegisterAddress(), CS_GPR_R2);
|
|
|
|
EXPECT_EQ(cmdREG->getDestinationRegisterAddress(), CS_PREDICATE_RESULT);
|
|
|
|
|
|
|
|
auto cmdALU = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(cmdMATH + 3);
|
|
|
|
EXPECT_EQ(cmdALU->DW0.BitField.ALUOpcode,
|
|
|
|
static_cast<uint32_t>(AluRegisters::OPCODE_SUB));
|
|
|
|
}
|