[Openmp-commits] [PATCH] D110473: [OpenMP][OMPT] thread_num determination for programs with explicit tasks

Vladimir Inđić via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sat Sep 25 04:52:41 PDT 2021


vladaindjic created this revision.
vladaindjic added reviewers: protze.joachim, AndreyChurbanov, hbae.
Herald added subscribers: guansong, yaxunl.
vladaindjic requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

__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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110473

Files:
  openmp/runtime/src/ompt-specific.cpp
  openmp/runtime/test/ompt/tasks/explicit_task_thread_num.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110473.375027.patch
Type: text/x-patch
Size: 4092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210925/099a8a97/attachment.bin>


More information about the Openmp-commits mailing list