[libc-commits] [libc] [libc] [gpu] Change Time To Be Per Iteration (PR #101919)

via libc-commits libc-commits at lists.llvm.org
Sun Aug 4 20:28:12 PDT 2024


https://github.com/jameshu15869 created https://github.com/llvm/llvm-project/pull/101919

Previously, the time field was the total time take to run all iterations of the benchmark. This PR changes the value displayed to be the average time take by each iteration. 

>From 6d92d72fc6791e10bb2facf7dfb82476fb83bc58 Mon Sep 17 00:00:00 2001
From: jameshu15869 <jhudson15869 at gmail.com>
Date: Sun, 4 Aug 2024 22:07:24 -0400
Subject: [PATCH] change time to be per iteration

---
 libc/benchmarks/gpu/LibcGpuBenchmark.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libc/benchmarks/gpu/LibcGpuBenchmark.cpp b/libc/benchmarks/gpu/LibcGpuBenchmark.cpp
index a5dbc62a2087b..28235cf137c18 100644
--- a/libc/benchmarks/gpu/LibcGpuBenchmark.cpp
+++ b/libc/benchmarks/gpu/LibcGpuBenchmark.cpp
@@ -115,7 +115,7 @@ void print_results(Benchmark *b) {
   cpp::atomic_thread_fence(cpp::MemoryOrder::RELEASE);
 
   LIBC_NAMESPACE::printf(
-      "%-20s |%8ld |%8ld |%8ld |%11d |%9ld %2s |%9ld |%9d |\n",
+      "%-20s |%8ld |%8ld |%8ld |%11d |%14ld %2s |%9ld |%9d |\n",
       b->get_test_name().data(), result.cycles, result.min, result.max,
       result.total_iterations, result.total_time, time_unit,
       static_cast<uint64_t>(result.standard_deviation), num_threads);
@@ -126,9 +126,9 @@ void print_header() {
   LIBC_NAMESPACE::printf("Running Suite: %-10s\n",
                          benchmarks[0]->get_suite_name().data());
   LIBC_NAMESPACE::printf("%s", RESET);
-  LIBC_NAMESPACE::printf("Benchmark            |  Cycles |     Min |     Max | "
-                         "Iterations |        "
-                         "Time |   Stddev |  Threads |\n");
+  LIBC_NAMESPACE::printf(
+      "Benchmark            |  Cycles |     Min |     Max | "
+      "Iterations | Time / Iteration |   Stddev |  Threads |\n");
   LIBC_NAMESPACE::printf(
       "---------------------------------------------------------------------"
       "--------------------------------\n");
@@ -222,7 +222,7 @@ BenchmarkResult benchmark(const BenchmarkOptions &options,
   result.max = max;
   result.samples = samples;
   result.total_iterations = total_iterations;
-  result.total_time = total_time;
+  result.total_time = total_time / total_iterations;
   return result;
 };
 



More information about the libc-commits mailing list