Skip to content

[libc] Add AMDGPU Sin Benchmark #101120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libc/benchmarks/gpu/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ if(CUDAToolkit_FOUND)
endif()
endif()

find_package(AMDDeviceLibs QUIET HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
if(AMDDeviceLibs_FOUND)
get_target_property(ocml_path ocml IMPORTED_LOCATION)
set(amdgpu_bitcode_link_flags
"SHELL:-Xclang -mlink-builtin-bitcode -Xclang ${ocml_path}")
set(amdgpu_math_found "-DAMDGPU_MATH_FOUND=1")
endif()

add_benchmark(
sin_benchmark
SUITE
Expand All @@ -27,6 +35,8 @@ add_benchmark(
COMPILE_OPTIONS
${nvptx_math_found}
${nvptx_bitcode_link_flags}
${amdgpu_math_found}
${amdgpu_bitcode_link_flags}
LOADER_ARGS
--threads 64
)
14 changes: 13 additions & 1 deletion libc/benchmarks/gpu/src/math/sin_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
#include "src/__support/FPUtil/FPBits.h"
#include "src/math/sin.h"
#include "src/stdlib/rand.h"
#include "src/stdlib/srand.h"

#ifdef NVPTX_MATH_FOUND
#include "src/math/nvptx/declarations.h"
#endif

#ifdef AMDGPU_MATH_FOUND
#include "src/math/amdgpu/declarations.h"
#endif

constexpr double M_PI = 3.14159265358979323846;
uint64_t get_bits(double x) {
return LIBC_NAMESPACE::cpp::bit_cast<uint64_t>(x);
Expand Down Expand Up @@ -51,3 +54,12 @@ BENCHMARK(LlvmLibcSinGpuBenchmark, NvSinTwoPi,
BENCHMARK(LlvmLibcSinGpuBenchmark, NvSinLargeInt,
BM_LARGE_INT(LIBC_NAMESPACE::__nv_sin));
#endif

#ifdef AMDGPU_MATH_FOUND
BENCHMARK(LlvmLibcSinGpuBenchmark, AmdgpuSin,
BM_RANDOM_INPUT(LIBC_NAMESPACE::__ocml_sin_f64));
BENCHMARK(LlvmLibcSinGpuBenchmark, AmdgpuSinTwoPi,
BM_TWO_PI(LIBC_NAMESPACE::__ocml_sin_f64));
BENCHMARK(LlvmLibcSinGpuBenchmark, AmdgpuSinLargeInt,
BM_LARGE_INT(LIBC_NAMESPACE::__ocml_sin_f64));
#endif
Loading