aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c-c++-common/task-detach-3.c
blob: c85857de21c97de8ff0e6b05dc52f43be66544eb (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
29
30
31
32
33
/* { dg-do run } */

#include <omp.h>
#include <assert.h>

/* Test the task detach clause used together with dependencies.  */

int main (void)
{
  omp_event_handle_t detach_event;
  int x = 0, y = 0, z = 0;
  int dep;

  #pragma omp parallel
    #pragma omp single
    {
      #pragma omp task depend (out:dep) detach (detach_event)
	x++;

      #pragma omp task
      {
	y++;
	omp_fulfill_event (detach_event);
      }

      #pragma omp task depend (in:dep)
	z++;
    }

  assert (x == 1);
  assert (y == 1);
  assert (z == 1);
}