diff --git a/openmp/runtime/src/kmp_gsupport.cpp b/openmp/runtime/src/kmp_gsupport.cpp --- a/openmp/runtime/src/kmp_gsupport.cpp +++ b/openmp/runtime/src/kmp_gsupport.cpp @@ -17,6 +17,12 @@ #include "ompt-specific.h" #endif +enum { + KMP_GOMP_TASK_UNTIED_FLAG = 1, + KMP_GOMP_TASK_FINAL_FLAG = 2, + KMP_GOMP_TASK_DEPENDS_FLAG = 8 +}; + // This class helps convert gomp dependency info into // kmp_depend_info_t structures class kmp_gomp_depends_info_t { @@ -1164,11 +1170,11 @@ KA_TRACE(20, ("GOMP_task: T#%d\n", gtid)); // The low-order bit is the "untied" flag - if (!(gomp_flags & 1)) { + if (!(gomp_flags & KMP_GOMP_TASK_UNTIED_FLAG)) { input_flags->tiedness = 1; } // The second low-order bit is the "final" flag - if (gomp_flags & 2) { + if (gomp_flags & KMP_GOMP_TASK_FINAL_FLAG) { input_flags->final = 1; } input_flags->native = 1; @@ -1206,7 +1212,7 @@ #endif if (if_cond) { - if (gomp_flags & 8) { + if (gomp_flags & KMP_GOMP_TASK_DEPENDS_FLAG) { KMP_ASSERT(depend); kmp_gomp_depends_info_t gomp_depends(depend); kmp_int32 ndeps = gomp_depends.get_num_deps(); @@ -1233,6 +1239,15 @@ OMPT_STORE_RETURN_ADDRESS(gtid); } #endif + if (gomp_flags & KMP_GOMP_TASK_DEPENDS_FLAG) { + KMP_ASSERT(depend); + kmp_gomp_depends_info_t gomp_depends(depend); + kmp_int32 ndeps = gomp_depends.get_num_deps(); + kmp_depend_info_t dep_list[ndeps]; + for (kmp_int32 i = 0; i < ndeps; i++) + dep_list[i] = gomp_depends.get_kmp_depend(i); + __kmpc_omp_wait_deps(&loc, gtid, ndeps, dep_list, 0, NULL); + } __kmpc_omp_task_begin_if0(&loc, gtid, task); func(data); diff --git a/openmp/runtime/test/tasking/taskdep_if0.c b/openmp/runtime/test/tasking/taskdep_if0.c new file mode 100644 --- /dev/null +++ b/openmp/runtime/test/tasking/taskdep_if0.c @@ -0,0 +1,39 @@ +// RUN: %libomp-compile-and-run + +#include +#include +#include +#include "omp_my_sleep.h" + +int a = 0; + +void task1() { + my_sleep(0.5); + a = 10; +} + +void task2() { + a++; +} + +int main(int argc, char** argv) +{ + #pragma omp parallel shared(argc) num_threads(2) + { + #pragma omp single + { + #pragma omp task depend(out: a) + task1(); + + #pragma omp task if(0) depend(inout: a) + task2(); + } + } + if (a != 11) { + fprintf(stderr, "fail: expected 11, but a is %d\n", a); + exit(1); + } else { + printf("pass\n"); + } + return 0; +}