| 94 | |
| 95 | template <bool output_timestamps> |
| 96 | void OpenCLClock<output_timestamps>::test_start() |
| 97 | { |
| 98 | // Start intercepting enqueues: |
| 99 | ARM_COMPUTE_ERROR_ON(_real_function != nullptr); |
| 100 | _real_function = CLSymbols::get().clEnqueueNDRangeKernel_ptr; |
| 101 | auto interceptor = [this](cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *gwo, |
| 102 | const size_t *gws, const size_t *lws, cl_uint num_events_in_wait_list, |
| 103 | const cl_event *event_wait_list, cl_event *event) |
| 104 | { |
| 105 | if (this->_timer_enabled) |
| 106 | { |
| 107 | kernel_info info; |
| 108 | cl::Kernel cpp_kernel(kernel, true); |
| 109 | std::stringstream ss; |
| 110 | ss << this->_prefix << cpp_kernel.getInfo<CL_KERNEL_FUNCTION_NAME>(); |
| 111 | if (gws != nullptr) |
| 112 | { |
| 113 | ss << " GWS[" << gws[0] << "," << gws[1] << "," << gws[2] << "]"; |
| 114 | } |
| 115 | if (lws != nullptr) |
| 116 | { |
| 117 | ss << " LWS[" << lws[0] << "," << lws[1] << "," << lws[2] << "]"; |
| 118 | } |
| 119 | info.name = ss.str(); |
| 120 | cl_event tmp; |
| 121 | cl_int retval = this->_real_function(command_queue, kernel, work_dim, gwo, gws, lws, |
| 122 | num_events_in_wait_list, event_wait_list, &tmp); |
| 123 | info.event = tmp; |
| 124 | this->_kernels.push_back(std::move(info)); |
| 125 | |
| 126 | if (event != nullptr) |
| 127 | { |
| 128 | //return cl_event from the intercepted call |
| 129 | clRetainEvent(tmp); |
| 130 | *event = tmp; |
| 131 | } |
| 132 | return retval; |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | return this->_real_function(command_queue, kernel, work_dim, gwo, gws, lws, num_events_in_wait_list, |
| 137 | event_wait_list, event); |
| 138 | } |
| 139 | }; |
| 140 | CLSymbols::get().clEnqueueNDRangeKernel_ptr = interceptor; |
| 141 | |
| 142 | #ifdef ARM_COMPUTE_GRAPH_ENABLED |
| 143 | ARM_COMPUTE_ERROR_ON(_real_graph_function != nullptr); |
| 144 | _real_graph_function = graph::TaskExecutor::get().execute_function; |
| 145 | // Start intercepting tasks: |
| 146 | auto task_interceptor = [this](graph::ExecutionTask &task) |
| 147 | { |
| 148 | if (task.node != nullptr && !task.node->name().empty()) |
| 149 | { |
| 150 | this->_prefix = task.node->name() + "/"; |
| 151 | } |
| 152 | else |
| 153 | { |
nothing calls this directly
no test coverage detected