Added benchmark for expression tree creation

This commit is contained in:
Philippe Tillet
2015-01-18 17:12:09 -05:00
parent edaa821d93
commit ad05dea33f
2 changed files with 29 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ set(CMAKE_BUILD_TYPE Release)
find_package(CUDA)
foreach(PROG blas)
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")

27
bench/overhead.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "atidlas/array.h"
#include "atidlas/tools/timer.hpp"
#include <vector>
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<int> 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;
}