1 | #include "benchmarks/gpu/LibcGpuBenchmark.h" |
2 | |
3 | #include "src/math/atan2.h" |
4 | #include "src/stdlib/rand.h" |
5 | |
6 | #ifdef NVPTX_MATH_FOUND |
7 | #include "src/math/nvptx/declarations.h" |
8 | #endif |
9 | |
10 | #ifdef AMDGPU_MATH_FOUND |
11 | #include "src/math/amdgpu/declarations.h" |
12 | #endif |
13 | |
14 | #define BM_TWO_RANDOM_INPUT(T, Func, MIN_EXP, MAX_EXP, N) \ |
15 | []() { \ |
16 | return LIBC_NAMESPACE::benchmarks::MathPerf<T>::run_throughput_in_range< \ |
17 | N>(Func, MIN_EXP, MAX_EXP, MIN_EXP, MAX_EXP); \ |
18 | } |
19 | |
20 | #define BENCH(T, Name, Func, MIN_EXP, MAX_EXP) \ |
21 | SINGLE_WAVE_BENCHMARK(LlvmLibcAtan2GpuBenchmark, Name##_1, \ |
22 | BM_TWO_RANDOM_INPUT(T, Func, MIN_EXP, MAX_EXP, 1)); \ |
23 | SINGLE_WAVE_BENCHMARK(LlvmLibcAtan2GpuBenchmark, Name##_128, \ |
24 | BM_TWO_RANDOM_INPUT(T, Func, MIN_EXP, MAX_EXP, 128)); \ |
25 | SINGLE_WAVE_BENCHMARK(LlvmLibcAtan2GpuBenchmark, Name##_1024, \ |
26 | BM_TWO_RANDOM_INPUT(T, Func, MIN_EXP, MAX_EXP, 1024)); \ |
27 | SINGLE_WAVE_BENCHMARK(LlvmLibcAtan2GpuBenchmark, Name##_4096, \ |
28 | BM_TWO_RANDOM_INPUT(T, Func, MIN_EXP, MAX_EXP, 4096)) |
29 | |
30 | BENCH(double, Atan2, LIBC_NAMESPACE::atan2, -1023, 1023); |
31 | BENCH(double, Atan2TwoPi, LIBC_NAMESPACE::atan2, -10, 3); |
32 | BENCH(double, Atan2TwoPow30, LIBC_NAMESPACE::atan2, 0, 30); |
33 | BENCH(double, Atan2Large, LIBC_NAMESPACE::atan2, 30, 1000); |
34 | |
35 | #ifdef NVPTX_MATH_FOUND |
36 | BENCH(double, NvAtan2, LIBC_NAMESPACE::__nv_atan2, -1023, 1023); |
37 | BENCH(double, NvAtan2TwoPi, LIBC_NAMESPACE::__nv_atan2, -10, 3); |
38 | BENCH(double, NvAtan2TwoPow30, LIBC_NAMESPACE::__nv_atan2, 0, 30); |
39 | BENCH(double, NvAtan2Large, LIBC_NAMESPACE::__nv_atan2, 30, 1000); |
40 | #endif |
41 | |
42 | #ifdef AMDGPU_MATH_FOUND |
43 | BENCH(double, AmdAtan2, LIBC_NAMESPACE::__ocml_atan2_f64, -1023, 1023); |
44 | BENCH(double, AmdAtan2TwoPi, LIBC_NAMESPACE::__ocml_atan2_f64, -10, 3); |
45 | BENCH(double, AmdAtan2TwoPow30, LIBC_NAMESPACE::__ocml_atan2_f64, 0, 30); |
46 | BENCH(double, AmdAtan2Large, LIBC_NAMESPACE::__ocml_atan2_f64, 30, 1000); |
47 | #endif |
48 | |