<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 - teams construct in implicit parallel has incorrect number of threads/teams"
   href="https://bugs.llvm.org/show_bug.cgi?id=47419">47419</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>teams construct in implicit parallel has incorrect number of threads/teams
          </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>Runtime Library
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jacob.weightman@hpe.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following program:
```
#include <omp.h>
#include <stdio.h>

int main(void) {
    printf("num_teams = %d\n", omp_get_num_teams());
    printf("num_threads = %d\n", omp_get_num_threads());

    #pragma omp teams num_teams(4)
    {
        if(omp_get_team_num() == 0) {
            printf("num_teams = %d\n", omp_get_num_teams());
            printf("num_threads = %d\n", omp_get_num_threads());
        }
        printf("team: %d; thread: %d\n",
               omp_get_team_num(),
               omp_get_thread_num());
    }
}
```

At present, Clang prints out (up to the ordering of the print statements):
```
num_teams = 1
num_threads = 1
num_teams = 4
num_threads = 12
team: 0; thread: 0
team: 1; thread: 0
team: 2; thread: 0
team: 3; thread: 0
```

The OpenMP 5.0 spec (section 2.7) states that
<span class="quote">> The teams construct creates a league of initial teams and the initial thread in each team executes the region.</span >

and (section 3.2.2):
<span class="quote">> The omp_get_num_threads routine returns the number of threads in the current team.</span >

The latter print statements indicate that the num_teams clause is respected,
and there is 1 thread per team. Therefore, one should expect that
omp_get_num_threads should return 1 inside of the teams region.</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>