Write a short program that counts the number of prime numbers up to 10,000,000. Make the for loop parallel and use the reduction clause to tally up the primes. Report the computed value at the end.

#include <math.h> int isPrime (unsigned int n) { unsigned int m = sqrt(n) ; for (unsigned int k=2 ; k <= m ; k++) { if (n % k == 0) return 0 ; } return 1 ; }

Run your program several times. Does it always say the same value?

Finally, use the time command to check how much time you are saving using OpenMP compared to a serial program. You should observe a 50% speedup on GL.

time ./a.out