Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Plagne__Laurent
Beginner
159 Views

Getting core ID during tbb program execution ?

Hi,

I would like to build an animation showing the // execution of a TBB kernel. I tought that It would be nice to use different colors in order to identify which core is doing what. For this purpose I would need the ID of the core that executes a given part of my programm (and dump it in an execution log file).

Is it possible in the TBB context ?

Laurent

 

 

 

0 Kudos
6 Replies
RafSchietekat
Black Belt
159 Views

tbb::this_thread::get_id()

Plagne__Laurent
Beginner
159 Views

Thanx !

RafSchietekat
Black Belt
159 Views

Sorry, that wasn't entirely the right answer. It will give you the thread id, and, as a task is always fully executed on one specific thread, that may well be enough for your purposes. But it is still different from what you were actually asking.

A thread may migrate across cores at the discretion of the operating system, even during the execution of a task. Knowing the exact core is probably not relevant, although you would be missing out on migration events. On a NUMA processor, the distance between cores might also be relevant.

Core id information is not available from TBB; you will have to consult your operating-system documentation, instead, e.g., on Linux it would be sched_getcpu(). This is for a synchronous query, and by the time the function returns the thread might already have migrated (not likely, but it's always possible). I'm not sure that thread migration notifications are available at all.

Plagne__Laurent
Beginner
159 Views

Thank you again !

I guess that the cost of the sched_getcpu() function must be much higher than tbb::this_thread::get_id().

I will try.

Counting the thread migration with "perf" tool maybe OK for my purpose.

RafSchietekat
Black Belt
159 Views

Is there a specific reason for using core id rather than thread id?

Plagne__Laurent
Beginner
159 Views

I want to understand the performance of a // algorithm  implemented with the TBBs (and compare this shared memory approach to an MPI implementation). For this purpose, It could be relevant to evaluate the cost of potential thread migrations. If this cost can be neglected, the thread IDs will be just fine.

Reply