[PATCH] D53030: [MicroBenchmark] Add initial LoopInterchange test/benchmark.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 28 02:49:09 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL347740: [MicroBenchmark] Add initial LoopInterchange test/benchmark. (authored by fhahn, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D53030?vs=175643&id=175644#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D53030/new/
https://reviews.llvm.org/D53030
Files:
test-suite/trunk/MicroBenchmarks/CMakeLists.txt
test-suite/trunk/MicroBenchmarks/LoopInterchange/CMakeLists.txt
test-suite/trunk/MicroBenchmarks/LoopInterchange/LoopInterchange.reference_output
test-suite/trunk/MicroBenchmarks/LoopInterchange/main.cpp
Index: test-suite/trunk/MicroBenchmarks/CMakeLists.txt
===================================================================
--- test-suite/trunk/MicroBenchmarks/CMakeLists.txt
+++ test-suite/trunk/MicroBenchmarks/CMakeLists.txt
@@ -5,4 +5,4 @@
add_subdirectory(LCALS)
add_subdirectory(harris)
add_subdirectory(ImageProcessing)
-
+add_subdirectory(LoopInterchange)
Index: test-suite/trunk/MicroBenchmarks/LoopInterchange/LoopInterchange.reference_output
===================================================================
--- test-suite/trunk/MicroBenchmarks/LoopInterchange/LoopInterchange.reference_output
+++ test-suite/trunk/MicroBenchmarks/LoopInterchange/LoopInterchange.reference_output
@@ -0,0 +1 @@
+test1: 1572352
Index: test-suite/trunk/MicroBenchmarks/LoopInterchange/CMakeLists.txt
===================================================================
--- test-suite/trunk/MicroBenchmarks/LoopInterchange/CMakeLists.txt
+++ test-suite/trunk/MicroBenchmarks/LoopInterchange/CMakeLists.txt
@@ -0,0 +1,9 @@
+llvm_test_run(WORKDIR ${CMAKE_CURRENT_BINARY_DIR})
+
+llvm_test_verify(WORKDIR ${CMAKE_CURRENT_BINARY_DIR}
+ ${FPCMP} LoopInterchange.reference_output LoopInterchange.txt
+)
+llvm_test_executable(LoopInterchange main.cpp)
+llvm_test_data(LoopInterchange LoopInterchange.reference_output)
+
+target_link_libraries(LoopInterchange benchmark)
Index: test-suite/trunk/MicroBenchmarks/LoopInterchange/main.cpp
===================================================================
--- test-suite/trunk/MicroBenchmarks/LoopInterchange/main.cpp
+++ test-suite/trunk/MicroBenchmarks/LoopInterchange/main.cpp
@@ -0,0 +1,54 @@
+#include <iostream>
+#include <cstdlib>
+#include <fstream>
+
+#include "benchmark/benchmark.h"
+
+
+#define N 1024
+unsigned A[N][N];
+
+void init() {
+ for (unsigned i = 0; i < N; i++)
+ for (unsigned j = 0; j < N; j++)
+ A[i][j] = i + j;
+}
+
+unsigned y = 0;
+
+static unsigned test1() {
+ for (unsigned i = 0; i < N; i++) {
+ y = 0;
+ for (unsigned j = 0; j < N; j++) {
+ A[i][j] += 1;
+ y += A[i][j];
+ }
+ }
+ return y;
+}
+
+int main(int argc, char *argv[]) {
+ benchmark::Initialize(&argc, argv);
+
+ init();
+
+ // Run kernels once, to test functionality.
+ std::ofstream myfile ("LoopInterchange.txt");
+ if (myfile.is_open()) {
+ unsigned y = test1();
+ myfile << "test1: " << y << "\n";
+ myfile.close();
+ } else
+ return EXIT_FAILURE;
+
+ benchmark::RunSpecifiedBenchmarks();
+ return EXIT_SUCCESS;
+}
+
+void BENCHMARK_LI1(benchmark::State &state) {
+ unsigned x = 0;
+ for (auto _ : state)
+ benchmark::DoNotOptimize(x += test1());
+}
+
+BENCHMARK(BENCHMARK_LI1)->Unit(benchmark::kMicrosecond);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53030.175644.patch
Type: text/x-patch
Size: 2705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181128/4fbdf6d5/attachment.bin>
More information about the llvm-commits
mailing list