<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70744>70744</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [OpenMP] Host offload reduction in parallel regions hangs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            openmp,
            openmp:libomp
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jdoerfert
      </td>
    </tr>
</table>

<pre>
    A host offload reduction in an outer parallel regions seems to hang.
Here is the test:
```
#include <iostream>
#include <vector>

#define N 8

int main() {
  std::vector<int> avec(N);
  int *a = avec.data();
#pragma omp parallel for
  for (int i = 0; i < N; i++) {
    a[i] = 0;
#pragma omp target teams distribute parallel for reduction(+ : a[i])
    for (int j = 0; j < N; j++)
      a[i] += 1;
  }

  // CHECK: 8
  // CHECK: 8
  // CHECK: 8
  // CHECK: 8
  // CHECK: 8
  // CHECK: 8
  // CHECK: 8
  // CHECK: 8
  for (int i = 0; i < N; i++)
    std::cout << a[i] << std::endl;
}
```
Even with N=1 it hangs.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVE-PuzYQ_TTDZbQRsSEkBw75q5WqbvsVDB7AkbGRPaTqt68gu5BVt4cef5IlbM_zm-c3eFSMpnVEJeQnyC-JGrnzobxrT6GhwEnl9d_lETsfGX3TWK80BtJjzcY7NA6VQz8yBRxUUNaSxUCt8S5iJOojssdOuXYD6QXS4zsFQhORO0KmyCCPzwDs0s_xXAppXG1HTQjybHzkQKoHef0p_KCafViDXxBNjXGEH7h_DRjH2CvjQOxBHBCK03MfMbKe9MjjF-HZOAZ5RfWgGsT-A8QB5AKfiEAcFYK8zJCNVqyetAsMhByCanuFvh9WjxofvmgaHxDEfmIzM1UK8jRPz_gxT0Gc5vFNLKKC_GQgvyyHfsrIKrTEyKT6iNpEDqYamb4pWQs6iz8hyOPCPl1mSfmi9b5qva9a74vW9dCrUnGaTm1fXITi8lodRBA3EDc8v1_Pv01C9r9o4H_UdfVq-QVrP_IEndAvhZ7XC4ictmvdFyO_P6Xrgxz-Zbibsl62aHh-kHGT6FLqgzyohMrt7rAv0iLdFUlXZtu82m0rtc13qtkXOsuaPBP5Th6KJtdZnphSpEJuU5kKmWai2GghMymaiipd1weqIEupV8ZurH30Gx_axMQ4UlmkRZYlVlVk49xyhPADuX4AIUCc16U8WlP5535-SUI5Eb1VYxshS62JHFdqNmznBvbHQO73Pyej3v-zXf2rS81eJGOwZcc8xMnYuaKt4W6sNrXvQdymXJ-ftyH4O9UM4jbfKYK4zdf6JwAA___DC3R6">