NAME: (1) For each of the following pieces of code, give the output value. If there is more than one possible output value, list a few that could occur and explain. Assume the underlying computer is a 2-core computer, so a parallel pragma runs on 2 cores. 5 points each part. (1a) int sum=0; #pragma omp parallel for for(int i=0; i<5; i++) sum += i; printf("%d\n", sum); (1b) int n = 23; #pragma omp parallel for for(int i=2; i*i <= 23; i++) if (n % i == 0) { n = -1; break; } if (n < 0) printf("composite.\n"); else printf("prime.\n"); (1c) int* A = {7, 5, 6, 1}; int okay = 1, small, temp; #pragma omp parallel for for(int i=0; i < 4; i++) { #pragma omp critical small = i; for(int j=i+1; j < 4; j++) if (A[j] < A[small]) #pragma omp critical small = j; temp = A[small]; A[small] = A[i]; A[i] = temp; printf("smallest = %d, largest = %d\n", A[0], A[4]); (2) Consider testing whether a number is prime using trial division. Given a number n, you can try dividing by numbers between 2 and sqrt(n). We consider two alternatives - either run the algorithm single-threaded, or run it on 100 CPU cores by just breaking up the range [2, sqrt(n)] into 100 pieces - with the 0th CPU core getting [2, (sqrt(n)+1)/100], the second getting [(sqrt(n)+1)/100 +1, 2*(sqrt(n)+1)/100], and so on. 5 points each part. (2a) For the single-threaded running of the algorithm, what is the running time as a function of n? Use the estimate that a single division takes O(log(n) * log(log(n))) time. (2b) For the multi-threaded version on 100 CPU cores, which CPU core will take the longest to complete its task? How long does it take, as a big-O estimate? Hint: whatever you get for (2b) cannot be greater than what you get for (2a)!