mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
21 lines
391 B
C
21 lines
391 B
C
/*
|
|
* @@name: tasking.4c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
int fib(int n) {
|
|
int i, j;
|
|
if (n<2)
|
|
return n;
|
|
else {
|
|
#pragma omp task shared(i)
|
|
i=fib(n-1);
|
|
#pragma omp task shared(j)
|
|
j=fib(n-2);
|
|
#pragma omp taskwait
|
|
return i+j;
|
|
}
|
|
}
|