mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-21 09:09:36 +08:00
Updated the benchmarking code to print the number of flops processed instead of the number of bytes.
This commit is contained in:
parent
8217281ae4
commit
a68864b6bc
@ -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))
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <time.h>
|
||||
#include <map>
|
||||
|
||||
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<std::string, ::testing::Benchmark*> 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<double>(g_bytes_processed)/1e6;
|
||||
if (g_benchmark_total_time_ns > 0 && g_flops_processed > 0) {
|
||||
double mflops_processed = static_cast<double>(g_flops_processed)/1e6;
|
||||
double seconds = static_cast<double>(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) {
|
||||
|
@ -367,7 +367,7 @@ template <typename Device> class BenchmarkSuite {
|
||||
}
|
||||
#endif
|
||||
StopBenchmarkTiming();
|
||||
SetBenchmarkBytesProcessed(num_items);
|
||||
SetBenchmarkFlopsProcessed(num_items);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user