[PATCH] D53030: [MicroBenchmark] Add initial LoopInterchange test/benchmark.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 23 03:39:42 PDT 2018


fhahn added a comment.

Thanks! I'll submit it in a few days, with DoNotOptimize.



================
Comment at: MicroBenchmarks/LoopInterchange/main.cpp:58-59
+    int y = test1(M, N);
+    if (state.range(0) == 20)
+      printf("%d\n", y);
+  }
----------------
homerdin wrote:
> fhahn wrote:
> > MatzeB wrote:
> > > Is the `printf` here a good idea? You'll artificially make one iteration slower which could possibly make the benchmark library take longer to stabilize until the result is statistically significant.
> > I've added a comment to the code. It's never called with state.range(0), so the printf should be never executed, but ensure the test1 calls cannot be optimized away.
> Can preventing the call being optimized away be accomplished using `benchmark::DoNotOptimize()` or `benchmark::ClobberMemory()`?
Thanks for pointing me to that function, it looks like it does the same thing in a much clearer way!


https://reviews.llvm.org/D53030





More information about the llvm-commits mailing list