[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
Wed Jun 13 19:07:54 PDT 2018


dberris added inline comments.


================
Comment at: MicroBenchmarks/harris/main.cpp:107-120
+void BENCHMARK_HARRIS(benchmark::State &state) {
+
+  float (* __restrict__ imageCopy)[2 + HEIGHT][2 + WIDTH];  
+  imageCopy  = (float(*)[2+HEIGHT][2+WIDTH]) malloc(sizeof(float)* (2+HEIGHT) * (2+WIDTH));
+  for (auto _ : state) {
+    state.PauseTiming();
+    std::memcpy(imageCopy, image, (2 + HEIGHT) * (2 + WIDTH) * sizeof(float));
----------------
There's a few comments I have about this code, but let me start with the simple(r) ones:

- You may want to make the image sizes configurable, and using the benchmark API to try it on differently sized images (so that you can see how the algorithm scales based on input sizes).

- You probably want to ensure that you do something with the image data after the loop(s) to ensure that the allocations aren't optimised away. You can use the benchmark::DoNotOptimize(...) function to do some of that.

- You might also want to consider measuring throughput (computing the amount of data processed for the time it took per iteration).

- Before you get into the loop, you should probably run the kernel once on the just-allocated memory, to ensure that you're not just measuring the cost of pulling data through the cache(s). This is probably better to do with smaller images.


https://reviews.llvm.org/D47675





More information about the llvm-commits mailing list