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 "BinaryOpSingleOutputPerf.h" 10 #include "SingleInputSingleOutputPerf.h" 11 #include "src/math/copysignf.h" 12 #include "src/math/copysignf16.h" 13 #include "src/math/fabsf.h" 14 #include "src/math/fabsf16.h" 15 16 #include <math.h> 17 18 static constexpr size_t FLOAT16_ROUNDS = 20'000; 19 static constexpr size_t FLOAT_ROUNDS = 40; 20 21 // LLVM libc might be the only libc implementation with support for float16 math 22 // functions currently. We can't compare our float16 functions against the 23 // system libc, so we compare them against this placeholder function. 24 float16 placeholder_unaryf16(float16 x) { return x; } 25 float16 placeholder_binaryf16(float16 x, float16 y) { return x; } 26 27 int main() { 28 SINGLE_INPUT_SINGLE_OUTPUT_PERF_EX(float16, LIBC_NAMESPACE::fabsf16, 29 placeholder_unaryf16, FLOAT16_ROUNDS, 30 "fabsf16_perf.log") 31 BINARY_OP_SINGLE_OUTPUT_PERF_EX(float16, float16, LIBC_NAMESPACE::copysignf16, 32 placeholder_binaryf16, FLOAT16_ROUNDS, 33 "copysignf16_perf.log") 34 35 SINGLE_INPUT_SINGLE_OUTPUT_PERF_EX(float, LIBC_NAMESPACE::fabsf, fabsf, 36 FLOAT_ROUNDS, "fabsf_perf.log") 37 BINARY_OP_SINGLE_OUTPUT_PERF_EX(float, float, LIBC_NAMESPACE::copysignf, 38 copysignf, FLOAT_ROUNDS, "copysignf_perf.log") 39 40 return 0; 41 } 42