mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Revert "Printf handler: enure that long format uses always 64 bit integers"
This reverts commit 4d3a017d9b
.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
fad7f10b7b
commit
0eb090a451
@ -113,17 +113,6 @@ void PrintFormatter::stripVectorTypeConversion(char *format) {
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void PrintFormatter::adjustFormatString<int64_t>(std::string &formatString) {
|
||||
auto longPosition = formatString.find('l');
|
||||
|
||||
UNRECOVERABLE_IF(longPosition == std::string::npos || longPosition == formatString.size() - 1);
|
||||
|
||||
if (formatString.at(longPosition + 1) != 'l') {
|
||||
formatString.insert(longPosition, "l");
|
||||
}
|
||||
}
|
||||
|
||||
size_t PrintFormatter::printToken(char *output, size_t size, const char *formatString) {
|
||||
PRINTF_DATA_TYPE type(PRINTF_DATA_TYPE::INVALID);
|
||||
read(&type);
|
||||
|
@ -81,36 +81,29 @@ class PrintFormatter {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void adjustFormatString(std::string &formatString) {}
|
||||
|
||||
template <class T>
|
||||
size_t typedPrintToken(char *output, size_t size, const char *inputFormatString) {
|
||||
size_t typedPrintToken(char *output, size_t size, const char *formatString) {
|
||||
T value{0};
|
||||
read(&value);
|
||||
constexpr auto offsetToBeDwordAligned = static_cast<uint32_t>(std::max(int64_t(sizeof(int) - sizeof(T)), int64_t(0)));
|
||||
currentOffset += offsetToBeDwordAligned;
|
||||
std::string formatString(inputFormatString);
|
||||
adjustFormatString<T>(formatString);
|
||||
return simpleSprintf(output, size, formatString.c_str(), value);
|
||||
return simpleSprintf(output, size, formatString, value);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
size_t typedPrintVectorToken(char *output, size_t size, const char *inputFormatString) {
|
||||
size_t typedPrintVectorToken(char *output, size_t size, const char *formatString) {
|
||||
T value = {0};
|
||||
int valueCount = 0;
|
||||
read(&valueCount);
|
||||
|
||||
size_t charactersPrinted = 0;
|
||||
char strippedFormat[1024]{};
|
||||
char strippedFormat[1024];
|
||||
|
||||
stripVectorFormat(inputFormatString, strippedFormat);
|
||||
stripVectorFormat(formatString, strippedFormat);
|
||||
stripVectorTypeConversion(strippedFormat);
|
||||
std::string formatString(strippedFormat);
|
||||
adjustFormatString<T>(formatString);
|
||||
|
||||
for (int i = 0; i < valueCount; i++) {
|
||||
read(&value);
|
||||
charactersPrinted += simpleSprintf(output + charactersPrinted, size - charactersPrinted, formatString.c_str(), value);
|
||||
charactersPrinted += simpleSprintf(output + charactersPrinted, size - charactersPrinted, strippedFormat, value);
|
||||
if (i < valueCount - 1) {
|
||||
charactersPrinted += simpleSprintf(output + charactersPrinted, size - charactersPrinted, "%c", ',');
|
||||
}
|
||||
|
@ -135,21 +135,14 @@ struct SingleValueTestParam {
|
||||
T value;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct SingleValueTestParamWithHostFormat {
|
||||
std::string format;
|
||||
std::string hostFormat;
|
||||
T value;
|
||||
};
|
||||
|
||||
typedef SingleValueTestParam<int8_t> Int8Params;
|
||||
typedef SingleValueTestParam<uint8_t> Uint8Params;
|
||||
typedef SingleValueTestParam<int16_t> Int16Params;
|
||||
typedef SingleValueTestParam<uint16_t> Uint16Params;
|
||||
typedef SingleValueTestParam<int32_t> Int32Params;
|
||||
typedef SingleValueTestParam<uint32_t> Uint32Params;
|
||||
typedef SingleValueTestParamWithHostFormat<int64_t> Int64Params;
|
||||
typedef SingleValueTestParamWithHostFormat<uint64_t> Uint64Params;
|
||||
typedef SingleValueTestParam<int64_t> Int64Params;
|
||||
typedef SingleValueTestParam<uint64_t> Uint64Params;
|
||||
typedef SingleValueTestParam<float> FloatParams;
|
||||
typedef SingleValueTestParam<double> DoubleParams;
|
||||
typedef SingleValueTestParam<std::string> StringParams;
|
||||
@ -278,70 +271,6 @@ INSTANTIATE_TEST_CASE_P(PrintfUint32Test,
|
||||
PrintfUint32Test,
|
||||
::testing::ValuesIn(uintValues));
|
||||
|
||||
Int64Params longValues[] = {
|
||||
{"%lld", "%lld", INT64_MAX},
|
||||
{"%ld", "%lld", INT64_MAX},
|
||||
{"%ld", "%lld", INT64_MIN},
|
||||
{"%lld", "%lld", INT64_MIN},
|
||||
{"%llx", "%llx", INT64_MAX},
|
||||
{"%lx", "%llx", INT64_MAX},
|
||||
{"%lx", "%llx", INT64_MIN},
|
||||
{"%llx", "%llx", INT64_MIN}};
|
||||
|
||||
class PrintfInt64Test : public PrintFormatterTest,
|
||||
public ::testing::WithParamInterface<Int64Params> {};
|
||||
|
||||
TEST_P(PrintfInt64Test, GivenFormatContainingIntWhenPrintingThenValueIsInserted) {
|
||||
auto input = GetParam();
|
||||
|
||||
auto stringIndex = injectFormatString(input.format);
|
||||
storeData(stringIndex);
|
||||
injectValue(input.value);
|
||||
|
||||
char referenceOutput[maxPrintfOutputLength];
|
||||
char actualOutput[maxPrintfOutputLength];
|
||||
|
||||
printFormatter->printKernelOutput([&actualOutput](char *str) { strncpy_s(actualOutput, maxPrintfOutputLength, str, maxPrintfOutputLength - 1); });
|
||||
|
||||
snprintf(referenceOutput, sizeof(referenceOutput), input.hostFormat.c_str(), input.value);
|
||||
|
||||
EXPECT_STREQ(referenceOutput, actualOutput);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(PrintfInt64Test,
|
||||
PrintfInt64Test,
|
||||
::testing::ValuesIn(longValues));
|
||||
|
||||
Uint64Params ulongValues[] = {
|
||||
{"%llu", "%llu", UINT64_MAX},
|
||||
{"%lu", "%llu", UINT64_MAX},
|
||||
{"%llux", "%llux", UINT64_MAX},
|
||||
{"%lux", "%llux", UINT64_MAX}};
|
||||
|
||||
class PrintfUint64Test : public PrintFormatterTest,
|
||||
public ::testing::WithParamInterface<Uint64Params> {};
|
||||
|
||||
TEST_P(PrintfUint64Test, GivenFormatContainingIntWhenPrintingThenValueIsInserted) {
|
||||
auto input = GetParam();
|
||||
|
||||
auto stringIndex = injectFormatString(input.format);
|
||||
storeData(stringIndex);
|
||||
injectValue(input.value);
|
||||
|
||||
char referenceOutput[maxPrintfOutputLength];
|
||||
char actualOutput[maxPrintfOutputLength];
|
||||
|
||||
printFormatter->printKernelOutput([&actualOutput](char *str) { strncpy_s(actualOutput, maxPrintfOutputLength, str, maxPrintfOutputLength - 1); });
|
||||
|
||||
snprintf(referenceOutput, sizeof(referenceOutput), input.hostFormat.c_str(), input.value);
|
||||
|
||||
EXPECT_STREQ(referenceOutput, actualOutput);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(PrintfUint64Test,
|
||||
PrintfUint64Test,
|
||||
::testing::ValuesIn(ulongValues));
|
||||
|
||||
FloatParams floatValues[] = {
|
||||
{"%f", 10.3456f},
|
||||
{"%.1f", 10.3456f},
|
||||
@ -790,21 +719,21 @@ TEST_F(PrintFormatterTest, GivenSpecialVectorWhenPrintingThenAllValuesAreInserte
|
||||
TEST_F(PrintFormatterTest, GivenVectorOfLongsWhenPrintingThenAllValuesAreInserted) {
|
||||
int channelCount = 2;
|
||||
|
||||
auto stringIndex = injectFormatString("%v2ld");
|
||||
auto stringIndex = injectFormatString("%v2lld");
|
||||
storeData(stringIndex);
|
||||
|
||||
storeData(PRINTF_DATA_TYPE::VECTOR_LONG);
|
||||
// channel count
|
||||
storeData(channelCount);
|
||||
|
||||
storeData<int64_t>(100000000000000);
|
||||
storeData<int64_t>(200000000000000);
|
||||
storeData<int64_t>(1);
|
||||
storeData<int64_t>(2);
|
||||
|
||||
char actualOutput[maxPrintfOutputLength];
|
||||
|
||||
printFormatter->printKernelOutput([&actualOutput](char *str) { strncpy_s(actualOutput, maxPrintfOutputLength, str, maxPrintfOutputLength - 1); });
|
||||
|
||||
EXPECT_STREQ("100000000000000,200000000000000", actualOutput);
|
||||
EXPECT_STREQ("1,2", actualOutput);
|
||||
}
|
||||
|
||||
TEST_F(PrintFormatterTest, GivenVectorOfFloatsWhenPrintingThenAllValuesAreInserted) {
|
||||
|
Reference in New Issue
Block a user