From c8357671152991d3f499908b659c60cce3bf7a85 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Fri, 11 Jun 2021 18:51:37 +0200 Subject: [PATCH] Timer in ProcessTask() --- libsrc/core/taskmanager.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libsrc/core/taskmanager.cpp b/libsrc/core/taskmanager.cpp index 9274fb97..60f24761 100644 --- a/libsrc/core/taskmanager.cpp +++ b/libsrc/core/taskmanager.cpp @@ -235,13 +235,14 @@ namespace ngcore const function * func; int mynr; int total; + int producing_thread; atomic * endcnt; TNestedTask () { ; } TNestedTask (const function & _func, int _mynr, int _total, - atomic & _endcnt) - : func(&_func), mynr(_mynr), total(_total), endcnt(&_endcnt) + atomic & _endcnt, int prod_tid) + : func(&_func), mynr(_mynr), total(_total), endcnt(&_endcnt), producing_thread(prod_tid) { ; } @@ -260,12 +261,14 @@ namespace ngcore TPToken ptoken(taskqueue); int num = endcnt; + auto tid = TaskManager::GetThreadId(); for (int i = 0; i < num; i++) - taskqueue.enqueue (ptoken, { afunc, i, num, endcnt }); + taskqueue.enqueue (ptoken, { afunc, i, num, endcnt, tid }); } bool TaskManager :: ProcessTask() { + static Timer t("process task"); TNestedTask task; TCToken ctoken(taskqueue); @@ -282,8 +285,14 @@ namespace ngcore cout << "process nested, nr = " << ti.task_nr << "/" << ti.ntasks << endl; } */ + if(trace && task.producing_thread != ti.thread_nr) + trace->StartTask (ti.thread_nr, t, PajeTrace::Task::ID_TIMER, task.producing_thread); + (*task.func)(ti); --*task.endcnt; + + if(trace && task.producing_thread != ti.thread_nr) + trace->StopTask (ti.thread_nr, t); return true; } return false;