LLVM OpenMP 20.0.0git
kmp_taskwait_depend_in.c
Go to the documentation of this file.
1// RUN: %libomp-compile-and-run
2
3// test checks IN dep kind in depend clause on taskwait construct
4// uses codegen emulation
5#include <stdio.h>
6#include <omp.h>
7// ---------------------------------------------------------------------------
8// internal data to emulate compiler codegen
9typedef struct DEP {
10 size_t addr;
11 size_t len;
12 unsigned char flags;
14typedef struct ID {
15 int reserved_1;
16 int flags;
17 int reserved_2;
18 int reserved_3;
19 char *psource;
21
22#ifdef __cplusplus
23extern "C" {
24#endif
26extern void __kmpc_omp_wait_deps(_id *, int, int, _dep *, int, _dep *);
27#ifdef __cplusplus
28} // extern "C"
29#endif
30
31int main()
32{
33 int i1,i2,i3;
35 printf("addresses: %p %p %p\n", &i1, &i2, &i3);
36 #pragma omp parallel
37 {
38 int t = omp_get_thread_num();
39 printf("thread %d enters parallel\n", t);
40 #pragma omp single
41 {
42 #pragma omp task depend(in: i3)
43 {
44 int th = omp_get_thread_num();
45 printf("task 0 created by th %d, executed by th %d\n", t, th);
46 }
47 #pragma omp task depend(in: i2)
48 {
49 int th = omp_get_thread_num();
50 printf("task 1 created by th %d, executed by th %d\n", t, th);
51 }
52// #pragma omp taskwait depend(in: i1, i2)
53 {
54 _dep sdep[2];
55 static _id loc = {0, 2, 0, 0, ";test9.c;func;60;0;;"};
56 int gtid = __kmpc_global_thread_num(&loc);
57 sdep[0].addr = (size_t)&i2;
58 sdep[0].flags = 1; // 1-in, 2-out, 3-inout, 4-mtx, 8-inoutset
59 sdep[1].addr = (size_t)&i1;
60 sdep[1].flags = 1; // in
61 __kmpc_omp_wait_deps(&loc, gtid, 2, sdep, 0, NULL);
62 }
63 printf("single done\n");
64 }
65 }
66 printf("passed\n");
67 return 0;
68}
#define omp_set_num_threads
Definition: kmp_stub.cpp:34
int __kmpc_global_thread_num(_id *)
void __kmpc_omp_wait_deps(_id *, int, int, _dep *, int, _dep *)
struct DEP _dep
struct ID _id
int main()
static id loc
size_t len
unsigned char flags
size_t addr
int reserved_2
char * psource
int reserved_3
int reserved_1