From a68864b6bce5e00fdec07a9d4dae7376dedb654e Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 28 Jan 2016 16:51:40 -0800 Subject: Updated the benchmarking code to print the number of flops processed instead of the number of bytes. --- bench/tensors/benchmark.h | 3 +-- bench/tensors/benchmark_main.cc | 14 +++++++------- bench/tensors/tensor_benchmarks.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'bench') diff --git a/bench/tensors/benchmark.h b/bench/tensors/benchmark.h index 2c06075e0..f115b54ad 100644 --- a/bench/tensors/benchmark.h +++ b/bench/tensors/benchmark.h @@ -41,10 +41,9 @@ class Benchmark { void RunWithArg(int arg); }; } // namespace testing -void SetBenchmarkBytesProcessed(int64_t); +void SetBenchmarkFlopsProcessed(int64_t); void StopBenchmarkTiming(); void StartBenchmarkTiming(); #define BENCHMARK(f) \ static ::testing::Benchmark* _benchmark_##f __attribute__((unused)) = \ (new ::testing::Benchmark(#f, f)) - diff --git a/bench/tensors/benchmark_main.cc b/bench/tensors/benchmark_main.cc index b2f457c96..65dbd89bb 100644 --- a/bench/tensors/benchmark_main.cc +++ b/bench/tensors/benchmark_main.cc @@ -23,7 +23,7 @@ #include #include -static int64_t g_bytes_processed; +static int64_t g_flops_processed; static int64_t g_benchmark_total_time_ns; static int64_t g_benchmark_start_time_ns; typedef std::map BenchmarkMap; @@ -124,7 +124,7 @@ void Benchmark::Run() { } } void Benchmark::RunRepeatedlyWithArg(int iterations, int arg) { - g_bytes_processed = 0; + g_flops_processed = 0; g_benchmark_total_time_ns = 0; g_benchmark_start_time_ns = NanoTime(); if (fn_ != NULL) { @@ -153,10 +153,10 @@ void Benchmark::RunWithArg(int arg) { } char throughput[100]; throughput[0] = '\0'; - if (g_benchmark_total_time_ns > 0 && g_bytes_processed > 0) { - double mib_processed = static_cast(g_bytes_processed)/1e6; + if (g_benchmark_total_time_ns > 0 && g_flops_processed > 0) { + double mflops_processed = static_cast(g_flops_processed)/1e6; double seconds = static_cast(g_benchmark_total_time_ns)/1e9; - snprintf(throughput, sizeof(throughput), " %8.2f MiB/s", mib_processed/seconds); + snprintf(throughput, sizeof(throughput), " %8.2f MFlops/s", mflops_processed/seconds); } char full_name[100]; if (fn_range_ != NULL) { @@ -175,8 +175,8 @@ void Benchmark::RunWithArg(int arg) { fflush(stdout); } } // namespace testing -void SetBenchmarkBytesProcessed(int64_t x) { - g_bytes_processed = x; +void SetBenchmarkFlopsProcessed(int64_t x) { + g_flops_processed = x; } void StopBenchmarkTiming() { if (g_benchmark_start_time_ns != 0) { diff --git a/bench/tensors/tensor_benchmarks.h b/bench/tensors/tensor_benchmarks.h index 6b9d13446..ba7e7eb48 100644 --- a/bench/tensors/tensor_benchmarks.h +++ b/bench/tensors/tensor_benchmarks.h @@ -367,7 +367,7 @@ template class BenchmarkSuite { } #endif StopBenchmarkTiming(); - SetBenchmarkBytesProcessed(num_items); + SetBenchmarkFlopsProcessed(num_items); } -- cgit v1.2.3