From ad05dea33f7450c5fca5a677392e3f0a0eaa63d1 Mon Sep 17 00:00:00 2001 From: Philippe Tillet Date: Sun, 18 Jan 2015 17:12:09 -0500 Subject: [PATCH] Added benchmark for expression tree creation --- bench/CMakeLists.txt | 4 ++-- bench/overhead.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 bench/overhead.cpp diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt index e955c6f89..dc671a256 100644 --- a/bench/CMakeLists.txt +++ b/bench/CMakeLists.txt @@ -2,8 +2,8 @@ set(CMAKE_BUILD_TYPE Release) find_package(CUDA) -foreach(PROG blas) - add_executable(${PROG}-bench ${PROG}.cpp) +foreach(PROG blas overhead) + add_executable(${PROG}-bench ${PROG}.cpp) target_link_libraries(${PROG}-bench atidlas ${OPENCL_LIBRARIES}) set_target_properties(${PROG}-bench PROPERTIES COMPILE_FLAGS "-Wall -Wextra") diff --git a/bench/overhead.cpp b/bench/overhead.cpp new file mode 100644 index 000000000..23ffff4b8 --- /dev/null +++ b/bench/overhead.cpp @@ -0,0 +1,27 @@ +#include "atidlas/array.h" +#include "atidlas/tools/timer.hpp" + +#include + +namespace ad = atidlas; + +int main() +{ + ad::array x(10, ad::FLOAT_TYPE), y(10, ad::FLOAT_TYPE), z(10, ad::FLOAT_TYPE); + ad::tools::timer t; + std::cout << "-------------------------" << std::endl; + std::cout << "Expression tree creation:" << std::endl; +#define BENCH(CREATE, STR) \ + {\ + std::vector flusher(10000000, 1);\ + t.start();\ + ad::array_expression tmp(CREATE);\ + std::cout << STR << ": " << t.get() << std::endl;\ + } + + BENCH(x + y, "2 terms"); + BENCH(x + y + x, "3 terms"); + BENCH(x + y + x + y, "4 terms"); + BENCH(x + y + x + y + x, "5 terms"); + std::cout << "-------------------------" << std::endl; +}