(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
task-reduction-13.c
       1  extern
       2  #ifdef __cplusplus
       3  "C"
       4  #endif
       5  void abort (void);
       6  #pragma omp declare reduction (foo: int: omp_out += omp_in - 1) initializer (omp_priv = 1)
       7  
       8  int
       9  main ()
      10  {
      11    int i, v = 0;
      12    unsigned long long j;
      13    volatile unsigned long long sixtyfour = 64;
      14    int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0;
      15    #pragma omp parallel
      16    {
      17  #define P(str) _Pragma (#str)
      18  #define ONE_ORDERED_LOOP(var, i, max, n, clauses...) \
      19      P (omp for ordered reduction (task, foo: var) clauses)		  \
      20      for (i = 0; i < max; i++)						  \
      21        {									  \
      22          var++;								  \
      23          P (omp task in_reduction (foo: var))				  \
      24  	var++;								  \
      25  	_Pragma ("omp ordered")						  \
      26  	if (v++ != i + n)						  \
      27  	  abort ();							  \
      28        }									  \
      29      if (var != 128 || v != 64 + n)					  \
      30        abort ();								  \
      31      _Pragma ("omp barrier")
      32      ONE_ORDERED_LOOP (a, i, 64, 0, )
      33      ONE_ORDERED_LOOP (b, i, 64, 64, schedule (monotonic: static))
      34      ONE_ORDERED_LOOP (c, i, 64, 128, schedule (static, 1))
      35      ONE_ORDERED_LOOP (d, i, 64, 192, schedule (monotonic: runtime))
      36      ONE_ORDERED_LOOP (e, i, 64, 256, schedule (dynamic, 2))
      37      ONE_ORDERED_LOOP (f, i, 64, 320, schedule (monotonic: guided, 3))
      38      ONE_ORDERED_LOOP (g, i, 64, 384, schedule (auto))
      39      #pragma omp single
      40      { v = 0; a = 0; b = 0; c = 0; d = 0; e = 0; f = 0; g = 0; }
      41      ONE_ORDERED_LOOP (a, j, sixtyfour, 0, )
      42      ONE_ORDERED_LOOP (b, j, sixtyfour, 64, schedule (static))
      43      ONE_ORDERED_LOOP (c, j, sixtyfour, 128, schedule (monotonic: static, 1))
      44      ONE_ORDERED_LOOP (d, j, sixtyfour, 192, schedule (runtime))
      45      ONE_ORDERED_LOOP (e, j, sixtyfour, 256, schedule (monotonic: dynamic, 2))
      46      ONE_ORDERED_LOOP (f, j, sixtyfour, 320, schedule (guided, 3))
      47      ONE_ORDERED_LOOP (g, j, sixtyfour, 384, schedule (monotonic: auto))
      48    }
      49    return 0;
      50  }