[all-commits] [llvm/llvm-project] 36d4e4: [OpenMP] Implement task record and replay mechanism

Jose Manuel Monsalve Diaz via All-commits all-commits at lists.llvm.org
Mon May 15 08:04:16 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 36d4e4c9b5f6cd0577b6029055b825caaec2dd11
      https://github.com/llvm/llvm-project/commit/36d4e4c9b5f6cd0577b6029055b825caaec2dd11
  Author: Chenle Yu <chenle.yu at bsc.es>
  Date:   2023-05-15 (Mon, 15 May 2023)

  Changed paths:
    M openmp/runtime/CMakeLists.txt
    M openmp/runtime/src/kmp.h
    M openmp/runtime/src/kmp_config.h.cmake
    M openmp/runtime/src/kmp_global.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/test/CMakeLists.txt
    M openmp/runtime/test/lit.cfg
    M openmp/runtime/test/lit.site.cfg.in
    A openmp/runtime/test/tasking/omp_record_replay.cpp
    A openmp/runtime/test/tasking/omp_record_replay_deps.cpp
    A openmp/runtime/test/tasking/omp_record_replay_multiTDGs.cpp
    A openmp/runtime/test/tasking/omp_record_replay_taskloop.cpp

  Log Message:
  -----------
  [OpenMP] Implement task record and replay mechanism

This patch implements the "task record and replay" mechanism.  The idea is to be able to store tasks and their dependencies in the runtime so that we do not pay the cost of task creation and dependency resolution for future executions. The objective is to improve fine-grained task performance, both for those from "omp task" and "taskloop".

The entry point of the recording phase is __kmpc_start_record_task, and the end of record is triggered by __kmpc_end_record_task.

Tasks encapsulated between a record start and a record end are saved, meaning that the runtime stores their dependencies and structures, referred to as TDG, in order to replay them in subsequent executions. In these TDG replays, we start the execution by scheduling all root tasks (tasks that do not have input dependencies), and there will be no involvement of a hash table to track the dependencies, yet tasks do not need to be created again.

At the beginning of __kmpc_start_record_task, we must check if a TDG has already been recorded. If yes, the function returns 0 and starts to replay the TDG by calling __kmp_exec_tdg; if not, we start to record, and the function returns 1.

An integer uniquely identifies TDGs. Currently, this identifier needs to be incremented manually in the source code. Still, depending on how this feature would eventually be used in the library, the caller function must do it; also, the caller function needs to implement a mechanism to skip the associated region, according to the return value of __kmpc_start_record_task.

Reviewed By: tianshilei1992

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




More information about the All-commits mailing list