(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
task-reduction-12.c
       1  extern
       2  #ifdef __cplusplus
       3  "C"
       4  #endif
       5  void abort (void);
       6  int a, b[3] = { 1, 1, 1 };
       7  unsigned long int c[2] = { ~0UL, ~0UL };
       8  
       9  void
      10  bar (int i)
      11  {
      12    #pragma omp task in_reduction (*: b[:3]) in_reduction (&: c[1:]) \
      13  	      in_reduction (+: a)
      14    {
      15      a += 4;
      16      b[1] *= 4;
      17      c[1] &= ~(1UL << (i + 16));
      18    }
      19  }
      20  
      21  void
      22  foo (int x)
      23  {
      24    #pragma omp sections reduction (task, +: a) reduction (task, *: b) \
      25  		       reduction (task, &: c[1:1])
      26    {
      27      {
      28        a++; b[0] *= 2; bar (2); b[2] *= 3; c[1] &= ~(1UL << 2);
      29      }
      30      #pragma omp section
      31      { b[0] *= 2; bar (4); b[2] *= 3; c[1] &= ~(1UL << 4); a++; }
      32      #pragma omp section
      33      { bar (6); b[2] *= 3; c[1] &= ~(1UL << 6); a++; b[0] *= 2; }
      34      #pragma omp section
      35      { b[2] *= 3; c[1] &= ~(1UL << 8); a++; b[0] *= 2; bar (8); }
      36      #pragma omp section
      37      { c[1] &= ~(1UL << 10); a++; b[0] *= 2; bar (10); b[2] *= 3; }
      38      #pragma omp section
      39      { a++; b[0] *= 2; b[2] *= 3; c[1] &= ~(1UL << 12); bar (12); }
      40      #pragma omp section
      41      if (x)
      42        {
      43  	a++; b[0] *= 2; b[2] *= 3; bar (14); c[1] &= ~(1UL << 14);
      44        }
      45    }
      46  }
      47  
      48  int
      49  main ()
      50  {
      51    volatile int one = 1;
      52    foo (!one);
      53    if (a != 30 || b[0] != 64 || b[1] != (1 << 12) || b[2] != 3 * 3 * 3 * 3 * 3 * 3
      54        || c[0] != ~0UL || c[1] != ~0x15541554UL)
      55      abort ();
      56    a = 0;
      57    b[0] = 1;
      58    b[1] = 1;
      59    b[2] = 1;
      60    c[1] = ~0UL;
      61    #pragma omp parallel
      62    foo (one);
      63    if (a != 35 || b[0] != 128 || b[1] != (1 << 14) || b[2] != 3 * 3 * 3 * 3 * 3 * 3 * 3
      64        || c[0] != ~0UL || c[1] != ~0x55545554UL)
      65      abort ();
      66    return 0;
      67  }