mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
Timer in ProcessTask()
This commit is contained in:
parent
97623db219
commit
c835767115
@ -235,13 +235,14 @@ namespace ngcore
|
|||||||
const function<void(TaskInfo&)> * func;
|
const function<void(TaskInfo&)> * func;
|
||||||
int mynr;
|
int mynr;
|
||||||
int total;
|
int total;
|
||||||
|
int producing_thread;
|
||||||
atomic<int> * endcnt;
|
atomic<int> * endcnt;
|
||||||
|
|
||||||
TNestedTask () { ; }
|
TNestedTask () { ; }
|
||||||
TNestedTask (const function<void(TaskInfo&)> & _func,
|
TNestedTask (const function<void(TaskInfo&)> & _func,
|
||||||
int _mynr, int _total,
|
int _mynr, int _total,
|
||||||
atomic<int> & _endcnt)
|
atomic<int> & _endcnt, int prod_tid)
|
||||||
: func(&_func), mynr(_mynr), total(_total), endcnt(&_endcnt)
|
: func(&_func), mynr(_mynr), total(_total), endcnt(&_endcnt), producing_thread(prod_tid)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -260,12 +261,14 @@ namespace ngcore
|
|||||||
TPToken ptoken(taskqueue);
|
TPToken ptoken(taskqueue);
|
||||||
|
|
||||||
int num = endcnt;
|
int num = endcnt;
|
||||||
|
auto tid = TaskManager::GetThreadId();
|
||||||
for (int i = 0; i < num; i++)
|
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()
|
bool TaskManager :: ProcessTask()
|
||||||
{
|
{
|
||||||
|
static Timer t("process task");
|
||||||
TNestedTask task;
|
TNestedTask task;
|
||||||
TCToken ctoken(taskqueue);
|
TCToken ctoken(taskqueue);
|
||||||
|
|
||||||
@ -282,8 +285,14 @@ namespace ngcore
|
|||||||
cout << "process nested, nr = " << ti.task_nr << "/" << ti.ntasks << endl;
|
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.func)(ti);
|
||||||
--*task.endcnt;
|
--*task.endcnt;
|
||||||
|
|
||||||
|
if(trace && task.producing_thread != ti.thread_nr)
|
||||||
|
trace->StopTask (ti.thread_nr, t);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user