MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / worker_thread

Method worker_thread

src/runtime/CPP/CPPScheduler.cpp:254–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254void Thread::worker_thread()
255{
256 set_thread_affinity(_core_pin);
257
258 while (true)
259 {
260 std::unique_lock<std::mutex> lock(_m);
261 _cv.wait(lock, [&] { return _wait_for_work; });
262 _wait_for_work = false;
263
264 _current_exception = nullptr;
265
266 // Exit if the worker thread has not been fed with workloads
267 if (_workloads == nullptr || _feeder == nullptr)
268 {
269 return;
270 }
271
272 // Wake up more peer threads from thread pool if this job has been delegated to the current thread
273 if (_thread_pool != nullptr)
274 {
275 auto thread_it = _thread_pool->begin();
276 std::advance(thread_it, std::min(static_cast<unsigned int>(_thread_pool->size()), _wake_beg));
277 auto wake_end = std::min(_wake_end, static_cast<unsigned int>(_info.num_threads - 1));
278 for (unsigned int t = _wake_beg; t < wake_end; ++t, ++thread_it)
279 {
280 thread_it->start();
281 }
282 }
283
284#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
285 try
286 {
287#endif /* ARM_COMPUTE_EXCEPTIONS_ENABLED */
288 process_workloads(*_workloads, *_feeder, _info);
289
290#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
291 }
292 catch (...)
293 {
294 _current_exception = std::current_exception();
295 }
296#endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
297 _workloads = nullptr;
298 _job_complete = true;
299 lock.unlock();
300 _cv.notify_one();
301 }
302}
303} //namespace
304
305struct CPPScheduler::Impl final

Callers

nothing calls this directly

Calls 8

set_thread_affinityFunction · 0.85
advanceFunction · 0.85
process_workloadsFunction · 0.85
waitMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
startMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected