[libc-commits] [libc] eeed589 - [libc] Correctly Run Multiple Benchmarks in the Same File (#98467)
via libc-commits
libc-commits at lists.llvm.org
Thu Jul 11 04:58:13 PDT 2024
Author: jameshu15869
Date: 2024-07-11T06:58:10-05:00
New Revision: eeed5896deed205997bd3cfc70b5bf134017c694
URL: https://github.com/llvm/llvm-project/commit/eeed5896deed205997bd3cfc70b5bf134017c694
DIFF: https://github.com/llvm/llvm-project/commit/eeed5896deed205997bd3cfc70b5bf134017c694.diff
LOG: [libc] Correctly Run Multiple Benchmarks in the Same File (#98467)
There was previously an issue where registering multiple benchmarks in
the same file would only give the results for the last benchmark to run.
This PR fixes the issue.
@jhuber6
Added:
Modified:
libc/benchmarks/gpu/LibcGpuBenchmark.cpp
libc/benchmarks/gpu/src/ctype/isalnum_benchmark.cpp
Removed:
################################################################################
diff --git a/libc/benchmarks/gpu/LibcGpuBenchmark.cpp b/libc/benchmarks/gpu/LibcGpuBenchmark.cpp
index 7f60c9cc4a2f4..3dd83cef6d4df 100644
--- a/libc/benchmarks/gpu/LibcGpuBenchmark.cpp
+++ b/libc/benchmarks/gpu/LibcGpuBenchmark.cpp
@@ -52,11 +52,10 @@ void Benchmark::run_benchmarks() {
uint64_t id = gpu::get_thread_id();
gpu::sync_threads();
- for (Benchmark *b : benchmarks)
+ for (Benchmark *b : benchmarks) {
results[id] = b->run();
- gpu::sync_threads();
- if (id == 0) {
- for (Benchmark const *b : benchmarks) {
+ gpu::sync_threads();
+ if (id == 0) {
BenchmarkResult all_results = reduce_results(results);
constexpr auto GREEN = "\033[32m";
constexpr auto RESET = "\033[0m";
diff --git a/libc/benchmarks/gpu/src/ctype/isalnum_benchmark.cpp b/libc/benchmarks/gpu/src/ctype/isalnum_benchmark.cpp
index 4050bc0ec77b9..6f8d247902f76 100644
--- a/libc/benchmarks/gpu/src/ctype/isalnum_benchmark.cpp
+++ b/libc/benchmarks/gpu/src/ctype/isalnum_benchmark.cpp
@@ -6,4 +6,16 @@ uint64_t BM_IsAlnum() {
char x = 'c';
return LIBC_NAMESPACE::latency(LIBC_NAMESPACE::isalnum, x);
}
-BENCHMARK(LlvmLibcIsAlNumGpuBenchmark, IsAlnumWrapper, BM_IsAlnum);
+BENCHMARK(LlvmLibcIsAlNumGpuBenchmark, IsAlnum, BM_IsAlnum);
+
+uint64_t BM_IsAlnumCapital() {
+ char x = 'A';
+ return LIBC_NAMESPACE::latency(LIBC_NAMESPACE::isalnum, x);
+}
+BENCHMARK(LlvmLibcIsAlNumGpuBenchmark, IsAlnumCapital, BM_IsAlnumCapital);
+
+uint64_t BM_IsAlnumNotAlnum() {
+ char x = '{';
+ return LIBC_NAMESPACE::latency(LIBC_NAMESPACE::isalnum, x);
+}
+BENCHMARK(LlvmLibcIsAlNumGpuBenchmark, IsAlnumNotAlnum, BM_IsAlnumNotAlnum);
More information about the libc-commits
mailing list