| 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 |
| 9 |
typedef struct DEP { |
| 10 |
size_t addr; |
| 11 |
size_t len; |
| 12 |
unsigned char flags; |
| 13 |
} _dep; |
| 14 |
typedef struct ID { |
| 15 |
int reserved_1; |
| 16 |
int flags; |
| 17 |
int reserved_2; |
| 18 |
int reserved_3; |
| 19 |
char *psource; |
| 20 |
} _id; |
| 21 |
|
| 22 |
#ifdef __cplusplus |
| 23 |
extern "C" { |
| 24 |
#endif |
| 25 |
extern int __kmpc_global_thread_num(_id*); |
| 26 |
extern void __kmpc_omp_wait_deps(_id *, int, int, _dep *, int, _dep *); |
| 27 |
#ifdef __cplusplus |
| 28 |
} // extern "C" |
| 29 |
#endif |
| 30 |
|
| 31 |
int main() |
| 32 |
{ |
| 33 |
int i1,i2,i3; |
| 34 |
omp_set_num_threads(2); |
| 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 |
} |