aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c-c++-common/depend-mutexinout-1.c
blob: 86322eddbcc6ecae7e57db43b6e62f1382adc71b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
int
main ()
{
  int a, b, c, d;
  #pragma omp parallel num_threads (6)
  #pragma omp single
  {
    #pragma omp task depend(out: c)
      c = 1;
    #pragma omp task depend(out: a)
      a = 2;
    #pragma omp task depend(out: b)
      b = 3;
    /* The above 3 tasks can be scheduled in any order.  */
    #pragma omp task depend(in: a) depend(mutexinoutset: c)
      c += a;
    #pragma omp task depend(in: b) depend(mutexinoutset: c)
      c += b;
    /* The above 2 tasks are mutually exclusive and need to wait
       for the first and second or first and third tasks respectively.  */
    #pragma omp task depend(in: c)
      d = c;
    /* The above task needs to wait for the mutexinoutset tasks.  */
  }
  if (d != 6)
    __builtin_abort ();
  return 0;
}