69 lines · c
1// RUN: %libomp-compile-and-run2 3// test checks IN dep kind in depend clause on taskwait construct4// uses codegen emulation5#include <stdio.h>6#include <omp.h>7// ---------------------------------------------------------------------------8// internal data to emulate compiler codegen9typedef struct DEP {10 size_t addr;11 size_t len;12 unsigned char flags;13} _dep;14typedef 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 __cplusplus23extern "C" {24#endif25extern int __kmpc_global_thread_num(_id*);26extern void __kmpc_omp_wait_deps(_id *, int, int, _dep *, int, _dep *);27#ifdef __cplusplus28} // extern "C"29#endif30 31int 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 parallel37 {38 int t = omp_get_thread_num();39 printf("thread %d enters parallel\n", t);40 #pragma omp single41 {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-inoutset59 sdep[1].addr = (size_t)&i1;60 sdep[1].flags = 1; // in61 __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}69