Files
triton/bench/overhead.cpp

57 lines
1.5 KiB
C++
Raw Normal View History

#include "atidlas/array.h"
#include "atidlas/tools/timer.hpp"
#include <vector>
namespace ad = atidlas;
2015-02-03 15:20:33 -05:00
#ifdef BENCH_CUBLAS
__global__ void dummy(){}
#endif
int main()
{
for(ad::cl_ext::queues_type::data_type::const_iterator it = ad::cl_ext::queues.data().begin() ; it != ad::cl_ext::queues.data().end() ; ++it)
2015-01-19 14:40:13 -05:00
{
cl::CommandQueue queue = it->second[0];
cl::Context context = it->first;
2015-02-03 15:20:33 -05:00
cl::Device device = queue.getInfo<CL_QUEUE_DEVICE>();
2015-02-06 02:00:02 -05:00
cl::Program program(context,"__kernel void dummy(){}");
program.build();
2015-02-03 15:20:33 -05:00
cl::Kernel kernel(program, "dummy");
cl::NDRange offset = cl::NullRange;
cl::NDRange global(1);
cl::NDRange local(1);
cl::Event event;
2015-01-19 14:40:13 -05:00
std::cout << "Device: " << device.getInfo<CL_DEVICE_NAME>() << std::endl;
std::cout << "-------------------------" << std::endl;
2015-02-03 15:20:33 -05:00
queue.enqueueNDRangeKernel(kernel, offset, global, local, NULL, &event);
queue.flush();
queue.finish();
2015-02-06 02:00:02 -05:00
{
long time = event.getProfilingInfo<CL_PROFILING_COMMAND_END>() - event.getProfilingInfo<CL_PROFILING_COMMAND_START>();
2015-02-03 15:20:33 -05:00
std::cout << "Kernel launch overhead: " << time << std::endl;
2015-02-06 02:00:02 -05:00
}
2015-02-03 15:20:33 -05:00
#ifdef BENCH_CUBLAS
2015-02-06 02:00:02 -05:00
float time;
2015-02-03 15:20:33 -05:00
cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
cudaEventRecord(start);
2015-02-06 02:00:02 -05:00
dummy<<<1, 1>>>();
2015-02-03 15:20:33 -05:00
cudaEventRecord(stop);
2015-02-06 02:00:02 -05:00
cudaEventSynchronize(stop);
2015-02-03 15:20:33 -05:00
cudaEventElapsedTime(&time, start, stop);
std::cout << "CUDA Kernel launch overhead: " << time << std::endl;
#endif
2015-01-19 14:40:13 -05:00
std::cout << "-------------------------" << std::endl;
}
}