math_brute_force: Fix -Wformat warnings (#1518)

* math_brute_force: Fix -Wformat warnings

The main sources of warnings were:

 * Printing of 64-bit types, which is now done using the `PRI*64`
   macros from <cinttypes> to ensure portability across 32 and 64-bit
   builds.

 * Printing of `size_t` types that lacked a `z` length modifier.

 * Printing of values with a `z` length modifier that weren't a
   `size_t` type.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

* [NFC] math_brute_force: clang-format after -Wformat changes

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
Sven van Haastregt
2022-10-01 10:14:32 +01:00
committed by GitHub
parent c69f6eec47
commit 73f51ccff7
23 changed files with 111 additions and 77 deletions

View File

@@ -42,6 +42,6 @@ set(${MODULE_NAME}_SOURCES
# math_brute_force compiles cleanly with -Wall (except for a few remaining
# warnings), but other tests not (yet); so enable -Wall locally.
set_gnulike_module_compile_flags("-Wall -Wno-format -Wno-strict-aliasing -Wno-unknown-pragmas")
set_gnulike_module_compile_flags("-Wall -Wno-strict-aliasing -Wno-unknown-pragmas")
include(../CMakeCommon.txt)

View File

@@ -630,7 +630,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10u scale:%10zu buf_elements:%10u ulps:%5.3f "
vlog("base:%14u step:%10u scale:%10u buf_elements:%10zu ulps:%5.3f "
"ThreadCount:%2u\n",
base, job->step, job->scale, buffer_elements, job->ulps,
job->threadCount);

View File

@@ -755,7 +755,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
{
vlog_error(
"\nERROR: %s%s: %f ulp error at {%a (0x%x), %a "
"(0x%x)}: *%a vs. %a (0x%8.8x) at index: %d\n",
"(0x%x)}: *%a vs. %a (0x%8.8x) at index: %zu\n",
name, sizeNames[k], err, s[j], ((cl_uint *)s)[j],
s2[j], ((cl_uint *)s2)[j], r[j], test,
((cl_uint *)&test)[0], j);
@@ -787,7 +787,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10u scale:%10zu buf_elements:%10u ulps:%5.3f "
vlog("base:%14u step:%10u scale:%10u buf_elements:%10zu ulps:%5.3f "
"ThreadCount:%2u\n",
base, job->step, job->scale, buffer_elements, job->ulps,
job->threadCount);

View File

@@ -516,7 +516,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
{
vlog_error(
"\nERROR: %s%s: %f ulp error at {%a (0x%8.8x), %d}: "
"*%a (0x%8.8x) vs. %a (0x%8.8x) at index: %d\n",
"*%a (0x%8.8x) vs. %a (0x%8.8x) at index: %zu\n",
name, sizeNames[k], err, s[j], ((uint32_t *)s)[j],
s2[j], r[j], ((uint32_t *)r)[j], test,
((cl_uint *)&test)[0], j);
@@ -545,7 +545,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10u scale:%10zu buf_elements:%10u ulps:%5.3f "
vlog("base:%14u step:%10u scale:%10u buf_elements:%10zu ulps:%5.3f "
"ThreadCount:%2u\n",
base, job->step, job->scale, buffer_elements, job->ulps,
job->threadCount);

View File

@@ -601,7 +601,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10u scale:%10zu buf_elements:%10u ulps:%5.3f "
vlog("base:%14u step:%10u scale:%10u buf_elements:%10zu ulps:%5.3f "
"ThreadCount:%2u\n",
base, job->step, job->scale, buffer_elements, job->ulps,
job->threadCount);

View File

@@ -698,7 +698,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
if (fail)
{
vlog_error("\nERROR: %s%s: %f ulp error at {%a, %a}: *%a "
"vs. %a (0x%8.8x) at index: %d\n",
"vs. %a (0x%8.8x) at index: %zu\n",
name, sizeNames[k], err, s[j], s2[j], r[j], test,
((cl_uint *)&test)[0], j);
error = -1;
@@ -726,7 +726,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10u scale:%10zu buf_elements:%10u ulps:%5.3f "
vlog("base:%14u step:%10u scale:%10u buf_elements:%10zu ulps:%5.3f "
"ThreadCount:%2u\n",
base, job->step, job->scale, buffer_elements, job->ulps,
job->threadCount);

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <climits>
#include <cstring>
@@ -527,15 +528,18 @@ int TestFunc_DoubleI_Double_Double(const Func *f, MTdata d, bool relaxedMode)
if (fail)
{
vlog_error(
"\nERROR: %sD%s: {%f, %lld} ulp error at {%.13la, "
"%.13la} ({ 0x%16.16llx, 0x%16.16llx}): *{%.13la, "
"%d} ({ 0x%16.16llx, 0x%8.8x}) vs. {%.13la, %d} ({ "
"0x%16.16llx, 0x%8.8x})\n",
f->name, sizeNames[k], err, iErr, ((double *)gIn)[j],
((double *)gIn2)[j], ((cl_ulong *)gIn)[j],
((cl_ulong *)gIn2)[j], ((double *)gOut_Ref)[j],
((int *)gOut_Ref2)[j], ((cl_ulong *)gOut_Ref)[j],
vlog_error("\nERROR: %sD%s: {%f, %" PRId64
"} ulp error at {%.13la, "
"%.13la} ({ 0x%16.16" PRIx64 ", 0x%16.16" PRIx64
"}): *{%.13la, "
"%d} ({ 0x%16.16" PRIx64
", 0x%8.8x}) vs. {%.13la, %d} ({ "
"0x%16.16" PRIx64 ", 0x%8.8x})\n",
f->name, sizeNames[k], err, iErr,
((double *)gIn)[j], ((double *)gIn2)[j],
((cl_ulong *)gIn)[j], ((cl_ulong *)gIn2)[j],
((double *)gOut_Ref)[j], ((int *)gOut_Ref2)[j],
((cl_ulong *)gOut_Ref)[j],
((cl_uint *)gOut_Ref2)[j], test, q2[j],
((cl_ulong *)q)[j], ((cl_uint *)q2)[j]);
error = -1;
@@ -548,8 +552,9 @@ int TestFunc_DoubleI_Double_Double(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{
@@ -566,8 +571,8 @@ int TestFunc_DoubleI_Double_Double(const Func *f, MTdata d, bool relaxedMode)
else
vlog("passed");
vlog("\t{%8.2f, %lld} @ {%a, %a}", maxError, maxError2, maxErrorVal,
maxErrorVal2);
vlog("\t{%8.2f, %" PRId64 "} @ {%a, %a}", maxError, maxError2,
maxErrorVal, maxErrorVal2);
}
vlog("\n");

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <climits>
#include <cstring>
@@ -513,14 +514,15 @@ int TestFunc_FloatI_Float_Float(const Func *f, MTdata d, bool relaxedMode)
if (fail)
{
vlog_error(
"\nERROR: %s%s: {%f, %lld} ulp error at {%a, %a} "
vlog_error("\nERROR: %s%s: {%f, %" PRId64
"} ulp error at {%a, %a} "
"({0x%8.8x, 0x%8.8x}): *{%a, %d} ({0x%8.8x, "
"0x%8.8x}) vs. {%a, %d} ({0x%8.8x, 0x%8.8x})\n",
f->name, sizeNames[k], err, iErr, ((float *)gIn)[j],
((float *)gIn2)[j], ((cl_uint *)gIn)[j],
((cl_uint *)gIn2)[j], ((float *)gOut_Ref)[j],
((int *)gOut_Ref2)[j], ((cl_uint *)gOut_Ref)[j],
f->name, sizeNames[k], err, iErr,
((float *)gIn)[j], ((float *)gIn2)[j],
((cl_uint *)gIn)[j], ((cl_uint *)gIn2)[j],
((float *)gOut_Ref)[j], ((int *)gOut_Ref2)[j],
((cl_uint *)gOut_Ref)[j],
((cl_uint *)gOut_Ref2)[j], test, q2[j],
((cl_uint *)&test)[0], ((cl_uint *)q2)[j]);
error = -1;
@@ -533,8 +535,9 @@ int TestFunc_FloatI_Float_Float(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{
@@ -551,8 +554,8 @@ int TestFunc_FloatI_Float_Float(const Func *f, MTdata d, bool relaxedMode)
else
vlog("passed");
vlog("\t{%8.2f, %lld} @ {%a, %a}", maxError, maxError2, maxErrorVal,
maxErrorVal2);
vlog("\t{%8.2f, %" PRId64 "} @ {%a, %a}", maxError, maxError2,
maxErrorVal, maxErrorVal2);
}
vlog("\n");

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -271,8 +272,9 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -268,8 +269,9 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -487,8 +488,9 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
cl_ulong err = t[j] - q[j];
if (q[j] > t[j]) err = q[j] - t[j];
vlog_error("\nERROR: %s: %lld ulp error at {%.13la, %.13la}: *%lld "
"vs. %lld (index: %d)\n",
vlog_error("\nERROR: %s: %" PRId64
" ulp error at {%.13la, %.13la}: *%" PRId64 " "
"vs. %" PRId64 " (index: %zu)\n",
name, err, ((double *)s)[j], ((double *)s2)[j], t[j],
q[j], j);
error = -1;
@@ -535,8 +537,9 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
cl_ulong err = -t[j] - q[j];
if (q[j] > -t[j]) err = q[j] + t[j];
vlog_error("\nERROR: %sD%s: %lld ulp error at {%.13la, "
"%.13la}: *%lld vs. %lld (index: %d)\n",
vlog_error("\nERROR: %sD%s: %" PRId64 " ulp error at {%.13la, "
"%.13la}: *%" PRId64 " vs. %" PRId64
" (index: %zu)\n",
name, sizeNames[k], err, ((double *)s)[j],
((double *)s2)[j], -t[j], q[j], j);
error = -1;

View File

@@ -478,7 +478,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
uint32_t err = t[j] - q[j];
if (q[j] > t[j]) err = q[j] - t[j];
vlog_error("\nERROR: %s: %d ulp error at {%a, %a}: *0x%8.8x vs. "
"0x%8.8x (index: %d)\n",
"0x%8.8x (index: %zu)\n",
name, err, ((float *)s)[j], ((float *)s2)[j], t[j], q[j],
j);
error = -1;
@@ -524,7 +524,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
cl_uint err = -t[j] - q[j];
if (q[j] > -t[j]) err = q[j] + t[j];
vlog_error("\nERROR: %s%s: %d ulp error at {%a, %a}: *0x%8.8x "
"vs. 0x%8.8x (index: %d)\n",
"vs. 0x%8.8x (index: %zu)\n",
name, sizeNames[k], err, ((float *)s)[j],
((float *)s2)[j], -t[j], q[j], j);
error = -1;

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -297,7 +298,8 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
cl_ulong err = t[j] - q[j];
if (q[j] > t[j]) err = q[j] - t[j];
vlog_error("\nERROR: %sD: %zd ulp error at %.13la: *%zd vs. %zd\n",
vlog_error("\nERROR: %sD: %" PRId64
" ulp error at %.13la: *%" PRId64 " vs. %" PRId64 "\n",
name, err, ((double *)gIn)[j], t[j], q[j]);
return -1;
}
@@ -323,7 +325,8 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
cl_ulong err = -t[j] - q[j];
if (q[j] > -t[j]) err = q[j] + t[j];
vlog_error(
"\nERROR: %sD%s: %zd ulp error at %.13la: *%zd vs. %zd\n",
"\nERROR: %sD%s: %" PRId64 " ulp error at %.13la: *%" PRId64
" vs. %" PRId64 "\n",
name, sizeNames[k], err, ((double *)gIn)[j], -t[j], q[j]);
return -1;
}

View File

@@ -132,7 +132,7 @@ static int doTest(const char *name)
if ((gStartTestNumber != ~0u && i < gStartTestNumber)
|| i > gEndTestNumber)
{
vlog("Skipping function #%d\n", i);
vlog("Skipping function #%zu\n", i);
return 0;
}

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
#define CORRECTLY_ROUNDED 0
@@ -708,8 +709,9 @@ int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d,
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
#define CORRECTLY_ROUNDED 0
@@ -843,8 +844,8 @@ int TestFunc_Float_Float_Float_Float(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10u bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64 " bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -345,7 +346,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
if (fail)
{
vlog_error("\nERROR: %s%s: %f ulp error at %.13la "
"(0x%16.16llx): *%.13la vs. %.13la\n",
"(0x%16.16" PRIx64 "): *%.13la vs. %.13la\n",
job->f->name, sizeNames[k], err,
((cl_double *)gIn)[j], ((cl_ulong *)gIn)[j],
((cl_double *)gOut_Ref)[j], test);

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -414,8 +415,9 @@ int TestFunc_Double2_Double(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -546,8 +547,9 @@ int TestFunc_Float2_Float(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <climits>
#include <cstring>
@@ -386,8 +387,9 @@ int TestFunc_DoubleI_Double(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{
@@ -404,8 +406,8 @@ int TestFunc_DoubleI_Double(const Func *f, MTdata d, bool relaxedMode)
else
vlog("passed");
vlog("\t{%8.2f, %lld} @ {%a, %a}", maxError, maxError2, maxErrorVal,
maxErrorVal2);
vlog("\t{%8.2f, %" PRId64 "} @ {%a, %a}", maxError, maxError2,
maxErrorVal, maxErrorVal2);
}
vlog("\n");

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <climits>
#include <cstring>
@@ -384,8 +385,9 @@ int TestFunc_FloatI_Float(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{
@@ -402,8 +404,8 @@ int TestFunc_FloatI_Float(const Func *f, MTdata d, bool relaxedMode)
else
vlog("passed");
vlog("\t{%8.2f, %lld} @ {%a, %a}", maxError, maxError2, maxErrorVal,
maxErrorVal2);
vlog("\t{%8.2f, %" PRId64 "} @ {%a, %a}", maxError, maxError2,
maxErrorVal, maxErrorVal2);
}
vlog("\n");

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -267,10 +268,10 @@ int TestFunc_Double_ULong(const Func *f, MTdata d, bool relaxedMode)
}
if (fail)
{
vlog_error("\n%s%sD: %f ulp error at 0x%16.16llx: "
vlog_error(
"\n%s%sD: %f ulp error at 0x%16.16" PRIx64 ": "
"*%.13la vs. %.13la\n",
f->name, sizeNames[k], err,
((uint64_t *)gIn)[j],
f->name, sizeNames[k], err, ((uint64_t *)gIn)[j],
((double *)gOut_Ref)[j], test);
error = -1;
goto exit;
@@ -283,8 +284,9 @@ int TestFunc_Double_ULong(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{

View File

@@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"
#include <cinttypes>
#include <cstring>
namespace {
@@ -285,8 +286,9 @@ int TestFunc_Float_UInt(const Func *f, MTdata d, bool relaxedMode)
{
if (gVerboseBruteForce)
{
vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step,
BUFFER_SIZE);
vlog("base:%14" PRIu64 " step:%10" PRIu64
" bufferSize:%10d \n",
i, step, BUFFER_SIZE);
}
else
{