Files
triton/bench/overhead.cpp

44 lines
1.3 KiB
C++
Raw Normal View History

#include "atidlas/array.h"
#include "atidlas/tools/timer.hpp"
#include <vector>
namespace ad = atidlas;
int main()
{
2015-01-27 16:14:02 -05:00
for(ad::cl_ext::queues_t::iterator it = ad::cl_ext::queues.begin() ; it != ad::cl_ext::queues.end() ; ++it)
2015-01-19 14:40:13 -05:00
{
ad::array x(10, ad::FLOAT_TYPE, it->first);
2015-01-27 16:14:02 -05:00
cl::Device device = it->second[0].getInfo<CL_QUEUE_DEVICE>();
2015-01-19 14:40:13 -05:00
ad::tools::timer t;
std::cout << "Device: " << device.getInfo<CL_DEVICE_NAME>() << std::endl;
std::cout << "-------------------------" << std::endl;
x = x + x;
2015-01-27 16:14:02 -05:00
ad::cl_ext::synchronize(x.context());
2015-01-19 14:40:13 -05:00
t.start();\
for(unsigned int i = 0 ; i < 100 ; ++i){
x = x + x;
2015-01-27 16:14:02 -05:00
ad::cl_ext::synchronize(x.context());
2015-01-19 14:40:13 -05:00
}
std::cout << "Kernel launch overhead: " << t.get()/100 << 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 + x, "2 terms");
BENCH(x + x + x, "3 terms");
BENCH(x + x + x + x, "4 terms");
BENCH(x + x + x + x + x, "5 terms");
#undef BENCH
std::cout << "-------------------------" << std::endl;
}
}