1 // RUN: %libomp-compile-and-run
2 // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8
3 // UNSUPPORTED: clang-3, clang-4, clang-5, clang-6, clang-7, clang-8
4 // TODO: update expected result when icc supports mutexinoutset
7 // Tests OMP 5.0 task dependences "mutexinoutset", emulates compiler codegen
8 // Mutually exclusive tasks get same input dependency info array
17 // task6 <-->task7 (these two are mutually exclusive)
23 #include "omp_my_sleep.h"
25 static int checker
= 0; // to check if two tasks run simultaneously
31 int mutex_task(int task_id
) {
32 int th
= omp_get_thread_num();
35 printf("task %d, th %d\n", task_id
, th
);
38 printf("Error1, checker %d != 1\n", checker
);
43 printf("Error2, checker %d != 1\n", checker
);
53 omp_set_num_threads(2);
56 #pragma omp single nowait
58 int t
= omp_get_thread_num();
59 #pragma omp task depend(in: i1, i2)
60 { int th
= omp_get_thread_num();
61 printf("task 0_%d, th %d\n", t
, th
);
63 #pragma omp task depend(in: i1, i3)
64 { int th
= omp_get_thread_num();
65 printf("task 1_%d, th %d\n", t
, th
);
67 #pragma omp task depend(in: i2) depend(out: i1)
68 { int th
= omp_get_thread_num();
69 printf("task 2_%d, th %d\n", t
, th
);
71 #pragma omp task depend(in: i1)
72 { int th
= omp_get_thread_num();
73 printf("task 3_%d, th %d\n", t
, th
);
75 #pragma omp task depend(out: i2)
76 { int th
= omp_get_thread_num();
77 printf("task 4_%d, th %d\n", t
, th
);
78 my_sleep(DELAY
+0.1); } // wait a bit longer than task 3
79 #pragma omp task depend(out: i3)
80 { int th
= omp_get_thread_num();
81 printf("task 5_%d, th %d\n", t
, th
);
84 #pragma omp task depend(mutexinoutset: i1, i4)
86 #pragma omp task depend(mutexinoutset: i1, i4)
89 #pragma omp task depend(in: i1)
90 { int th
= omp_get_thread_num();
91 printf("task 8_%d, th %d\n", t
, th
);