[all-commits] [llvm/llvm-project] fea8c0: [Support][Parallel] Add sequential mode to TaskGro...

avl-llvm via All-commits all-commits at lists.llvm.org
Wed Apr 26 04:53:23 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fea8c073561f21ac0fea7f961287bf6b7dcf9f96
      https://github.com/llvm/llvm-project/commit/fea8c073561f21ac0fea7f961287bf6b7dcf9f96
  Author: Alexey Lapshin <a.v.lapshin at mail.ru>
  Date:   2023-04-26 (Wed, 26 Apr 2023)

  Changed paths:
    M lld/ELF/OutputSections.cpp
    M lld/ELF/Relocations.cpp
    M llvm/include/llvm/Support/Parallel.h
    M llvm/lib/Support/Parallel.cpp
    M llvm/unittests/Support/ParallelTest.cpp

  Log Message:
  -----------
  [Support][Parallel] Add sequential mode to TaskGroup::spawn().

This patch allows to specify that some part of tasks should be
done in sequential order. It makes it possible to not use
condition operator for separating sequential tasks:

TaskGroup tg;
for () {
  if(condition)      ==>   tg.spawn([](){fn();}, condition)
    fn();
  else
    tg.spawn([](){fn();});
}

It also prevents execution on main thread. Which allows adding
checks for getThreadIndex() function discussed in D142318.

The patch also replaces std::stack with std::deque in the
ThreadPoolExecutor to have natural execution order in case
(parallel::strategy.ThreadsRequested == 1).

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




More information about the All-commits mailing list