Skip to content

Commit

Permalink
Fix powr and re-enable test.
Browse files Browse the repository at this point in the history
We already treat 1 as a special case in pow(). If we treat it as a
special case in powr() too, that looks to be sufficient to avoid
errors caused by internal overflow.
  • Loading branch information
hvdijk committed Jan 5, 2024
1 parent ae30b07 commit ff57593
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 7 additions & 5 deletions modules/compiler/builtins/abacus/source/abacus_math/powr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ inline T powr(const T x, const T y) {
result =
__abacus_select(result, bit, SignedType(xIsInf | yIsInf | (x == 0.0f)));

// Return for any input where y is zero
result = __abacus_select(result, T(1.0), SignedType(y == 0.0f));
// Return 1 for any input where x is 1 or y is zero and we do not subsequently
// change it to NaN.
result =
__abacus_select(result, T(1.0f), SignedType((x == 1.0f) | (y == 0.0f)));

// Return NAN in the following conditions:
// * x is NAN
// * y is NAN
// Return NaN in the following conditions:
// * x is NaN
// * y is NaN
// * x is less than zero
// * x is +/- zero and y is +/- zero
// * x is INFINITY and y is +/- zero
Expand Down
3 changes: 1 addition & 2 deletions source/cl/test/UnitCL/source/ktst_precision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1807,8 +1807,7 @@ TEST_P(HalfMathBuiltinsPow, Precision_80_Half_pow) {
TestAgainstRef<4_ULP>(pow_ref);
}

// TODO: OCK-523
TEST_P(HalfMathBuiltinsPow, DISABLED_Precision_81_Half_powr) {
TEST_P(HalfMathBuiltinsPow, Precision_81_Half_powr) {
if (!UCL::hasHalfSupport(device)) {
GTEST_SKIP();
}
Expand Down

0 comments on commit ff57593

Please sign in to comment.