Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lot of my colleagues are confused with this question can you guys help us out Th

ID: 3859667 • Letter: L

Question

Lot of my colleagues are confused with this question can you guys help us out Thank you The language is C regular I think it's for parallel computing CS4328 Parallel Computing Lab: Divide and Coqur(har) Name ID Check the exercises when you have done and demonstrate your program in class. 1. Implement the integration program in Chapter 4 (Also on slides). Make necessary modifications to run on the cluster Examine the data partitioning scheme used by this program. What data partitioning scheme is used? Change the data partitioning scheme to block partitioning. Note that the number of items assigned to the last process may not be the same as the number assigned to other processes. 2.

Explanation / Answer

The parallel computing for the pi calculation. The code required for the pi calculationis as follows. I tried to keep it as simple as I could. Hope you will understand the code.Here is the code:

pi.c

#include <stdio.h>

#include <stdlib.h>

#include <gmp.h>

mpz_t temp, temp1, to1, tt29, pow;

void acting(mpz_t resol, unsigned long bs, mpz_t pow)

{

int uu, nega = 1;

mpz_tdiv_q_ui(resol, pow, bs);

mpz_set(temp, resol);

for (uu = 3; ; uu += 2) {

mpz_tdiv_q_ui(temp, temp, bs * bs);

mpz_tdiv_q_ui(temp1, temp, uu);

if (mpz_cmp_ui(temp1, 0) == 0) break;

if (nega) mpz_sub(resol, resol, temp1);

else mpz_add(resol, resol, temp1);

nega = !nega;

}

}

char * gt_dig(int no, size_t* lenth)

{

mpz_ui_pow_ui(pow, 10, no + 20);

acting(to1, 5, pow);

mpz_mul_ui(to1, to1, 16);

acting(tt29, 239, pow);

mpz_mul_ui(tt29, tt29, 4);

mpz_sub(to1, to1, tt29);

mpz_ui_pow_ui(pow, 10, 20);

mpz_tdiv_q(to1, to1, pow);

*lenth = mpz_sizeinbase(to1, 10);

return mpz_get_str(0, 0, to1);

}

int main(int co, char **arg)

{

unsigned long accuma = 16384, done = 0;

size_t GOT;

char *st;

mpz_init(temp);

mpz_init(temp1);

mpz_init(to1);

mpz_init(tt29);

mpz_init(pow);

while (1) {

st = gt_dig(accuma, &GOT);

GOT -= 2;

while (st[GOT] == '0' || st[GOT] == '9') GOT--;

printf("%.*st", (int)(GOT - done), st + done);

free(st);

done = GOT;

accuma *= 2;

}

return 0;

}

Please rate the answer if it helped......Thankyou

Hope it helps....