brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 20e045b Raw
57 lines · cpp
1//===-- GPU benchmark for expf16 ------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "benchmarks/gpu/LibcGpuBenchmark.h"10#include "benchmarks/gpu/Random.h"11 12#include "hdr/stdint_proxy.h"13#include "src/__support/macros/properties/types.h"14#include "src/math/expf16.h"15 16#if defined(NVPTX_MATH_FOUND) || defined(AMDGPU_MATH_FOUND)17#include "platform.h"18#endif19 20#define RANDOM_INPUT(T, Func, Dist, Min, Max, N)                               \21  [](uint32_t call_index) {                                                    \22    using namespace LIBC_NAMESPACE::benchmarks;                                \23                                                                               \24    const Dist<T> dist(Min, Max);                                              \25    return MathPerf<T>::template run_throughput<N>(Func, dist, call_index);    \26  }27 28#define BENCH(T, Name, Func, Dist, Min, Max)                                   \29  SINGLE_WAVE_BENCHMARK(LlvmLibcExpf16GpuBenchmark, Name##_1,                  \30                        RANDOM_INPUT(T, Func, Dist, Min, Max, 1));             \31  SINGLE_WAVE_BENCHMARK(LlvmLibcExpf16GpuBenchmark, Name##_128,                \32                        RANDOM_INPUT(T, Func, Dist, Min, Max, 128));           \33  SINGLE_WAVE_BENCHMARK(LlvmLibcExpf16GpuBenchmark, Name##_1024,               \34                        RANDOM_INPUT(T, Func, Dist, Min, Max, 1024));          \35  SINGLE_WAVE_BENCHMARK(LlvmLibcExpf16GpuBenchmark, Name##_4096,               \36                        RANDOM_INPUT(T, Func, Dist, Min, Max, 4096))37 38using LIBC_NAMESPACE::expf16;39 40BENCH(float16, Expf16Subnormal, expf16, UniformExponent, -14, -14);41BENCH(float16, Expf16CoreRange, expf16, UniformLinear, -10.0f16, 10.0f16);42BENCH(float16, Expf16Finite, expf16, UniformLinear, -16.0f16, 11.0f16);43BENCH(float16, Expf16Underflow, expf16, UniformLinear, -17.0f16, -16.0f16);44BENCH(float16, Expf16Overflow, expf16, UniformLinear, 11.0f16, 12.0f16);45 46#ifdef AMDGPU_MATH_FOUND47BENCH(float16, AmdExpf16Subnormal, __ocml_exp_f16, UniformExponent, -14, -14);48BENCH(float16, AmdExpf16CoreRange, __ocml_exp_f16, UniformLinear, -10.0f16,49      10.0f16);50BENCH(float16, AmdExpf16Finite, __ocml_exp_f16, UniformLinear, -16.0f16,51      11.0f16);52BENCH(float16, AmdExpf16Underflow, __ocml_exp_f16, UniformLinear, -17.0f16,53      -16.0f16);54BENCH(float16, AmdExpf16Overflow, __ocml_exp_f16, UniformLinear, 11.0f16,55      12.0f16);56#endif57