| 212 | } |
| 213 | |
| 214 | void CLScheduler::flush_queue(bool flush) |
| 215 | { |
| 216 | ARM_COMPUTE_TRACE_EVENT_BEGIN(ARM_COMPUTE_PROF_CAT_SCHEDULER, ARM_COMPUTE_PROF_LVL_GPU, "CLScheduler::flush_queue"); |
| 217 | ARM_COMPUTE_TRACE_OPENCL_BEGIN(); |
| 218 | _enqueue_count++; |
| 219 | _flush_count += flush; |
| 220 | const float flush_ratio = _flush_count / (float)_enqueue_count; |
| 221 | |
| 222 | if (_enqueue_count > 100 && flush_ratio > 0.5f && _job_chaining_enabled) |
| 223 | { |
| 224 | ++_job_chaining_count; |
| 225 | |
| 226 | if (_job_chaining_count >= _job_chaining_size) |
| 227 | { |
| 228 | _job_chaining_count = 0; |
| 229 | /* |
| 230 | Optimisation note: Flush the queue at the first enqueue to start the GPU |
| 231 | execution and then incrementally saturate the clFlush calls to minimize |
| 232 | the CPU activity for job-scheduling. |
| 233 | For eg. job-chain size goes from 1, 2, 4, 8 and 16 |
| 234 | */ |
| 235 | if (_job_chaining_size < 16) |
| 236 | { |
| 237 | _job_chaining_size <<= 1; |
| 238 | } |
| 239 | _queue.flush(); |
| 240 | } |
| 241 | } |
| 242 | else if (flush) |
| 243 | { |
| 244 | _job_chaining_count = 0; |
| 245 | _queue.flush(); |
| 246 | } |
| 247 | ARM_COMPUTE_TRACE_EVENT_END(ARM_COMPUTE_PROF_CAT_SCHEDULER, ARM_COMPUTE_PROF_LVL_GPU); |
| 248 | } |
| 249 | |
| 250 | void CLScheduler::enqueue(ICLKernel &kernel, bool flush) |
| 251 | { |