26 #include "../Framework.h" 32 #ifndef ARM_COMPUTE_CL 33 #error "You can't use OpenCLTimer without OpenCL" 48 : _kernels(), _real_function(nullptr), _real_graph_function(nullptr), _prefix(), _timer_enabled(false)
51 cl_command_queue_properties props = q.getInfo<CL_QUEUE_PROPERTIES>();
52 if((props & CL_QUEUE_PROFILING_ENABLE) == 0)
64 _scale_factor = 1000.f;
68 _scale_factor = 1000000.f;
72 _scale_factor = 1000000000.f;
87 auto interceptor = [
this](
88 cl_command_queue command_queue,
94 cl_uint num_events_in_wait_list,
95 const cl_event * event_wait_list,
98 if(this->_timer_enabled)
103 OpenCLTimer::kernel_info
info;
104 cl::Kernel cpp_kernel(kernel,
true);
105 std::stringstream ss;
106 ss << this->_prefix << cpp_kernel.getInfo<CL_KERNEL_FUNCTION_NAME>();
109 ss <<
" GWS[" << gws[0] <<
"," << gws[1] <<
"," << gws[2] <<
"]";
113 ss <<
" LWS[" << lws[0] <<
"," << lws[1] <<
"," << lws[2] <<
"]";
115 info.name = ss.str();
117 cl_int retval = this->_real_function(command_queue, kernel, work_dim, gwo, gws, lws, num_events_in_wait_list, event_wait_list, &tmp);
119 this->_kernels.push_back(std::move(info));
124 return this->_real_function(command_queue, kernel, work_dim, gwo, gws, lws, num_events_in_wait_list, event_wait_list, event);
131 if(task.node !=
nullptr && !task.node->name().empty())
133 this->_prefix = task.node->name() +
"/";
139 this->_real_graph_function(task);
150 _timer_enabled =
true;
154 _timer_enabled =
false;
162 _real_graph_function =
nullptr;
163 _real_function =
nullptr;
169 unsigned int kernel_number = 0;
170 for(
auto kernel : _kernels)
172 cl_ulong
start = kernel.event.getProfilingInfo<CL_PROFILING_COMMAND_START>();
173 cl_ulong end = kernel.event.getProfilingInfo<CL_PROFILING_COMMAND_END>();
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
static CLSymbols & get()
Get the static instance of CLSymbols.
void start() override
Start measuring.
std::string to_string(T &&value)
Convert integer and float values to string.
Generic measurement that stores values as either double or long long int.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
src info() -> set_format(Format::S16)
This file contains all available output stages for GEMMLowp on OpenCL.
std::string id() const override
Identifier for the instrument.
std::function< decltype(clEnqueueNDRangeKernel)> clEnqueueNDRangeKernel_ptr
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
static CLScheduler & get()
Access the scheduler singleton.
void set_queue(cl::CommandQueue queue)
Accessor to set the CL command queue to be used by the scheduler.
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
void test_stop() override
End of the test.
void stop() override
Stop measuring.
MeasurementsMap measurements() const override
Return the latest measurements.
void test_start() override
Start of the test.
std::map< std::string, Measurement > MeasurementsMap
Map of measurements.
static TaskExecutor & get()
Task executor accessor.
std::function< decltype(execute_task)> execute_function
Function that is responsible for executing tasks.
#define ARM_COMPUTE_ERROR_ON_MSG(cond,...)
OpenCLTimer(ScaleFactor scale_factor)
Construct an OpenCL timer.