[all-commits] [llvm/llvm-project] 9d6427: [OpenMP] Added the support for hidden helper task ...

Shilei Tian via All-commits all-commits at lists.llvm.org
Mon Jan 25 19:21:06 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9d64275ae08fbdeeca0ce9c2f3951a2de6f38a08
      https://github.com/llvm/llvm-project/commit/9d64275ae08fbdeeca0ce9c2f3951a2de6f38a08
  Author: Shilei Tian <tianshilei1992 at gmail.com>
  Date:   2021-01-25 (Mon, 25 Jan 2021)

  Changed paths:
    M openmp/runtime/src/kmp.h
    M openmp/runtime/src/kmp_global.cpp
    M openmp/runtime/src/kmp_runtime.cpp
    M openmp/runtime/src/kmp_settings.cpp
    M openmp/runtime/src/kmp_taskdeps.cpp
    M openmp/runtime/src/kmp_taskdeps.h
    M openmp/runtime/src/kmp_tasking.cpp
    M openmp/runtime/src/kmp_wait_release.h
    M openmp/runtime/src/z_Linux_util.cpp
    M openmp/runtime/src/z_Windows_NT_util.cpp
    A openmp/runtime/test/tasking/hidden_helper_task/common.h
    A openmp/runtime/test/tasking/hidden_helper_task/depend.cpp
    A openmp/runtime/test/tasking/hidden_helper_task/gtid.cpp
    A openmp/runtime/test/tasking/hidden_helper_task/taskgroup.cpp
    M openmp/runtime/test/worksharing/for/kmp_sch_simd_guided.c

  Log Message:
  -----------
  [OpenMP] Added the support for hidden helper task in RTL

The basic design is to create an outer-most parallel team. It is not a regular team because it is only created when the first hidden helper task is encountered, and is only responsible for the execution of hidden helper tasks.  We first use `pthread_create` to create a new thread, let's call it the initial and also the main thread of the hidden helper team. This initial thread then initializes a new root, just like what RTL does in initialization. After that, it directly calls `__kmpc_fork_call`. It is like the initial thread encounters a parallel region. The wrapped function for this team is, for main thread, which is the initial thread that we create via `pthread_create` on Linux, waits on a condition variable. The condition variable can only be signaled when RTL is being destroyed. For other work threads, they just do nothing. The reason that main thread needs to wait there is, in current implementation, once the main thread finishes the wrapped function of this team, it starts to free the team which is not what we want.

Two environment variables, `LIBOMP_NUM_HIDDEN_HELPER_THREADS` and `LIBOMP_USE_HIDDEN_HELPER_TASK`, are also set to configure the number of threads and enable/disable this feature. By default, the number of hidden helper threads is 8.

Here are some open issues to be discussed:
1. The main thread goes to sleeping when the initialization is finished. As Andrey mentioned, we might need it to be awaken from time to time to do some stuffs. What kind of update/check should be put here?

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D77609




More information about the All-commits mailing list