(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
order-reproducible-1.c
       1  #include <unistd.h>
       2  #include <stdlib.h>
       3  
       4  int
       5  main ()
       6  {
       7    int a[128];
       8    #pragma omp teams num_teams(5)
       9    {
      10      #pragma omp loop bind(teams)
      11      for (int i = 0; i < 128; i++)
      12        {
      13  	a[i] = i;
      14  	if (i == 0)
      15  	  usleep (20);
      16  	else if (i == 17)
      17  	  usleep (40);
      18        }
      19      #pragma omp loop bind(teams)
      20      for (int i = 0; i < 128; i++)
      21        a[i] += i;
      22    }
      23    for (int i = 0; i < 128; i++)
      24      if (a[i] != 2 * i)
      25        abort ();
      26    #pragma omp teams num_teams(5)
      27    {
      28      #pragma omp loop bind(teams) order(concurrent)
      29      for (int i = 0; i < 128; i++)
      30        {
      31  	a[i] *= 2;
      32  	if (i == 1)
      33  	  usleep (20);
      34  	else if (i == 13)
      35  	  usleep (40);
      36        }
      37      #pragma omp loop bind(teams) order(concurrent)
      38      for (int i = 0; i < 128; i++)
      39        a[i] += i;
      40    }
      41    for (int i = 0; i < 128; i++)
      42      if (a[i] != 5 * i)
      43        abort ();
      44    #pragma omp teams num_teams(5)
      45    {
      46      #pragma omp loop bind(teams) order(reproducible:concurrent)
      47      for (int i = 0; i < 128; i++)
      48        {
      49  	a[i] *= 2;
      50  	if (i == 2)
      51  	  usleep (20);
      52  	else if (i == 105)
      53  	  usleep (40);
      54        }
      55      #pragma omp loop bind(teams) order(reproducible:concurrent)
      56      for (int i = 0; i < 128; i++)
      57        a[i] += i;
      58    }
      59    for (int i = 0; i < 128; i++)
      60      if (a[i] != 11 * i)
      61        abort ();
      62    return 0;
      63  }