[PATCH] D47675: [test-suite][RFC] Using Google Benchmark Library on Harris Kernel

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 19 22:29:59 PDT 2018


dberris added inline comments.


================
Comment at: MicroBenchmarks/harris/main.cpp:179
+}
+BENCHMARK(BENCHMARK_HARRIS)->Unit(benchmark::kMicrosecond);
+#endif
----------------
It seems that HEIGHT and WIDTH are input values anyway, consider making multiple input sizes to see how the kernel performs as you scale the image size goes up.

You might also not need the `__restrict__` attributes for the malloc-provided heap memory either. This means you could do:

```
float **image = reinterpret_cast<float**>(malloc(sizeof(float) * (2 + state.range(0)) * (2 + state.range(1))));
```

When you register the benchmark, you can then provide the image sizes to test with:

```
BENCHMARK(HarrisBenchmark)
    ->Unit(benchmark::kMicrosecond)
    ->Args({256, 256})
    ->Args({512, 512})
    ->Args({1024, 1024})
    ->Args({2048, 2048});
```

You can see more options at https://github.com/google/benchmark#passing-arguments.

Another thing you may consider measuring as I suggested in the past is throughput. To do that, you can call `state.SetBytesProcessed(...)` in the benchmark body, typically at the end just before exiting -- you want to essentially report something like:

```
state.SetBytesProcessed(sizeof(float) * (state.range(0) + 2) * (state.range(1) + 2) * state.iterations());
```

This will add a "MB/sec" output alongside the time it took for each iteration of the benchmark.


https://reviews.llvm.org/D47675





More information about the llvm-commits mailing list