[Openmp-commits] [PATCH] D77609: [OpenMP] Added the support for hidden helper task in RTL

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Mar 17 17:17:54 PDT 2021


tianshilei1992 added a comment.

I find a stable way to reproduce the assertion. Let's say the default `__kmp_threads_capacity` is `N`. If hidden helper thread is enabled, `__kmp_threads_capacity` will be offset to `N+8` by default. If the number of threads we need exceeds `N+8`, e.g. via `num_threads` clause, we need to expand `__kmp_threads`. In `__kmp_expand_threads`, the expansion starts from `__kmp_threads_capacity`, and repeatedly doubling it until the new capacity meets the requirement. Let's assume the new requirement is `Y`.  If `Y` happens to meet the constraint `(N+8)*2^X=Y` where `X` is the number of iterations, then the new capacity is not enough because we have 8 slots for hidden helper threads.

  #include <vector>
  
  int main(int argc, char *argv[]) {
    constexpr const size_t N = 1344;
    std::vector<int> data(N);
  
  #pragma omp parallel for
    for (unsigned i = 0; i < N; ++i) {
      data[i] = i;
    }
  
  #pragma omp parallel for num_threads(N)
    for (unsigned i = 0; i < N; ++i) {
      data[i] += i;
    }
  
    return 0;
  }

Here is an example. My CPU is 20C40T, then `__kmp_threads_capacity` is 160. After offset, `__kmp_threads_capacity` becomes 168. `1344 = (160+8)*2^3`, and then the assertions hit.

I'll fix it right away.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77609/new/

https://reviews.llvm.org/D77609



More information about the Openmp-commits mailing list