| 1 | //===-- Performance test for miscellaneous basic operations ---------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "PerfTest.h" |
| 10 | #include "src/math/copysignf.h" |
| 11 | #include "src/math/copysignf16.h" |
| 12 | #include "src/math/fabsf.h" |
| 13 | #include "src/math/fabsf16.h" |
| 14 | |
| 15 | #include <math.h> |
| 16 | |
| 17 | static constexpr size_t FLOAT16_ROUNDS = 20'000; |
| 18 | static constexpr size_t FLOAT_ROUNDS = 40; |
| 19 | |
| 20 | // LLVM libc might be the only libc implementation with support for float16 math |
| 21 | // functions currently. We can't compare our float16 functions against the |
| 22 | // system libc, so we compare them against this placeholder function. |
| 23 | float16 placeholder_unaryf16(float16 x) { return x; } |
| 24 | float16 placeholder_binaryf16(float16 x, float16 y) { return x; } |
| 25 | |
| 26 | int main() { |
| 27 | SINGLE_INPUT_SINGLE_OUTPUT_PERF_EX(float16, LIBC_NAMESPACE::fabsf16, |
| 28 | placeholder_unaryf16, FLOAT16_ROUNDS, |
| 29 | "fabsf16_perf.log" ) |
| 30 | BINARY_INPUT_SINGLE_OUTPUT_PERF_EX( |
| 31 | float16, float16, LIBC_NAMESPACE::copysignf16, placeholder_binaryf16, |
| 32 | FLOAT16_ROUNDS, "copysignf16_perf.log" ) |
| 33 | |
| 34 | SINGLE_INPUT_SINGLE_OUTPUT_PERF_EX(float, LIBC_NAMESPACE::fabsf, fabsf, |
| 35 | FLOAT_ROUNDS, "fabsf_perf.log" ) |
| 36 | BINARY_INPUT_SINGLE_OUTPUT_PERF_EX(float, float, LIBC_NAMESPACE::copysignf, |
| 37 | copysignf, FLOAT_ROUNDS, |
| 38 | "copysignf_perf.log" ) |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |