<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - combined target teams implements shared clause as firstprivate"
   href="https://bugs.llvm.org/show_bug.cgi?id=40253">40253</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>combined target teams implements shared clause as firstprivate
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Clang Compiler Support
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jdenny.ornl@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>a.bataev@hotmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang implements `shared(n)` on `omp target teams` as firstprivate instead of
shared.  For example, n is not shared in the following example:

```
$ cat test.c
#include <omp.h>
#include <stdio.h>
int main() {
  int n = 0;
  #pragma omp target teams shared(n) num_teams(2)
  #pragma omp parallel num_threads(1)
  {
    #pragma omp atomic update
    ++n;
    printf("n=%d, team=%d\n", n, omp_get_team_num());
  }
  return 0;
}

$ clang -fopenmp test.c && ./a.out
n=1, team=0
n=1, team=1
```

However, if I split the `target teams` directive into two directives, I see
results indicating n is shared:

```
$ cat test.c
#include <omp.h>
#include <stdio.h>
int main() {
  int n = 0;
  #pragma omp target 
  #pragma omp teams shared(n) num_teams(2)
  #pragma omp parallel num_threads(1)
  {
    #pragma omp atomic update
    ++n;
    printf("n=%d, team=%d\n", n, omp_get_team_num());
  }
  return 0;
}

$ clang -fopenmp test.c && ./a.out
n=1, team=0
n=2, team=1
```

The LLVM IR shows that n is passed to the teams by value in the first case and
by pointer in the second.

This bugzilla was suggested at:

  <a href="https://reviews.llvm.org/D56113#1345047">https://reviews.llvm.org/D56113#1345047</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>