[Openmp-commits] [PATCH] D110811: [OpenMP][OMPT] Unnecessary execution of the while loop inside __ompt_get_task_info_internal
Vladimir Inđić via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Sep 30 04:09:19 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 now recognizes if the task at the
requested ancestor_level doesn’t exist. This is done by recognizing
whether all tasks have been exhausted (“taskdata” doesn’t exist) during
the iteration over the hierarchy of active tasks. If so, there’s no need
to continue executing the while loop. Break the loop and return 0 code
instead.
This patch prevents the SEGFAULT that may arise if the the loop unnecessarily
continues instead (the code before the patch). Assume that the
__ompt_get_task_info_internal is called with the argument “ancestor_level == 2”,
while the initial master thread is executing the initial task.
After the while loop finishes, both “prev_lwt” and “prev_team” are equal to NULL.
If the called function should determine the “thread_num”, it will do that by
executing the assignment “*thread_num = prev_team->t.t_master_tid”.
Since “prev_team” is NULL, dereferencing it leads to a SEGFAULT.
Also, this patch may be considered as a simple performance optimization.
Assume that the hierarchy of active tasks contains two tasks.
If the __ompt_get_task_info_internal is called with the argument
“ancestor_level==1000”, there’s no need to execute more that two iterations
of the while before detecting that the task at the requested “ancestor_level”
doesn’t exist.
This patch provides the simple test cases that validates the behaviour of
the __ompt_get_task_info_internal function in case when the task doesn’t exist
at the requested “ancestor_level”.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110811
Files:
openmp/runtime/src/ompt-specific.cpp
openmp/runtime/test/ompt/taskinfo/no_task.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110811.376154.patch
Type: text/x-patch
Size: 4193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210930/d8f9240e/attachment.bin>
More information about the Openmp-commits
mailing list