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

via libc-commits libc-commits at lists.llvm.org
Mon Aug 5 06:27:34 PDT 2024


Author: jameshu15869
Date: 2024-08-05T08:27:31-05:00
New Revision: 39826b10306ea05fe79d7af3420ffd4a93718ec4

URL: https://github.com/llvm/llvm-project/commit/39826b10306ea05fe79d7af3420ffd4a93718ec4
DIFF: https://github.com/llvm/llvm-project/commit/39826b10306ea05fe79d7af3420ffd4a93718ec4.diff

LOG: [libc] [gpu] Change Time To Be Per Iteration (#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.

Added: 
    

Modified: 
    libc/benchmarks/gpu/LibcGpuBenchmark.cpp

Removed: 
    


################################################################################
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