(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
teams-2.c
       1  #include <omp.h>
       2  #include <stdlib.h>
       3  
       4  int
       5  foo ()
       6  {
       7    return 934;
       8  }
       9  
      10  int
      11  main ()
      12  {
      13    int a[934] = {};
      14    int k, e;
      15    #pragma omp target map(a)
      16    #pragma omp teams num_teams (foo ())
      17    {
      18      int i = omp_get_team_num ();
      19      if (omp_get_num_teams () != 934
      20  	|| (unsigned) i >= 934U
      21  	|| a[i] != 0)
      22        abort ();
      23      ++a[i];
      24    }
      25    #pragma omp target map(a)
      26    #pragma omp teams num_teams (foo () - 50 : foo ())
      27    {
      28      int i = omp_get_team_num ();
      29      int j = omp_get_num_teams ();
      30      if (j < 884
      31  	|| j > 934
      32  	|| (unsigned) i >= (unsigned) j
      33  	|| a[i] != 1)
      34        abort ();
      35      ++a[i];
      36    }
      37    #pragma omp target teams map(a) num_teams (foo () / 2)
      38    {
      39      int i = omp_get_team_num ();
      40      if (omp_get_num_teams () != 467
      41  	|| (unsigned) i >= 467U
      42  	|| a[i] != 2)
      43        abort ();
      44      ++a[i];
      45    }
      46    #pragma omp target teams map(a) num_teams (foo () / 2 - 50 : foo () / 2)
      47    {
      48      int i = omp_get_team_num ();
      49      int j = omp_get_num_teams ();
      50      if (j < 417
      51  	|| j > 467
      52  	|| (unsigned) i >= (unsigned) j
      53  	|| a[i] != 3)
      54        abort ();
      55      ++a[i];
      56    }
      57    e = 4;
      58    for (k = 0; k < 934; k++)
      59      {
      60        if (k >= 417 && k < 467 && a[k] == 3)
      61  	e = 3;
      62        else if (k == 467)
      63  	e = 2;
      64        else if (k >= 884 && a[k] == 1)
      65  	e = 1;
      66        if (a[k] != e)
      67  	abort ();
      68      }
      69    return 0;
      70  }