Added benchmark for kernel launch

This commit is contained in:
Philippe Tillet
2015-01-19 08:47:18 -05:00
parent ad05dea33f
commit 225c7aac8f

View File

@@ -9,19 +9,30 @@ 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;\
}
// std::cout << "-------------------------" << std::endl;
// std::cout << "Expression tree creation:" << std::endl;
//#define BENCH(CREATE, STR) \
// {\
// ad::array_expression tmp1(CREATE);\
// t.start();\
// for(unsigned int i = 0 ; i < 1000 ; ++i)\
// ad::array_expression tmp2(CREATE);\
// std::cout << STR << ": " << t.get()/1000 << 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");
// 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");
//#undef BENCH
std::cout << "-------------------------" << std::endl;
x = y + z;
ad::cl::synchronize(x.context());
t.start();\
for(unsigned int i = 0 ; i < 100 ; ++i){
x = y + z;
ad::cl::synchronize(x.context());
}
std::cout << "Kernel launch overhead: " << t.get()/100 << std::endl;
}