mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Fix calculation in encodeGreaterThanPredicate()
encodeGreaterThanPredicate() computes *firstOperand > secondOperand and stores the result in MI_PREDICATE_RESULT where firstOperand is an device memory address. To calculate the "greater than" operation in the device, (secondOperand - *firstOperand) needs to be used, and if the carry flag register is set, then (*firstOperand) is greater than secondOperand. The order of operands in the subtraction (secondOperand - *firstOperand) in encodeGreaterThanPredicate() is incorrect. Transpose the operands. Change-Id: Ie7fee32af338a1a3948abc78cf8332e0be8595ac Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
e26e34e70d
commit
f936b3e1cd
@@ -93,10 +93,19 @@ void EncodeMathMMIO<Family>::encodeMulRegVal(CommandContainer &container, uint32
|
|||||||
EncodeStoreMMIO<Family>::encode(container, CS_GPR_R1, dstAddress);
|
EncodeStoreMMIO<Family>::encode(container, CS_GPR_R1, dstAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compute *firstOperand > secondOperand and store the result in
|
||||||
|
* MI_PREDICATE_RESULT where firstOperand is an device memory address.
|
||||||
|
*
|
||||||
|
* To calculate the "greater than" operation in the device,
|
||||||
|
* (secondOperand - *firstOperand) is used, and if the carry flag register is
|
||||||
|
* set, then (*firstOperand) is greater than secondOperand.
|
||||||
|
*/
|
||||||
template <typename Family>
|
template <typename Family>
|
||||||
void EncodeMathMMIO<Family>::encodeGreaterThanPredicate(CommandContainer &container, uint64_t lhsVal, uint32_t rhsVal) {
|
void EncodeMathMMIO<Family>::encodeGreaterThanPredicate(CommandContainer &container, uint64_t firstOperand, uint32_t secondOperand) {
|
||||||
EncodeSetMMIO<Family>::encodeMEM(container, CS_GPR_R0, lhsVal);
|
/* (*firstOperand) will be subtracted from secondOperand */
|
||||||
EncodeSetMMIO<Family>::encodeIMM(container, CS_GPR_R1, rhsVal);
|
EncodeSetMMIO<Family>::encodeIMM(container, CS_GPR_R0, secondOperand);
|
||||||
|
EncodeSetMMIO<Family>::encodeMEM(container, CS_GPR_R1, firstOperand);
|
||||||
|
|
||||||
size_t size = sizeof(MI_MATH) + sizeof(MI_MATH_ALU_INST_INLINE) * NUM_ALU_INST_FOR_READ_MODIFY_WRITE;
|
size_t size = sizeof(MI_MATH) + sizeof(MI_MATH_ALU_INST_INLINE) * NUM_ALU_INST_FOR_READ_MODIFY_WRITE;
|
||||||
|
|
||||||
@@ -136,6 +145,7 @@ void EncodeMathMMIO<Family>::encodeAlu(MI_MATH_ALU_INST_INLINE *pAluParam, uint3
|
|||||||
pAluParam->DW0.BitField.Operand2 = srcB;
|
pAluParam->DW0.BitField.Operand2 = srcB;
|
||||||
pAluParam++;
|
pAluParam++;
|
||||||
|
|
||||||
|
/* Order of operation: Operand1 <ALUOpcode> Operand2 */
|
||||||
pAluParam->DW0.BitField.ALUOpcode = op;
|
pAluParam->DW0.BitField.ALUOpcode = op;
|
||||||
pAluParam->DW0.BitField.Operand1 = 0;
|
pAluParam->DW0.BitField.Operand1 = 0;
|
||||||
pAluParam->DW0.BitField.Operand2 = 0;
|
pAluParam->DW0.BitField.Operand2 = 0;
|
||||||
@@ -149,6 +159,7 @@ void EncodeMathMMIO<Family>::encodeAlu(MI_MATH_ALU_INST_INLINE *pAluParam, uint3
|
|||||||
|
|
||||||
template <typename Family>
|
template <typename Family>
|
||||||
void EncodeMathMMIO<Family>::encodeAluSubStoreCarry(MI_MATH_ALU_INST_INLINE *pAluParam, uint32_t regA, uint32_t regB, uint32_t finalResultRegister) {
|
void EncodeMathMMIO<Family>::encodeAluSubStoreCarry(MI_MATH_ALU_INST_INLINE *pAluParam, uint32_t regA, uint32_t regB, uint32_t finalResultRegister) {
|
||||||
|
/* regB is subtracted from regA */
|
||||||
encodeAlu(pAluParam, regA, regB, ALU_OPCODE_SUB, finalResultRegister, ALU_REGISTER_R_CF);
|
encodeAlu(pAluParam, regA, regB, ALU_OPCODE_SUB, finalResultRegister, ALU_REGISTER_R_CF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,20 +96,20 @@ HWTEST_F(CommandEncoderMathTest, appendsAGreaterThanPredicate) {
|
|||||||
|
|
||||||
auto itor = commands.begin();
|
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());
|
itor = find<MI_LOAD_REGISTER_IMM *>(itor, commands.end());
|
||||||
ASSERT_NE(itor, commands.end());
|
ASSERT_NE(itor, commands.end());
|
||||||
|
|
||||||
auto cmdIMM = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itor);
|
auto cmdIMM = genCmdCast<MI_LOAD_REGISTER_IMM *>(*itor);
|
||||||
EXPECT_EQ(cmdIMM->getRegisterOffset(), CS_GPR_R1);
|
EXPECT_EQ(cmdIMM->getRegisterOffset(), CS_GPR_R0);
|
||||||
EXPECT_EQ(cmdIMM->getDataDword(), 17u);
|
EXPECT_EQ(cmdIMM->getDataDword(), 17u);
|
||||||
|
|
||||||
|
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_R1);
|
||||||
|
EXPECT_EQ(cmdMEM->getMemoryAddress(), 0xDEADBEEFCAF0u);
|
||||||
|
|
||||||
itor = find<MI_MATH *>(itor, commands.end());
|
itor = find<MI_MATH *>(itor, commands.end());
|
||||||
ASSERT_NE(itor, commands.end());
|
ASSERT_NE(itor, commands.end());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user