diff options
author | Florian Hahn <florian.hahn@arm.com> | 2018-11-28 10:46:17 +0000 |
---|---|---|
committer | Florian Hahn <florian.hahn@arm.com> | 2018-11-28 10:46:17 +0000 |
commit | 8c55a4b286748bae08b5fcc795562705b4a1c11a (patch) | |
tree | 425039bf43f01a6c989b8ff1bbce01dab780c36b | |
parent | 1907cd0f10994d469d195e72a6aa858476d777f7 (diff) |
[MicroBenchmark] Add initial LoopInterchange test/benchmark.
This patch adds a first test case specifically for LoopInterchange. I am
not sure if MicroBenchmarks is the best place for this, but it seems
like a good way to benchmark/tests a set of loops targeted at loop
interchange.
Reviewers: Meinersbur, homerdin, proton0001, proton, MatzeB
Reviewed By: MatzeB
Differential Revision: https://reviews.llvm.org/D53030
git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@347740 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | MicroBenchmarks/CMakeLists.txt | 2 | ||||
-rw-r--r-- | MicroBenchmarks/LoopInterchange/CMakeLists.txt | 9 | ||||
-rw-r--r-- | MicroBenchmarks/LoopInterchange/LoopInterchange.reference_output | 1 | ||||
-rw-r--r-- | MicroBenchmarks/LoopInterchange/main.cpp | 54 |
4 files changed, 65 insertions, 1 deletions
diff --git a/MicroBenchmarks/CMakeLists.txt b/MicroBenchmarks/CMakeLists.txt index bafa5de4..77a8e897 100644 --- a/MicroBenchmarks/CMakeLists.txt +++ b/MicroBenchmarks/CMakeLists.txt @@ -5,4 +5,4 @@ add_subdirectory(XRay) add_subdirectory(LCALS) add_subdirectory(harris) add_subdirectory(ImageProcessing) - +add_subdirectory(LoopInterchange) diff --git a/MicroBenchmarks/LoopInterchange/CMakeLists.txt b/MicroBenchmarks/LoopInterchange/CMakeLists.txt new file mode 100644 index 00000000..72e91f84 --- /dev/null +++ b/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) diff --git a/MicroBenchmarks/LoopInterchange/LoopInterchange.reference_output b/MicroBenchmarks/LoopInterchange/LoopInterchange.reference_output new file mode 100644 index 00000000..66a2d3c1 --- /dev/null +++ b/MicroBenchmarks/LoopInterchange/LoopInterchange.reference_output @@ -0,0 +1 @@ +test1: 1572352 diff --git a/MicroBenchmarks/LoopInterchange/main.cpp b/MicroBenchmarks/LoopInterchange/main.cpp new file mode 100644 index 00000000..2f7bad8e --- /dev/null +++ b/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); |