22 #pragma omp taskgroup task_reduction(+:r)
23 {
int th_gen = omp_get_thread_num();
24 #pragma omp task in_reduction(+:r) firstprivate(i, th_gen)
27printf(
"executing task (%d, 0), th %d (gen by th %d)\n",
i, omp_get_thread_num(), th_gen);
29 #pragma omp task in_reduction(+:r) firstprivate(i, th_gen)
32printf(
"executing task (%d, 1), th %d (gen by th %d)\n",
i, omp_get_thread_num(), th_gen);
38 int th_gen = omp_get_thread_num();
39 #pragma omp taskgroup task_reduction(+:r)
43printf(
"th %d passed bar0\n", th_gen);
44 #pragma omp taskloop reduction(+:r) firstprivate(th_gen)
45 for (
i = 1;
i < 4; ++
i) {
47printf(
"th %d (gen by th %d) passed bar%d in taskloop\n", omp_get_thread_num(), th_gen,
i);
48 #pragma omp task in_reduction(+:r)
58 #pragma omp parallel num_threads(2)
62 #pragma omp single nowait
68 printf(
"error r = %d (!= %d)\n",
r,
res);