2 // RUN: %libomp-compile && env OMP_NUM_THREADS='2' %libomp-run
7 #include "kmp_task_deps.h"
11 volatile int done
= 0;
13 #pragma omp parallel num_threads(2)
15 while (omp_get_thread_num() != 0 && !done
)
21 kmp_depnode_list_t
*A_succ
;
22 kmp_base_depnode_t
*B_node
;
27 gtid
= __kmpc_global_thread_num(&loc
);
30 A
= __kmpc_omp_task_alloc(&loc
, gtid
, TIED
, sizeof(kmp_task_t
), 0, NULL
);
31 deps
[0].addr
= (size_t)&x
;
33 deps
[0].flags
= 2; // OUT
35 deps
[1].addr
= (size_t)&y
;
37 deps
[1].flags
= 2; // OUT
39 __kmpc_omp_task_with_deps(&loc
, gtid
, A
, 2, deps
, 0, 0);
42 B
= __kmpc_omp_task_alloc(&loc
, gtid
, TIED
, sizeof(kmp_task_t
), 0, NULL
);
43 deps
[0].addr
= (size_t)&x
;
45 deps
[0].flags
= 1; // IN
47 deps
[1].addr
= (size_t)&y
;
49 deps
[1].flags
= 1; // IN
51 __kmpc_omp_task_with_deps(&loc
, gtid
, B
, 2, deps
, 0, 0);
54 A_succ
= __kmpc_task_get_successors(A
);
55 B_node
= __kmpc_task_get_depnode(B
);
57 // 'B' should only be added once to 'A' successors list
58 assert(A_succ
->node
== B_node
);
59 assert(A_succ
->next
== NULL
);