(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c/
depend-5.c
       1  #include <stdlib.h>
       2  
       3  __attribute__((noinline, noclone)) void
       4  f1 (int ifval)
       5  {
       6    int x = 1, y = 2, z = 3;
       7    #pragma omp parallel
       8    #pragma omp single
       9    {
      10      #pragma omp task shared (x) depend(out: x)
      11      x = 2;
      12      #pragma omp task shared (x) depend(inout: x)
      13      {
      14        if (x != 2)
      15  	abort ();
      16        x = 3;
      17      }
      18      #pragma omp task shared (x) depend(inout: x)
      19      {
      20        if (x != 3)
      21  	abort ();
      22        x = 4;
      23      }
      24      #pragma omp task shared (z) depend(in: z)
      25      if (z != 3)
      26        abort ();
      27      #pragma omp task shared (z) depend(in: z)
      28      if (z != 3)
      29        abort ();
      30      #pragma omp task shared (z) depend(in: z)
      31      if (z != 3)
      32        abort ();
      33      #pragma omp task shared (z) depend(in: z)
      34      if (z != 3)
      35        abort ();
      36      #pragma omp task shared (z) depend(in: z)
      37      if (z != 3)
      38        abort ();
      39      #pragma omp task shared (z) depend(in: z)
      40      if (z != 3)
      41        abort ();
      42      #pragma omp task shared (y) depend(in: y)
      43      if (y != 2)
      44        abort ();
      45      #pragma omp task shared (y) depend(in: y)
      46      if (y != 2)
      47        abort ();
      48      #pragma omp task shared (y) depend(in: y)
      49      if (y != 2)
      50        abort ();
      51      #pragma omp task shared (y) depend(in: y)
      52      if (y != 2)
      53        abort ();
      54      #pragma omp task if (ifval) shared (x, y) depend(in: x) depend(inout: y)
      55      {
      56        if (x != 4 || y != 2)
      57  	abort ();
      58        y = 3;
      59      }
      60      if (ifval == 0)
      61        {
      62  	/* The above if (0) task should have waited till all
      63  	   the tasks with x and y dependencies finish.  */
      64  	if (x != 4 || y != 3)
      65  	  abort ();
      66  	x = 5;
      67  	y = 4;
      68        }
      69      #pragma omp task shared (z) depend(inout: z)
      70      {
      71        if (z != 3)
      72  	abort ();
      73        z = 4;
      74      }
      75      #pragma omp task shared (z) depend(inout: z)
      76      {
      77        if (z != 4)
      78  	abort ();
      79        z = 5;
      80      }
      81      #pragma omp taskwait
      82      if (x != (ifval ? 4 : 5) || y != (ifval ? 3 : 4) || z != 5)
      83        abort ();
      84      #pragma omp task if (ifval) shared (x, y) depend(in: x) depend(inout: y)
      85      {
      86        if (x != (ifval ? 4 : 5) || y != (ifval ? 3 : 4))
      87  	abort ();
      88      }
      89    }
      90  }
      91  
      92  int
      93  main ()
      94  {
      95    f1 (0);
      96    f1 (1);
      97    return 0;
      98  }