Timer in ProcessTask()

This commit is contained in:
Matthias Hochsteger 2021-06-11 18:51:37 +02:00
parent 97623db219
commit c835767115

View File

@ -235,13 +235,14 @@ namespace ngcore
const function<void(TaskInfo&)> * func;
int mynr;
int total;
int producing_thread;
atomic<int> * endcnt;
TNestedTask () { ; }
TNestedTask (const function<void(TaskInfo&)> & _func,
int _mynr, int _total,
atomic<int> & _endcnt)
: func(&_func), mynr(_mynr), total(_total), endcnt(&_endcnt)
atomic<int> & _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;