[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / tasking / kmp_task_deps_multiple_edges.c
blobe04ebf0f394000ae0f1ca5e4bb889fbffcf313ab
1 // REQUIRES: linux
2 // RUN: %libomp-compile && env OMP_NUM_THREADS='2' %libomp-run
4 #include <assert.h>
5 #include <omp.h>
7 #include "kmp_task_deps.h"
9 // the test
10 int main(void) {
11 volatile int done = 0;
13 #pragma omp parallel num_threads(2)
15 while (omp_get_thread_num() != 0 && !done)
18 #pragma omp single
20 kmp_task_t *A, *B;
21 kmp_depnode_list_t *A_succ;
22 kmp_base_depnode_t *B_node;
23 dep deps[2];
24 int gtid;
25 int x, y;
27 gtid = __kmpc_global_thread_num(&loc);
29 // A - out(x, y)
30 A = __kmpc_omp_task_alloc(&loc, gtid, TIED, sizeof(kmp_task_t), 0, NULL);
31 deps[0].addr = (size_t)&x;
32 deps[0].len = 0;
33 deps[0].flags = 2; // OUT
35 deps[1].addr = (size_t)&y;
36 deps[1].len = 0;
37 deps[1].flags = 2; // OUT
39 __kmpc_omp_task_with_deps(&loc, gtid, A, 2, deps, 0, 0);
41 // B - in(x, y)
42 B = __kmpc_omp_task_alloc(&loc, gtid, TIED, sizeof(kmp_task_t), 0, NULL);
43 deps[0].addr = (size_t)&x;
44 deps[0].len = 0;
45 deps[0].flags = 1; // IN
47 deps[1].addr = (size_t)&y;
48 deps[1].len = 0;
49 deps[1].flags = 1; // IN
51 __kmpc_omp_task_with_deps(&loc, gtid, B, 2, deps, 0, 0);
53 // Retrieve TDG nodes
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);
61 #pragma omp taskwait
63 done = 1;
66 return 0;