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/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/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/main.cpp =================================================================== --- test-suite/trunk/MicroBenchmarks/LoopInterchange/main.cpp +++ test-suite/trunk/MicroBenchmarks/LoopInterchange/main.cpp @@ -0,0 +1,54 @@ +#include +#include +#include + +#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);