Page MenuHomePhabricator

[OpenMP][OMPT] thread_num determination for programs with explicit tasks
ClosedPublic

Authored by vladaindjic on Sep 25 2021, 4:52 AM.

Details

Summary

__ompt_get_task_info_internal is now able to determine the right value of the
“thread_num” argument during the execution of an explicit task.

During the execution of a while loop that iterates over the ancestor tasks hierarchy,
the “prev_team” variable was always set to “team” variable at the beginning of each
loop iteration.

Assume that the program contains a parallel region which encloses an explicit task
executed by the worker thread of the region. Also assume that the tool inquires
the “thread_num” of a worker thread for the implicit task that corresponds to the
region (task at “ancestor_level == 1”) and expects to receive the value of “thread_num > 0”.
After the loop finishes, both “team” and “prev_team” variables are equal and point
to the team information of the parallel region.
The “thread_num” is set to “prev_team->t.t_master_tid”, that is equal to “team->t.t_master_tid”.
In this case, “team->t.t_master_tid” is 0, since the master thread of the region is the
initial master thread of the program. This leads to a contradiction.

To prevent this, “prev_team” variable is set to “team” variable only at the time when the loop
that has already encountered the implicit task (“taskdata” variable contains the information
about an implicit task) continues iterating over the implicit task’s ancestors, if any.

After the mentioned loop finishes, the “prev_team” variable might be equal to NULL.
This means that the task at requested “ancestor_level” belongs to the innermost parallel region,
so the “thread_num” will be determined by calling the “__kmp_get_tid”.

To prove that this patch works, the test case “explicit_task_thread_num.c” is provided.
It contains the example of the program explained earlier in the summary.

Diff Detail

Event Timeline

vladaindjic created this revision.Sep 25 2021, 4:52 AM
vladaindjic requested review of this revision.Sep 25 2021, 4:52 AM
Herald added a project: Restricted Project. · View Herald Transcript
This revision is now accepted and ready to land.Oct 18 2021, 2:36 AM

@protze.joachim Thank you very much for reviewing. Could you please land this patch for me?