Em Andamento

Parallel program question answer

Need answers for the questions of the 2 parallel programs given below. Needed within 18-20 hours ans it shouldn't be a problem for someone who did parallel programming. Max. $20 will be accepted.

Program 1: Consider the following fragment of a parallel program.

MPI_Comm_rank(MPI_COMM_WORLD, &procnum);

MPI_Comm_size(MPI_COMM_WORLD, &numprocs);

// COMMENT 1

right = procnum + 1; if (right == numprocs) right = 0;

left = procnum - 1; if (left == -1) left = numprocs-1;

sum = 0;

value = procnum;

for (i = 0; i < numprocs; i++) {

// COMMENT 2

MPI_Send(&value,1,MPI_INT,right,tag,MPI_COMM_WORLD);

MPI_Recv(&new_value,1,MPI_INT,left,tag,MPI_COMM_WORLD,&status);

// COMMENT 3

sum = sum + new_value;

value = new_value;

}

// COMMENT 4

if (procnum == 0) {

printf ("%d\n", sum);

}

(a) For each of the four lines listed as comments, such as COMMENT 1 etc,

write down the comment number and then a short explanation of the

lines of code underneath that comment. For example, for COMMENT

1, explain the two subsequent lines, before the blank line.

(b) Explain the purpose of the for loop.

(c) Draw a diagram showing the flow of messages between processes in

an execution of the program. Assume four processes.

Program 2:Consider the following parallel program (as presented in lectures):

#include mpi.h

#include <stdio.h>

#include <math.h>

#define MAXSIZE 1000

void main(int argc, char *argv[]){

int myid,numprocs;

int data[MAXSIZE], i, x, low, high, myresult,

result;

char fn[255];

char *fp;

MPI_Init(&argc,&argv);

MPI_Comm_size(MPI_COMM_WORLD,&numprocs);

MPI_Comm_rank(MPI_COMM_WORLD,&myid);

if (my_id == 0){

strcpy(fn,getenv(HOME));

strcat(fn,/MPI/[url removed, login to view]);

if((fp = fopen(fn,r)) == NULL){

printf(Cant open the input file);

exit(1);

}

for (i=0; i < MAXSIZE; i++)

fscanf(fp,%d,&data[i]);

MPI_Bcast(data,MAXSIZE,MPI_INT,0,MPI_COMM_WORLD);

x = MAXSIZE / numprocs;

low = myid * x;

high = low + x;

for(i = low; i < high; i++)

myresult += data[i];

printf(I got %d from %d\n,myresult, myid);

MPI_Reduce(&myresult,&result,1,MPI_INT,MPI_SUM,0,

MPI_COMM_WORLD);

if (myid == 0) printf(the sum is %d.\n,result);

MPI_Finalize();

}}

(a) Show how the program can be initiated with five processes in use.

(b) Identify clearly which code is executed by which processes.

(c) What is the significance of the communicator in the call to MPI Bcast?

(d) Draw a diagram to show the process structure in the executing program.

(e) Draw a series of diagrams to show how the computation proceeds.

Identify parts executed in parallel, and code executed sequentially.

(f) Can the final reduce be done in parallel? Explain.

Habilidades: Programação C, Programação C++ , Java

Ver mais: what is r programming, what is parallel programming, what is data structure in programming, what is a loop in programming, what is a data structure explain, use of proceeds example, use of data structure in programming, questions of data structure, question of data structure, programming question in c, programming diagram, printf c programming, parallel programming with mpi, parallel programming in java, parallel programming in c, math programming, math in programming, math and programming, java parallel programming, for loop in c programming, for loop c programming, fopen c programming, fn number, explain data structure, define data structure with example

Acerca do Empregador:
( 52 comentários ) Brisbane, Australia

ID do Projeto: #5120527

Premiar a:

TarasKuzyo

Hi! I am well familiar with MPI concepts. I can answer those questions providing high-quality solution to each of them.

$20 AUD em 3 dias
(0 Avaliações)
0.0

3 freelancers estão ofertando em média $22 para este trabalho

kaloyan13

Parallel programmer with experience in MPI. I can answer the question and explain the code. I know MPI from university, where we used MPICH2 to run distributed programs.

$25 AUD in 0 dias
(36 Comentários)
4.8
sachitjani81

I've 3+ years experience working in c , Perl. I can do it....................................................................

$20 AUD in 2 dias
(0 Comentários)
0.0