1 // RUN: %libomp-compile-and-run
3 // test checks IN dep kind in depend clause on taskwait nowait
4 // uses codegen emulation
5 // Note: no outlined task routine used
8 // ---------------------------------------------------------------------------
9 // internal data to emulate compiler codegen
32 typedef int(*entry_t
)(int, task_t
*);
37 extern int __kmpc_global_thread_num(_id
*);
38 task_t
*__kmpc_omp_task_alloc(_id
*loc
, int gtid
, int flags
,
39 size_t sz
, size_t shar
, entry_t rtn
);
40 int __kmpc_omp_task_with_deps(_id
*loc
, int gtid
, task_t
*task
, int ndeps
,
41 _dep
*dep_lst
, int nd_noalias
, _dep
*noalias_l
);
49 omp_set_num_threads(2);
50 printf("addresses: %p %p %p\n", &i1
, &i2
, &i3
);
53 int t
= omp_get_thread_num();
54 printf("thread %d enters parallel\n", t
);
57 #pragma omp task depend(in: i3)
59 int th
= omp_get_thread_num();
60 printf("task 0 created by th %d, executed by th %d\n", t
, th
);
62 #pragma omp task depend(in: i2)
64 int th
= omp_get_thread_num();
65 printf("task 1 created by th %d, executed by th %d\n", t
, th
);
67 // #pragma omp taskwait depend(in: i1, i2) nowait
70 static _id loc
= {0, 2, 0, 0, ";test.c;func;67;0;;"};
71 int gtid
= __kmpc_global_thread_num(&loc
);
72 // instead of creating an empty task function we can now send NULL to runtime
73 task_t
*ptr
= __kmpc_omp_task_alloc(&loc
, gtid
, TIED
,
74 sizeof(task_t
), 0, NULL
);
75 sdep
[0].addr
= (size_t)&i2
;
76 sdep
[0].flags
= 1; // 1-in, 2-out, 3-inout, 4-mtx, 8-inoutset
77 sdep
[1].addr
= (size_t)&i1
;
78 sdep
[1].flags
= 1; // in
79 __kmpc_omp_task_with_deps(&loc
, gtid
, ptr
, 2, sdep
, 0, NULL
);
81 printf("single done\n");