Exemplo n.º 1
0
long pfib(int n) {
  if (n<2) return 1;

  long x;
  long y;
  x = cilk_spawn pfib(n-1);
  // We add a spawn here in order to match time_fib in qthreads
  y = cilk_spawn pfib(n-2);

  cilk_sync;
  return x+y;
}
Exemplo n.º 2
0
int main( int argc, char **argv )
{
    int n,m;

    if( argc < 2 ) {
        fprintf( stderr, "Usage: fib-seq <arg>\n" ),
            exit( 2 );
    }

    n = atoi( argv[ 1 ] );

    double t1 = wctime();
    m = pfib( n );
    double t2 = wctime();

    printf( "%d\n", m );
    printf("Time: %f\n", t2-t1);
    return 0;
}