Question: Please check the code ( given below ) which implements its serial algorithm of computing the pi. In terminal, run gcc -o computingPi CCalPi.c Then
Please check the code (given below) which implements its serial algorithm of computing the pi. In terminal, run gcc -o computingPi CCalPi.c Then 1. Copy CCalPi.c as CCalPi_pthreads.c 2. Update the CCalPi_pthreads.c to support tree-structure parallelism with an efficient barrier mechanism. Write a brief report, including the pseudo code and giving an explanation why you choose the method.
CODE
#include
double computingPiSerial();
int main(void) { double sum = computingPiSerial(); printf("Pi is equal to %f ", sum);
return EXIT_SUCCESS; }
double computingPiSerial(){ double sum = 0; double factor; long i, n = 100000;
for (i = 0; i < n; i++){ if (i % 2 == 0){ factor = 1.0; } else { factor = -1.0; }
sum = sum + 4 * factor / (2*i+1); } return sum; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
