llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.85k stars 11.02k forks source link

[OpenMP] __kmp_init_implicit_task debug assert hit when using tasks #97548

Open mikaoP opened 1 week ago

mikaoP commented 1 week ago
#include <stdio.h>

#define MAX_N 25000

int main(int argc, char *argv[]) {
  for (int n = 0; n < 2; ++n) {
    for (int tms = 1 ; tms <= 2 ; tms *= 2) {
      for (int ths = 1 ; ths <= 1; ths *= 2) {
        fprintf(stderr, "n %d tms %d ths %d\n", n, tms, ths);
        #pragma omp teams num_teams(tms)
        {
          #pragma omp distribute parallel for num_threads(ths)
          for (int i = 0; i < MAX_N; ++i) {
            #pragma omp task
            {}
          }
          fprintf(stderr, "BARRIER\n");
          #pragma omp distribute parallel for num_threads(ths)
          for (int i = 0; i < MAX_N; ++i) {
            #pragma omp task
            {}
          }
        } // loop over 'ths'
      } // loop over 'tms'
    }
  }
  return 0;
}

clang -fopenmp t1.c -o t1 && ./t1 KMP_DEBUG_ASSERT(task->td_incomplete_child_tasks == 0);

I simplified this test from back2back_distribute.c in omptarget :)

llvmbot commented 1 week ago

@llvm/issue-subscribers-openmp

Author: None (mikaoP)

```cpp #include <stdio.h> #define MAX_N 25000 int main(int argc, char *argv[]) { for (int n = 0; n < 2; ++n) { for (int tms = 1 ; tms <= 2 ; tms *= 2) { for (int ths = 1 ; ths <= 1; ths *= 2) { fprintf(stderr, "n %d tms %d ths %d\n", n, tms, ths); #pragma omp teams num_teams(tms) { #pragma omp distribute parallel for num_threads(ths) for (int i = 0; i < MAX_N; ++i) { #pragma omp task {} } fprintf(stderr, "BARRIER\n"); #pragma omp distribute parallel for num_threads(ths) for (int i = 0; i < MAX_N; ++i) { #pragma omp task {} } } // loop over 'ths' } // loop over 'tms' } } return 0; } ``` `clang -fopenmp t1.c -o t1 && ./t1` `KMP_DEBUG_ASSERT(task->td_incomplete_child_tasks == 0);` I simplified this test from `back2back_distribute.c` in omptarget :)