#include

#include

#include "cilkview.h"

#include

int isprime ( int n )

{

int m;

int sqrt_n = sqrt(n);

for (m = 2; m <= sqrt_n+1; m++) // +1 in case of obscure rounding error

if ((n % m) == 0) return 0;

return 1;

}

int main ( int argc, char** argv )

{

cilkview_data_t start;

int i;

__cilkview_query(start);

cilk_for (i = 79000; i < 10081000; i++)

if (isprime(i)) { printf ( "%d ", i );

fflush(stdout); }

__cilkview_report(&start, NULL, "my_tag", CV_REPORT_WRITE_TO_RESULTS);

return 0;

}

In the above program, how does one cilkify is prime and main? I am guessing thatthe

the answer is not to take the following line:

if (isprime(i)) { printf ( "%d ", i );

and change it to

if (spawn isprime(i)) { printf ( "%d ", i );

That would generate an error; there must be a different way.

Thanks in advance.

Newport_j