refactor: correct naming of enum class constants 3/n

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2023-12-11 13:50:36 +00:00 committed by Compute-Runtime-Automation
parent 1ae79d4ac0
commit 4320f4829a
8 changed files with 121 additions and 139 deletions

View File

@ -78,14 +78,14 @@ static std::string kernelName2 = "kernel_fill";
static std::string kernelName3 = "image_copy";
enum class ExecutionMode : uint32_t {
CommandQueue,
ImmSyncCmdList
commandQueue,
immSyncCmdList
};
enum class AddressingMode : uint32_t {
Default,
Bindless,
BindlessImages
defaultMode,
bindless,
bindlessImages
};
void createModule(const char *sourceCode, AddressingMode addressing, const ze_context_handle_t context, const ze_device_handle_t device, const std::string &deviceName, const std::string &revisionId, ze_module_handle_t &module) {
@ -93,10 +93,10 @@ void createModule(const char *sourceCode, AddressingMode addressing, const ze_co
std::string bindlessOptions = "-cl-intel-use-bindless-mode -cl-intel-use-bindless-advanced-mode";
std::string bindlessImagesOptions = "-cl-intel-use-bindless-images -cl-intel-use-bindless-advanced-mode";
std::string internalOptions = "";
if (addressing == AddressingMode::Bindless) {
if (addressing == AddressingMode::bindless) {
internalOptions = bindlessOptions;
}
if (addressing == AddressingMode::BindlessImages) {
if (addressing == AddressingMode::bindlessImages) {
internalOptions = bindlessImagesOptions;
}
auto bin = LevelZeroBlackBoxTests::compileToNative(sourceCode, deviceName, revisionId, "", internalOptions, buildLog);
@ -125,7 +125,7 @@ void run(const ze_kernel_handle_t &copyKernel, const ze_kernel_handle_t &fillKer
ze_context_handle_t &context, ze_device_handle_t &device, uint32_t id, ExecutionMode mode, bool &outputValidationSuccessful) {
LevelZeroBlackBoxTests::CommandHandler commandHandler;
bool isImmediateCmdList = (mode == ExecutionMode::ImmSyncCmdList);
bool isImmediateCmdList = (mode == ExecutionMode::immSyncCmdList);
SUCCESS_OR_TERMINATE(commandHandler.create(context, device, isImmediateCmdList));
@ -200,10 +200,10 @@ bool testBindlessBufferCopy(ze_context_handle_t context, ze_device_handle_t devi
ze_module_handle_t module = nullptr;
ze_module_handle_t module2 = nullptr;
createModule(source, AddressingMode::Bindless, context, device, deviceId, revisionId, module);
createModule(source2, AddressingMode::Default, context, device, deviceId, revisionId, module2);
createModule(source, AddressingMode::bindless, context, device, deviceId, revisionId, module);
createModule(source2, AddressingMode::defaultMode, context, device, deviceId, revisionId, module2);
ExecutionMode executionModes[] = {ExecutionMode::CommandQueue, ExecutionMode::ImmSyncCmdList};
ExecutionMode executionModes[] = {ExecutionMode::commandQueue, ExecutionMode::immSyncCmdList};
ze_kernel_handle_t copyKernel = nullptr;
ze_kernel_handle_t fillKernel = nullptr;
createKernel(module, copyKernel, kernelName.c_str());
@ -387,7 +387,7 @@ int main(int argc, char *argv[]) {
auto imageCount = LevelZeroBlackBoxTests::getParamValue(argc, argv, "", "--image-count", defaultImageCount);
auto bindlessImages = LevelZeroBlackBoxTests::isParamEnabled(argc, argv, "", "--bindless-images");
AddressingMode mode = bindlessImages ? AddressingMode::BindlessImages : AddressingMode::Bindless;
AddressingMode mode = bindlessImages ? AddressingMode::bindlessImages : AddressingMode::bindless;
std::cout << "--image-count: " << imageCount << std::endl;
if (bindlessImages) {

View File

@ -40,8 +40,8 @@ static constexpr std::array<const char *, 2> kernelNames = {"printf_kernel",
"printf_kernel1"};
enum class PrintfExecutionMode : uint32_t {
CommandQueue,
ImmSyncCmdList
commandQueue,
immSyncCmdList
};
void createModule(const ze_context_handle_t context, const ze_device_handle_t device, ze_module_handle_t &module) {
@ -72,7 +72,7 @@ void runPrintfKernel(const ze_module_handle_t &module, const ze_kernel_handle_t
ze_context_handle_t &context, ze_device_handle_t &device, uint32_t id, PrintfExecutionMode mode) {
LevelZeroBlackBoxTests::CommandHandler commandHandler;
bool isImmediateCmdList = (mode == PrintfExecutionMode::ImmSyncCmdList);
bool isImmediateCmdList = (mode == PrintfExecutionMode::immSyncCmdList);
SUCCESS_OR_TERMINATE(commandHandler.create(context, device, isImmediateCmdList));
@ -129,7 +129,7 @@ int main(int argc, char *argv[]) {
"id == 0\nid == 0\nid == 0\nid == 0\nid == 0\n"
"id == 0\nid == 0\nid == 0\nid == 0\nid == 0\n"};
PrintfExecutionMode executionModes[] = {PrintfExecutionMode::CommandQueue, PrintfExecutionMode::ImmSyncCmdList};
PrintfExecutionMode executionModes[] = {PrintfExecutionMode::commandQueue, PrintfExecutionMode::immSyncCmdList};
for (auto mode : executionModes) {
for (uint32_t i = 0; i < 2; i++) {

View File

@ -18,15 +18,15 @@
namespace NEO {
enum class NewAluOpcodes : uint32_t {
OPCODE_LOAD = 0x080,
OPCODE_LOAD0 = 0x081,
OPCODE_LOAD1 = 0x481,
OPCODE_LOADIND = 0x082,
OPCODE_STOREIND = 0x181,
OPCODE_SHL = 0x105,
OPCODE_SHR = 0x106,
OPCODE_SAR = 0x107,
OPCODE_FENCE = 0x001
opcodeLoad = 0x080,
opcodeLoad0 = 0x081,
opcodeLoad1 = 0x481,
opcodeLoadind = 0x082,
opcodeStoreind = 0x181,
opcodeShl = 0x105,
opcodeShr = 0x106,
opcodeSar = 0x107,
opcodeFence = 0x001
};
struct MiMath : public AUBFixture, public ::testing::Test {
@ -100,7 +100,7 @@ struct MiMath : public AUBFixture, public ::testing::Test {
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCB);
pAluParam->DW0.BitField.Operand2 = shiftReg;
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_SHL); // shift high part
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeShl); // shift high part
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -158,15 +158,15 @@ HWTEST2_F(MiMath, givenLoadIndirectFromMemoryWhenUseMiMathToSimpleOperationThenS
reinterpret_cast<MI_MATH *>(pCmd)->DW0.BitField.DwordLength = numberOfOperationToLoadAddressToMiMathAccu + 13 - 1;
loadAddressToMiMathAccu<FamilyType>(static_cast<uint32_t>(AluRegisters::R_0), static_cast<uint32_t>(AluRegisters::R_1), static_cast<uint32_t>(AluRegisters::R_2)); // GPU address of buffer load to ACCU register
MI_MATH_ALU_INST_INLINE *pAluParam = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(taskStream->getSpace(13 * sizeof(MI_MATH_ALU_INST_INLINE)));
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_FENCE); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeFence); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_LOADIND); // load dword from memory address located in ACCU
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeLoadind); // load dword from memory address located in ACCU
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_0);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_ACCU);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_FENCE); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeFence); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -194,7 +194,7 @@ HWTEST2_F(MiMath, givenLoadIndirectFromMemoryWhenUseMiMathToSimpleOperationThenS
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCA);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_2);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_LOAD0);
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeLoad0);
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCB);
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -202,11 +202,11 @@ HWTEST2_F(MiMath, givenLoadIndirectFromMemoryWhenUseMiMathToSimpleOperationThenS
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_FENCE); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeFence); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_STOREIND); // store to memory from ACCU, value from register R1
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeStoreind); // store to memory from ACCU, value from register R1
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_ACCU);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_1);
@ -248,30 +248,30 @@ HWTEST2_F(MiMath, givenLoadIndirectFromMemoryWhenUseMiMathThenStoreIndirectToAno
loadAddressToMiMathAccu<FamilyType>(static_cast<uint32_t>(AluRegisters::R_0), static_cast<uint32_t>(AluRegisters::R_1), static_cast<uint32_t>(AluRegisters::R_2)); // GPU address of buffer load to ACCU register
MI_MATH_ALU_INST_INLINE *pAluParam = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(taskStream->getSpace(3 * sizeof(MI_MATH_ALU_INST_INLINE)));
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_FENCE); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeFence); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_LOADIND); // load dword from memory address located in ACCU to R0
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeLoadind); // load dword from memory address located in ACCU to R0
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_0);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_ACCU);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_FENCE); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeFence); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
loadAddressToMiMathAccu<FamilyType>(static_cast<uint32_t>(AluRegisters::R_3), static_cast<uint32_t>(AluRegisters::R_4), static_cast<uint32_t>(AluRegisters::R_2)); // GPU address of bufferB load to ACCU register
pAluParam = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(taskStream->getSpace(3 * sizeof(MI_MATH_ALU_INST_INLINE)));
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_FENCE); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeFence); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_STOREIND); // store to memory from ACCU, value from register R0
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeStoreind); // store to memory from ACCU, value from register R0
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_ACCU);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_0);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_FENCE); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeFence); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
@ -317,7 +317,7 @@ HWTEST2_F(MiMath, givenValueToMakeLeftLogicalShiftWhenUseMiMathThenShiftIsDonePr
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCB);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_1);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_SHL); // load value to shift to SRCB
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeShl); // load value to shift to SRCB
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -329,7 +329,7 @@ HWTEST2_F(MiMath, givenValueToMakeLeftLogicalShiftWhenUseMiMathThenShiftIsDonePr
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCB);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_2);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_SHL); // load value to shift to SRCB
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeShl); // load value to shift to SRCB
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -388,7 +388,7 @@ HWTEST2_F(MiMath, givenValueToMakeRightLogicalShiftWhenUseMiMathThenShiftIsDoneP
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCB);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_1);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_SHR); // load value to shift to SRCB
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeShr); // load value to shift to SRCB
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -400,7 +400,7 @@ HWTEST2_F(MiMath, givenValueToMakeRightLogicalShiftWhenUseMiMathThenShiftIsDoneP
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCB);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_2);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_SHR); // load value to shift to SRCB
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeShr); // load value to shift to SRCB
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -452,11 +452,11 @@ HWTEST2_F(MiMath, givenValueToMakeRightAritmeticShiftWhenUseMiMathThenShiftIsDon
reinterpret_cast<MI_MATH *>(pCmd)->DW0.BitField.DwordLength = numberOfOperationToLoadAddressToMiMathAccu + 9 - 1;
loadAddressToMiMathAccu<FamilyType>(static_cast<uint32_t>(AluRegisters::R_0), static_cast<uint32_t>(AluRegisters::R_1), static_cast<uint32_t>(AluRegisters::R_2)); // GPU address of buffer load to ACCU register
MI_MATH_ALU_INST_INLINE *pAluParam = reinterpret_cast<MI_MATH_ALU_INST_INLINE *>(taskStream->getSpace(9 * sizeof(MI_MATH_ALU_INST_INLINE)));
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_LOADIND); // load value from R0 to SRCA
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeLoadind); // load value from R0 to SRCA
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_3);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_ACCU);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_FENCE); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeFence); // to be sure that all writes and reads are completed
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -468,7 +468,7 @@ HWTEST2_F(MiMath, givenValueToMakeRightAritmeticShiftWhenUseMiMathThenShiftIsDon
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCB);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_4);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_SAR); // load value to shift to SRCB
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeSar); // load value to shift to SRCB
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;
@ -480,7 +480,7 @@ HWTEST2_F(MiMath, givenValueToMakeRightAritmeticShiftWhenUseMiMathThenShiftIsDon
pAluParam->DW0.BitField.Operand1 = static_cast<uint32_t>(AluRegisters::R_SRCB);
pAluParam->DW0.BitField.Operand2 = static_cast<uint32_t>(AluRegisters::R_5);
pAluParam++;
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::OPCODE_SAR); // load value to shift to SRCB
pAluParam->DW0.BitField.ALUOpcode = static_cast<uint32_t>(NewAluOpcodes::opcodeSar); // load value to shift to SRCB
pAluParam->DW0.BitField.Operand1 = 0;
pAluParam->DW0.BitField.Operand2 = 0;
pAluParam++;

View File

@ -126,7 +126,7 @@ class ProcessElfBinaryTestsWithBinaryType : public ::testing::TestWithParam<unsi
};
TEST_P(ProcessElfBinaryTestsWithBinaryType, GivenBinaryTypeWhenResolveProgramThenProgramIsProperlyResolved) {
auto mockElf = std::make_unique<MockElfBinaryPatchtokens<enabledIrFormat::ENABLE_SPIRV>>(device->getHardwareInfo());
auto mockElf = std::make_unique<MockElfBinaryPatchtokens<enabledIrFormat::enableSpirv>>(device->getHardwareInfo());
auto pBinary = mockElf->storage;
auto binarySize = mockElf->storage.size();
@ -231,4 +231,4 @@ TEST_F(ProcessElfBinaryTests, GivenBinaryWhenIncompatiblePatchtokenVerionThenPro
cl_int retVal = program->createProgramFromBinary(elfBinary.data(), elfBinary.size(), *device);
EXPECT_EQ(CL_INVALID_BINARY, retVal);
}
}
}

View File

@ -133,35 +133,35 @@ void PrintFormatter::adjustFormatString<int64_t>(std::string &formatString) {
}
size_t PrintFormatter::printToken(char *output, size_t size, const char *formatString) {
PRINTF_DATA_TYPE type(PRINTF_DATA_TYPE::INVALID);
PrintfDataType type(PrintfDataType::invalidType);
read(&type);
switch (type) {
case PRINTF_DATA_TYPE::BYTE:
case PrintfDataType::byteType:
return typedPrintToken<int8_t>(output, size, formatString);
case PRINTF_DATA_TYPE::SHORT:
case PrintfDataType::shortType:
return typedPrintToken<int16_t>(output, size, formatString);
case PRINTF_DATA_TYPE::INT:
case PrintfDataType::intType:
return typedPrintToken<int>(output, size, formatString);
case PRINTF_DATA_TYPE::FLOAT:
case PrintfDataType::floatType:
return typedPrintToken<float>(output, size, formatString);
case PRINTF_DATA_TYPE::LONG:
case PrintfDataType::longType:
return typedPrintToken<int64_t>(output, size, formatString);
case PRINTF_DATA_TYPE::POINTER:
case PrintfDataType::pointerType:
return printPointerToken(output, size, formatString);
case PRINTF_DATA_TYPE::DOUBLE:
case PrintfDataType::doubleType:
return typedPrintToken<double>(output, size, formatString);
case PRINTF_DATA_TYPE::VECTOR_BYTE:
case PrintfDataType::vectorByteType:
return typedPrintVectorToken<int8_t>(output, size, formatString);
case PRINTF_DATA_TYPE::VECTOR_SHORT:
case PrintfDataType::vectorShortType:
return typedPrintVectorToken<int16_t>(output, size, formatString);
case PRINTF_DATA_TYPE::VECTOR_INT:
case PrintfDataType::vectorIntType:
return typedPrintVectorToken<int>(output, size, formatString);
case PRINTF_DATA_TYPE::VECTOR_LONG:
case PrintfDataType::vectorLongType:
return typedPrintVectorToken<int64_t>(output, size, formatString);
case PRINTF_DATA_TYPE::VECTOR_FLOAT:
case PrintfDataType::vectorFloatType:
return typedPrintVectorToken<float>(output, size, formatString);
case PRINTF_DATA_TYPE::VECTOR_DOUBLE:
case PrintfDataType::vectorDoubleType:
return typedPrintVectorToken<double>(output, size, formatString);
default:
return 0;
@ -169,7 +169,7 @@ size_t PrintFormatter::printToken(char *output, size_t size, const char *formatS
}
size_t PrintFormatter::printStringToken(char *output, size_t size, const char *formatString) {
PRINTF_DATA_TYPE type = PRINTF_DATA_TYPE::INVALID;
PrintfDataType type = PrintfDataType::invalidType;
read(&type);
const char *string = nullptr;
@ -184,8 +184,8 @@ size_t PrintFormatter::printStringToken(char *output, size_t size, const char *f
switch (type) {
default:
return simpleSprintf(output, size, formatString, 0);
case PRINTF_DATA_TYPE::STRING:
case PRINTF_DATA_TYPE::POINTER:
case PrintfDataType::stringType:
case PrintfDataType::pointerType:
return simpleSprintf(output, size, formatString, string);
}
}

View File

@ -24,24 +24,24 @@ namespace NEO {
using StringMap = std::unordered_map<uint32_t, std::string>;
enum class PRINTF_DATA_TYPE : int {
INVALID,
BYTE,
SHORT,
INT,
FLOAT,
STRING,
LONG,
POINTER,
DOUBLE,
VECTOR_BYTE,
VECTOR_SHORT,
VECTOR_INT,
VECTOR_LONG,
VECTOR_FLOAT,
VECTOR_DOUBLE
enum class PrintfDataType : int {
invalidType,
byteType,
shortType,
intType,
floatType,
stringType,
longType,
pointerType,
doubleType,
vectorByteType,
vectorShortType,
vectorIntType,
vectorLongType,
vectorFloatType,
vectorDoubleType
};
static_assert(sizeof(PRINTF_DATA_TYPE) == sizeof(int));
static_assert(sizeof(PrintfDataType) == sizeof(int));
class PrintFormatter {
public:

View File

@ -19,12 +19,12 @@
using namespace NEO;
enum class enabledIrFormat {
NONE,
ENABLE_SPIRV,
ENABLE_LLVM
none,
enableSpirv,
enableLlvm
};
template <enabledIrFormat irFormat = enabledIrFormat::NONE>
template <enabledIrFormat irFormat = enabledIrFormat::none>
struct MockElfBinaryPatchtokens {
MockElfBinaryPatchtokens(const HardwareInfo &hwInfo) : MockElfBinaryPatchtokens(std::string{}, hwInfo){};
MockElfBinaryPatchtokens(const std::string &buildOptions, const HardwareInfo &inputHwInfo) {
@ -54,9 +54,9 @@ struct MockElfBinaryPatchtokens {
enc.getElfFileHeader().identity = Elf::ElfFileHeaderIdentity(Elf::EI_CLASS_64);
enc.getElfFileHeader().type = NEO::Elf::ET_OPENCL_EXECUTABLE;
enc.appendSection(Elf::SHT_OPENCL_DEV_BINARY, Elf::SectionNamesOpenCl::deviceBinary, ArrayRef<const uint8_t>::fromAny(mockDevBinaryData, mockDevBinaryDataSize));
if (irFormat == enabledIrFormat::ENABLE_SPIRV)
if (irFormat == enabledIrFormat::enableSpirv)
enc.appendSection(Elf::SHT_OPENCL_SPIRV, Elf::SectionNamesOpenCl::spirvObject, ArrayRef<const uint8_t>::fromAny(mockSpirvBinaryData, mockSpirvBinaryDataSize));
else if (irFormat == enabledIrFormat::ENABLE_LLVM)
else if (irFormat == enabledIrFormat::enableLlvm)
enc.appendSection(Elf::SHT_OPENCL_LLVM_BINARY, Elf::SectionNamesOpenCl::llvmObject, ArrayRef<const uint8_t>::fromAny(mockLlvmBinaryData, mockLlvmBinaryDataSize));
if (false == buildOptions.empty())
enc.appendSection(Elf::SHT_OPENCL_OPTIONS, Elf::SectionNamesOpenCl::buildOptions, ArrayRef<const uint8_t>::fromAny(buildOptions.data(), buildOptions.size()));

View File

@ -56,43 +56,25 @@ class PrintFormatterTest : public testing::Test {
delete data;
}
enum class PRINTF_DATA_TYPE : int {
INVALID,
BYTE,
SHORT,
INT,
FLOAT,
STRING,
LONG,
POINTER,
DOUBLE,
VECTOR_BYTE,
VECTOR_SHORT,
VECTOR_INT,
VECTOR_LONG,
VECTOR_FLOAT,
VECTOR_DOUBLE
};
PRINTF_DATA_TYPE getPrintfDataType(char value) { return PRINTF_DATA_TYPE::BYTE; };
PRINTF_DATA_TYPE getPrintfDataType(int8_t value) { return PRINTF_DATA_TYPE::BYTE; };
PRINTF_DATA_TYPE getPrintfDataType(uint8_t value) { return PRINTF_DATA_TYPE::BYTE; };
PRINTF_DATA_TYPE getPrintfDataType(int16_t value) { return PRINTF_DATA_TYPE::SHORT; };
PRINTF_DATA_TYPE getPrintfDataType(uint16_t value) { return PRINTF_DATA_TYPE::SHORT; };
PRINTF_DATA_TYPE getPrintfDataType(int32_t value) { return PRINTF_DATA_TYPE::INT; };
PRINTF_DATA_TYPE getPrintfDataType(uint32_t value) { return PRINTF_DATA_TYPE::INT; };
PRINTF_DATA_TYPE getPrintfDataType(int64_t value) { return PRINTF_DATA_TYPE::LONG; };
PRINTF_DATA_TYPE getPrintfDataType(uint64_t value) { return PRINTF_DATA_TYPE::LONG; };
PRINTF_DATA_TYPE getPrintfDataType(float value) { return PRINTF_DATA_TYPE::FLOAT; };
PRINTF_DATA_TYPE getPrintfDataType(double value) { return PRINTF_DATA_TYPE::DOUBLE; };
PRINTF_DATA_TYPE getPrintfDataType(char *value) { return PRINTF_DATA_TYPE::STRING; };
PrintfDataType getPrintfDataType(char value) { return PrintfDataType::byteType; };
PrintfDataType getPrintfDataType(int8_t value) { return PrintfDataType::byteType; };
PrintfDataType getPrintfDataType(uint8_t value) { return PrintfDataType::byteType; };
PrintfDataType getPrintfDataType(int16_t value) { return PrintfDataType::shortType; };
PrintfDataType getPrintfDataType(uint16_t value) { return PrintfDataType::shortType; };
PrintfDataType getPrintfDataType(int32_t value) { return PrintfDataType::intType; };
PrintfDataType getPrintfDataType(uint32_t value) { return PrintfDataType::intType; };
PrintfDataType getPrintfDataType(int64_t value) { return PrintfDataType::longType; };
PrintfDataType getPrintfDataType(uint64_t value) { return PrintfDataType::longType; };
PrintfDataType getPrintfDataType(float value) { return PrintfDataType::floatType; };
PrintfDataType getPrintfDataType(double value) { return PrintfDataType::doubleType; };
PrintfDataType getPrintfDataType(char *value) { return PrintfDataType::stringType; };
template <class T>
void injectValue(T value) {
auto dataType = getPrintfDataType(value);
storeData(dataType);
if (dataType == PRINTF_DATA_TYPE::BYTE ||
dataType == PRINTF_DATA_TYPE::SHORT) {
if (dataType == PrintfDataType::byteType ||
dataType == PrintfDataType::shortType) {
storeData(static_cast<int>(value));
} else {
storeData(value);
@ -100,7 +82,7 @@ class PrintFormatterTest : public testing::Test {
}
void injectStringValue(int value) {
storeData(PRINTF_DATA_TYPE::STRING);
storeData(PrintfDataType::stringType);
storeData(value);
}
@ -614,7 +596,7 @@ TEST_F(PrintFormatterTest, GivenNullTokenWhenPrintingThenNullIsInserted) {
auto stringIndex = injectFormatString("%s");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_INT);
storeData(PrintfDataType::vectorIntType);
storeData(0);
char actualOutput[maxPrintfOutputLength];
@ -631,7 +613,7 @@ TEST_F(PrintFormatterTest, GivenVector2WhenPrintingThenAllValuesAreInserted) {
auto stringIndex = injectFormatString("%v2d");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_INT);
storeData(PrintfDataType::vectorIntType);
// channel count
storeData(channelCount);
@ -652,7 +634,7 @@ TEST_F(PrintFormatterTest, GivenVector4WhenPrintingThenAllValuesAreInserted) {
auto stringIndex = injectFormatString("%v4d");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_INT);
storeData(PrintfDataType::vectorIntType);
// channel count
storeData(channelCount);
@ -673,7 +655,7 @@ TEST_F(PrintFormatterTest, GivenVector8WhenPrintingThenAllValuesAreInserted) {
auto stringIndex = injectFormatString("%v8d");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_INT);
storeData(PrintfDataType::vectorIntType);
// channel count
storeData(channelCount);
@ -694,7 +676,7 @@ TEST_F(PrintFormatterTest, GivenVector16WhenPrintingThenAllValuesAreInserted) {
auto stringIndex = injectFormatString("%v16d");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_INT);
storeData(PrintfDataType::vectorIntType);
// channel count
storeData(channelCount);
@ -716,7 +698,7 @@ TEST_F(PrintFormatterTest, GivenVectorOfBytesWhenPrintingThenAllValuesAreInserte
auto stringIndex = injectFormatString("%v2hhd");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_BYTE);
storeData(PrintfDataType::vectorByteType);
// channel count
storeData(channelCount);
@ -736,7 +718,7 @@ TEST_F(PrintFormatterTest, GivenVectorOfShortsWhenPrintingThenAllValuesAreInsert
auto stringIndex = injectFormatString("%v2hd");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_SHORT);
storeData(PrintfDataType::vectorShortType);
// channel count
storeData(channelCount);
@ -756,7 +738,7 @@ TEST_F(PrintFormatterTest, GivenVectorOfIntsWhenPrintingThenAllValuesAreInserted
auto stringIndex = injectFormatString("%v2d");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_INT);
storeData(PrintfDataType::vectorIntType);
// channel count
storeData(channelCount);
@ -776,7 +758,7 @@ TEST_F(PrintFormatterTest, GivenSpecialVectorWhenPrintingThenAllValuesAreInserte
auto stringIndex = injectFormatString("%v2hld");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_INT);
storeData(PrintfDataType::vectorIntType);
// channel count
storeData(channelCount);
@ -795,7 +777,7 @@ TEST_F(PrintFormatterTest, GivenVectorOfLongsWhenPrintingThenAllValuesAreInserte
auto stringIndex = injectFormatString("%v2ld");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_LONG);
storeData(PrintfDataType::vectorLongType);
// channel count
storeData(channelCount);
@ -815,7 +797,7 @@ TEST_F(PrintFormatterTest, GivenVectorOfFloatsWhenPrintingThenAllValuesAreInsert
auto stringIndex = injectFormatString("%v2f");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_FLOAT);
storeData(PrintfDataType::vectorFloatType);
// channel count
storeData(channelCount);
@ -835,7 +817,7 @@ TEST_F(PrintFormatterTest, GivenVectorOfDoublesWhenPrintingThenAllValuesAreInser
auto stringIndex = injectFormatString("%v2f");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_DOUBLE);
storeData(PrintfDataType::vectorDoubleType);
// channel count
storeData(channelCount);
@ -855,7 +837,7 @@ TEST_F(PrintFormatterTest, GivenPointerWhenPrintingThenValueIsInserted) {
int temp;
storeData(PRINTF_DATA_TYPE::POINTER);
storeData(PrintfDataType::pointerType);
// channel count
storeData(reinterpret_cast<void *>(&temp));
@ -881,7 +863,7 @@ TEST_F(PrintFormatterTest, GivenPointerWith32BitKernelWhenPrintingThen32BitPoint
storeData(stringIndex);
kernelInfo->kernelDescriptor.kernelAttributes.gpuPointerSize = 4;
storeData(PRINTF_DATA_TYPE::POINTER);
storeData(PrintfDataType::pointerType);
// store pointer
uint32_t addressValue = 0;
@ -909,7 +891,7 @@ TEST_F(PrintFormatterTest, Given2ByteVectorsWhenPrintingThenDataBufferParsedProp
auto stringIndex = injectFormatString("%v4hhd %v4hhd");
storeData(stringIndex);
storeData(PRINTF_DATA_TYPE::VECTOR_BYTE);
storeData(PrintfDataType::vectorByteType);
// channel count
storeData(channelCount);
@ -921,7 +903,7 @@ TEST_F(PrintFormatterTest, Given2ByteVectorsWhenPrintingThenDataBufferParsedProp
for (int i = 0; i < 12; i++)
storeData(static_cast<int8_t>(0));
storeData(PRINTF_DATA_TYPE::VECTOR_BYTE);
storeData(PrintfDataType::vectorByteType);
// channel count
storeData(channelCount);
@ -973,10 +955,10 @@ TEST_F(PrintFormatterTest, GivenNoStringMapAndBufferWithFormatStringAnd2StringsT
storeData(formatString);
const char *string1 = "str1";
storeData(PRINTF_DATA_TYPE::POINTER);
storeData(PrintfDataType::pointerType);
storeData(string1);
const char *string2 = "str2";
storeData(PRINTF_DATA_TYPE::POINTER);
storeData(PrintfDataType::pointerType);
storeData(string2);
const char *expectedOutput = "str1 str2";