mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
commonfns: Fix max_error initialization and improve test output (#2500)
Before this change, `max_error` was initialized to `0.0f`, which caused issues when the actual maximum `error` was also `0.0f`. In such cases, `max_val` would never be updated, leading to misleading test output showing `NaN` values: ``` degrees: Max error 0.000000 ulps at 0: *nan vs 0x1.9802318e8abefp+21 ``` This fix initializes `max_error` to `-INFINITY` to ensure `max_val` is always updated at least once. Additionally, the log output now includes the input value for better debugging: ``` degrees: Max error 0.000000 ulps at 0, input 0x1.c7bffcp+15: *0x1.9802318e8abefp+21 vs 0x1.9802318e8abefp+21 ``` This makes the test output more informative and eliminates confusing `NaN` values in the summary.
This commit is contained in:
@@ -57,7 +57,7 @@ namespace {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
int verify_degrees(const T *const inptr, const T *const outptr, int n)
|
int verify_degrees(const T *const inptr, const T *const outptr, int n)
|
||||||
{
|
{
|
||||||
float error, max_error = 0.0f;
|
float error, max_error = -INFINITY;
|
||||||
double r, max_val = NAN;
|
double r, max_val = NAN;
|
||||||
int max_index = 0;
|
int max_index = 0;
|
||||||
|
|
||||||
@@ -89,13 +89,16 @@ int verify_degrees(const T *const inptr, const T *const outptr, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (std::is_same<T, half>::value)
|
if (std::is_same<T, half>::value)
|
||||||
log_info("degrees: Max error %f ulps at %d: *%a vs %a (*%g vs %g)\n",
|
log_info("degrees: Max error %f ulps at %d, input %a: *%a vs %a (*%g "
|
||||||
max_error, max_index, max_val, conv_to_flt(outptr[max_index]),
|
"vs %g)\n",
|
||||||
max_val, conv_to_flt(outptr[max_index]));
|
max_error, max_index, conv_to_flt(inptr[max_index]), max_val,
|
||||||
|
conv_to_flt(outptr[max_index]), max_val,
|
||||||
|
conv_to_flt(outptr[max_index]));
|
||||||
else
|
else
|
||||||
log_info("degrees: Max error %f ulps at %d: *%a vs %a (*%g vs %g)\n",
|
log_info("degrees: Max error %f ulps at %d, input %a: *%a vs %a (*%g "
|
||||||
max_error, max_index, max_val, outptr[max_index], max_val,
|
"vs %g)\n",
|
||||||
outptr[max_index]);
|
max_error, max_index, conv_to_flt(inptr[max_index]), max_val,
|
||||||
|
outptr[max_index], max_val, outptr[max_index]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -103,7 +106,7 @@ int verify_degrees(const T *const inptr, const T *const outptr, int n)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
int verify_radians(const T *const inptr, const T *const outptr, int n)
|
int verify_radians(const T *const inptr, const T *const outptr, int n)
|
||||||
{
|
{
|
||||||
float error, max_error = 0.0f;
|
float error, max_error = -INFINITY;
|
||||||
double r, max_val = NAN;
|
double r, max_val = NAN;
|
||||||
int max_index = 0;
|
int max_index = 0;
|
||||||
|
|
||||||
@@ -135,13 +138,16 @@ int verify_radians(const T *const inptr, const T *const outptr, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (std::is_same<T, half>::value)
|
if (std::is_same<T, half>::value)
|
||||||
log_info("radians: Max error %f ulps at %d: *%a vs %a (*%g vs %g)\n",
|
log_info("radians: Max error %f ulps at %d, input %a: *%a vs %a (*%g "
|
||||||
max_error, max_index, max_val, conv_to_flt(outptr[max_index]),
|
"vs %g)\n",
|
||||||
max_val, conv_to_flt(outptr[max_index]));
|
max_error, max_index, conv_to_flt(inptr[max_index]), max_val,
|
||||||
|
conv_to_flt(outptr[max_index]), max_val,
|
||||||
|
conv_to_flt(outptr[max_index]));
|
||||||
else
|
else
|
||||||
log_info("radians: Max error %f ulps at %d: *%a vs %a (*%g vs %g)\n",
|
log_info("radians: Max error %f ulps at %d, input %a: *%a vs %a (*%g "
|
||||||
max_error, max_index, max_val, outptr[max_index], max_val,
|
"vs %g)\n",
|
||||||
outptr[max_index]);
|
max_error, max_index, conv_to_flt(inptr[max_index]), max_val,
|
||||||
|
outptr[max_index], max_val, outptr[max_index]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user