Retro68/gcc/libgomp/testsuite/libgomp.c/examples-4/e.53.1.c

37 lines
489 B
C
Raw Normal View History

2015-08-28 15:33:40 +00:00
/* { dg-do run } */
#include <stdlib.h>
#define THRESHOLD 20
#pragma omp declare target
int fib (int n)
{
if (n <= 0)
return 0;
else if (n == 1)
return 1;
else
return fib (n - 1) + fib (n - 2);
}
#pragma omp end declare target
int fib_wrapper (int n)
{
int x = 0;
#pragma omp target if(n > THRESHOLD)
x = fib (n);
return x;
}
int main ()
{
if (fib (15) != fib_wrapper (15))
abort ();
if (fib (25) != fib_wrapper (25))
abort ();
return 0;
}