Find Jobs
Hire Freelancers

Parallel program question answer

$15-20 AUD

Selesai
Disiarkan lebih dari 10 tahun yang lalu

$15-20 AUD

Dibayar semasa penghantaran
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/[login to view URL]); 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.
ID Projek: 5120527

Tentang projek

3 cadangan
Projek jarak jauh
Aktif 10 tahun yang lalu

Ingin menjana wang?

Faedah membida di Freelancer

Tetapkan bajet dan garis masa anda
Dapatkan bayaran untuk kerja anda
Tuliskan cadangan anda
Ianya percuma untuk mendaftar dan membida pekerjaan
Dianugerahkan kepada:
Avatar Pengguna
Hi! I am well familiar with MPI concepts. I can answer those questions providing high-quality solution to each of them.
$20 AUD dalam 3 hari
0.0 (0 ulasan)
0.0
0.0
3 pekerja bebas membida secara purata $22 AUD untuk pekerjaan ini
Avatar Pengguna
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 dalam 0 hari
4.9 (36 ulasan)
4.8
4.8
Avatar Pengguna
I've 3+ years experience working in c , Perl. I can do it....................................................................
$20 AUD dalam 2 hari
0.0 (0 ulasan)
0.0
0.0

Tentang klien

Bendera AUSTRALIA
Brisbane, Australia
4.9
52
Kaedah pembayaran disahkan
Ahli sejak Okt 20, 2013

Pengesahan Klien

Terima kasih! Kami telah menghantar pautan melalui e-mel kepada anda untuk menuntut kredit percuma anda.
Sesuatu telah berlaku semasa menghantar e-mel anda. Sila cuba lagi.
Pengguna Berdaftar Jumlah Pekerjaan Disiarkan
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Memuatkan pratonton
Kebenaran diberikan untuk Geolocation.
Sesi log masuk anda telah luput dan telah dilog keluar. Sila log masuk sekali lagi.