11 #include <boost/core/ignore_unused.hpp> 24 auto interceptor = [
this]( cl_command_queue command_queue,
30 cl_uint num_events_in_wait_list,
31 const cl_event * event_wait_list,
34 boost::ignore_unused(event);
38 cl::Kernel retainedKernel(kernel,
true);
40 ss << retainedKernel.getInfo<CL_KERNEL_FUNCTION_NAME>();
45 ss <<
" GWS[" << gws[0] <<
"," << gws[1] <<
"," << gws[2] <<
"]";
49 ss <<
" LWS[" << lws[0] <<
"," << lws[1] <<
"," << lws[2] <<
"]";
55 retVal = m_OriginalEnqueueFunction( command_queue,
61 num_events_in_wait_list,
66 m_Kernels.emplace_back(ss.str(), customEvent);
71 m_OriginalEnqueueFunction = CLSymbols::get().clEnqueueNDRangeKernel_ptr;
72 CLSymbols::get().clEnqueueNDRangeKernel_ptr = interceptor;
77 CLSymbols::get().clEnqueueNDRangeKernel_ptr = m_OriginalEnqueueFunction;
82 std::vector<Measurement> measurements;
84 cl_command_queue_properties clQueueProperties = CLScheduler::get().queue().getInfo<CL_QUEUE_PROPERTIES>();
87 for (
auto& kernel : m_Kernels)
89 std::string name = std::string(this->
GetName()) +
"/" + std::to_string(idx++) +
": " + kernel.m_Name;
92 if((clQueueProperties & CL_QUEUE_PROFILING_ENABLE) != 0)
95 kernel.m_Event.wait();
97 cl_ulong start = kernel.m_Event.getProfilingInfo<CL_PROFILING_COMMAND_START>();
98 cl_ulong end = kernel.m_Event.getProfilingInfo<CL_PROFILING_COMMAND_END>();
99 timeUs =
static_cast<double>(end - start) / 1000.0;
102 measurements.emplace_back(name, timeUs, Measurement::Unit::TIME_US);
void Stop() override
Stop the OpenCl timer.
const char * GetName() const override
std::vector< Measurement > GetMeasurements() const override
void Start() override
Start the OpenCl timer.