[all-commits] [llvm/llvm-project] b1f5da: [libc][gpu] Add exp/log benchmarks and flexible in...
Leandro Lacerda via All-commits
all-commits at lists.llvm.org
Wed Aug 27 19:05:31 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b1f5da432845a221b2ebb5abf11cc4521415c9f8
https://github.com/llvm/llvm-project/commit/b1f5da432845a221b2ebb5abf11cc4521415c9f8
Author: Leandro Lacerda <leandrolcampos at yahoo.com.br>
Date: 2025-08-27 (Wed, 27 Aug 2025)
Changed paths:
M libc/benchmarks/gpu/CMakeLists.txt
M libc/benchmarks/gpu/LibcGpuBenchmark.h
A libc/benchmarks/gpu/Random.h
M libc/benchmarks/gpu/src/math/CMakeLists.txt
M libc/benchmarks/gpu/src/math/atan2_benchmark.cpp
A libc/benchmarks/gpu/src/math/exp_benchmark.cpp
A libc/benchmarks/gpu/src/math/expf16_benchmark.cpp
A libc/benchmarks/gpu/src/math/expf_benchmark.cpp
A libc/benchmarks/gpu/src/math/log_benchmark.cpp
A libc/benchmarks/gpu/src/math/logf16_benchmark.cpp
A libc/benchmarks/gpu/src/math/logf_benchmark.cpp
M libc/benchmarks/gpu/src/math/platform.h
M libc/benchmarks/gpu/src/math/sin_benchmark.cpp
Log Message:
-----------
[libc][gpu] Add exp/log benchmarks and flexible input generation (#155727)
This patch adds GPU benchmarks for the exp (`exp`, `expf`, `expf16`) and
log (`log`, `logf`, `logf16`) families of math functions.
Adding these benchmarks revealed a key limitation in the existing
framework: the input generation mechanism was hardcoded to a single
strategy that sampled numbers with a uniform distribution of their
unbiased exponents.
While this strategy is effective for values spanning multiple orders of
magnitude, it is not suitable for linear ranges. The previous framework
lacked the flexibility to support this.
### Summary of Changes
**1. Framework Refactoring for Flexible Input Sampling:**
The GPU benchmark framework was refactored to support multiple,
pluggable input sampling strategies.
* **`Random.h`:** A new header was created to house the
`RandomGenerator` and the new distribution classes.
* **Distribution Classes:** Two sampling strategies were implemented:
* `UniformExponent`: Formalizes the previous logic of sampling numbers
with a uniform distribution of their unbiased exponents. It can now also
be configured to produce only positive values, which is essential for
functions like `log`.
* `UniformLinear`: A new strategy that samples numbers from a uniform
distribution over a linear interval `[min, max)`.
* **`MathPerf` Update:** The `MathPerf` class was updated with a generic
`run_throughput` method that is templated on a distribution object. This
makes the framework extensible to future sampling strategies.
**2. New Benchmarks for `exp` and `log`:**
Using the newly refactored framework, benchmarks were added for `exp`,
`expf`, `expf16`, `log`, `logf`, and `logf16`. The test intervals were
carefully chosen to measure the performance of distinct behavioral
regions of each function.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list