Software Archive
Read-only legacy content
17061 Discussions

Id of the spawning thread

Vitaly_A_
Beginner
255 Views
Hello.
In my code, I need to pass the information,hiding from the user, about running time and etc. to the processor which spawns from spawned evaluations. For that I need in processor to know, from what processor's deque he has stolen the task. Is this possible?
Regards,
Aksenov Vitaly
0 Kudos
1 Reply
Pablo_H_Intel
Employee
255 Views

In general, no.  However, if you have complete control, you can manage it two ways:

  1. If the source code doesn't contain too many spawns, you can record the worker ID before a spawn and then again after the spawn.  If they are different, then a steal occurred and the ID from before the spawn is the victim.  You can then do whatever bookkeeping you want.  Unfortunately, this approach doesn't work for cilk_for loops, which have hidden spawns.
  2. A more sophisticated but powerful technique is to modify the Cilk runtime library (which is open source). You can find the place in schedule.c where a steal is successful and you can add a little code to store the victim's worker ID (perhaps in thread-local storage).

-Pablo

0 Kudos
Reply