Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <omp.h>
- int fibonacci(int n){
- int i,j;
- if(n<2) return n;
- else{
- #pragma omp task shared(i)
- i = fibonacci(n-1);
- #pragma omp task shared(j)
- j = fibonacci(n-2);
- #pragma omp taskwait
- return i+j;
- }
- }
- int main(){
- int fibN;
- omp_set_num_threads(4);
- #pragma omp parallel
- {
- #pragma omp single nowait
- fibN = fibonacci(27);
- }
- printf("%d",fibN);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement