Skip to content

Commit

Permalink
spirv_new: fix test_decorate. (#1980)
Browse files Browse the repository at this point in the history
test_decorate was checking for half-precision NAN incorrectly, calling
cl_half_from_float where cl_half_to_float was intended, causing a wrong
expected result.

test_decorate was also printing the expected and actual results
reversed, printing "got -1, want 0", when our implementation already
returned 0.
  • Loading branch information
hvdijk committed Jun 25, 2024
1 parent ac69311 commit c7b682f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test_conformance/spirv_new/test_decorate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static inline To compute_saturated_output(Ti lhs, Ti rhs)
f = cl_half_to_float(cl_half_from_float(f, CL_HALF_RTE));

To val = (To)std::min<float>(std::max<float>(f, loVal), hiVal);
if (isnan(cl_half_from_float(rhs, CL_HALF_RTE)))
if (isnan(cl_half_to_float(rhs)))
{
val = 0;
}
Expand Down Expand Up @@ -309,7 +309,7 @@ int verify_saturated_results(cl_device_id deviceID, cl_context context,

if (val != h_res[i])
{
log_error("Value error at %d: got %d, want %d\n", i, val, h_res[i]);
log_error("Value error at %d: got %d, want %d\n", i, h_res[i], val);
return -1;
}
}
Expand Down

0 comments on commit c7b682f

Please sign in to comment.