1 /* { dg-do run } */ 2 3 #include <stdlib.h> 4 5 #define THRESHOLD 20 6 7 #pragma omp declare target fib(int n)8int fib (int n) 9 { 10 if (n <= 0) 11 return 0; 12 else if (n == 1) 13 return 1; 14 else 15 return fib (n - 1) + fib (n - 2); 16 } 17 #pragma omp end declare target 18 fib_wrapper(int n)19int fib_wrapper (int n) 20 { 21 int x = 0; 22 23 #pragma omp target if(n > THRESHOLD) map(from:x) 24 x = fib (n); 25 26 return x; 27 } 28 main()29int main () 30 { 31 if (fib (15) != fib_wrapper (15)) 32 abort (); 33 if (fib (25) != fib_wrapper (25)) 34 abort (); 35 return 0; 36 } 37