- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tbb::this_thread::get_id()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanx !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a specific reason for using core id rather than thread id?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page