Debian Codegraph @

openmp/libompd/test/api_tests/test_ompd_get_curr_task_handle.c

raw
1 // RUN: %gdb-compile 2>&1 | tee %t.compile
2 // RUN: %gdb-test -x %s.cmd %t 2>&1 | tee %t.out | FileCheck %s
3
4 #include <omp.h>
5 #include <stdio.h>
6 int get_fib_num(int num) {
7 int t1, t2;
8 if (num < 2)
9 return num;
10 else {
11 #pragma omp task shared(t1)
12 t1 = get_fib_num(num - 1);
13 #pragma omp task shared(t2)
14 t2 = get_fib_num(num - 2);
15 #pragma omp taskwait
16 return t1 + t2;
17 }
18 }
19
20 int main() {
21 int ret = 0;
22 omp_set_num_threads(2);
23 #pragma omp parallel
24 { ret = get_fib_num(10); }
25 printf("Fib of 10 is %d", ret);
26 return 0;
27 }
28
29 // CHECK-NOT: Failed
30 // CHECK-NOT: Skip