diff options
author | Pablo Tello <pablo.tello@arm.com> | 2018-01-16 11:41:12 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:43:42 +0000 |
commit | 826c76952b45098f2d090fb3c292707a872e20ce (patch) | |
tree | faf34d728e0e885e3ee43716016e439bcd9054ec /support/ToolchainSupport.h | |
parent | a66eaa2a374a50b798159d95431c946fdda22a24 (diff) | |
download | ComputeLibrary-826c76952b45098f2d090fb3c292707a872e20ce.tar.gz |
COMPMID-835: Valgrind make UNIT/Utils/RoundFloatToNearestUp fail on aarch64
Workaround for Valgrind round() issue on aarch64.
Valgrind's call to std::round(-4.500000) == -4.000000 instead of 5.00000. I think there is a bug
in valgrind's code for aarch64 where the rounding mode is not properly setup and that's the reason
why round to zero is used all the time.
Change-Id: If8fbee98e022856fcc48e454f7afd447f1f193e9
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/116457
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'support/ToolchainSupport.h')
-rw-r--r-- | support/ToolchainSupport.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/support/ToolchainSupport.h b/support/ToolchainSupport.h index e3c0c2761d..56cbce8cc4 100644 --- a/support/ToolchainSupport.h +++ b/support/ToolchainSupport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -246,7 +246,8 @@ int stof(Ts &&... args) template <typename T, typename = typename std::enable_if<std::is_floating_point<T>::value>::type> inline T round(T value) { - return std::round(value); + //Workaround Valgrind's mismatches: when running from Valgrind the call to std::round(-4.500000) == -4.000000 instead of 5.00000 + return (value < 0.f) ? static_cast<int>(value - 0.5f) : static_cast<int>(value + 0.5f); } /** Truncate floating-point value. |