Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math_brute_force: fix fdim to use device's rounding when converting result back to half. #2223

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions test_conformance/math_brute_force/binary_half.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
return CL_SUCCESS;
}

cl_half_rounding_mode halfRoundingMode = CL_HALF_RTE;
FPU_mode_type oldMode;
oldRoundMode = kRoundToNearestEven;
if (isFDim)
Expand All @@ -294,7 +295,11 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
if (ftz) ForceFTZ(&oldMode);

// Set the rounding mode to match the device
if (gIsInRTZMode) oldRoundMode = set_round(kRoundTowardZero, kfloat);
if (gIsInRTZMode)
{
oldRoundMode = set_round(kRoundTowardZero, kfloat);
halfRoundingMode = CL_HALF_RTZ;
}
}

if (!strcmp(name, "copysign")) copysign_test = 1;
Expand All @@ -312,9 +317,9 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data)
s2[j] = cl_half_to_float(p2[j]);
if (isNextafter)
r[j] = cl_half_from_float(reference_nextafterh(s[j], s2[j]),
cycheng marked this conversation as resolved.
Show resolved Hide resolved
CL_HALF_RTE);
halfRoundingMode);
else
r[j] = cl_half_from_float(ref_func(s[j], s2[j]), CL_HALF_RTE);
r[j] = cl_half_from_float(ref_func(s[j], s2[j]), halfRoundingMode);
}

if (isFDim && ftz) RestoreFPState(&oldMode);
Expand Down
Loading