Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following code computes row sums of matrix data [ 1 0 0 ] [ 1 0 0 ] by 2 processes. - - -
The following code computes row sums of matrix data by processes.
#include
#include
#include
#define generatedataijijj
int main int argc, char argv
int i j pid, np mtag, count;
double t t ;
int data rowsum ;
MPIStatus status;
MPIRequest reqs reqr;
MPIInit &argc, &argv ;
MPICommrankMPICOMMWORLD, &pid;
MPICommsizeMPICOMMWORLD, &np;
ifpid generate data
fori; i; i
forj; j; j
dataij generatedataij ;
mtag ;
MPIIsenddata MPIINT, mtag, MPICOMMWORLD, &reqs ;
fori; i; i
forj; j; j
dataij generatedataij ;
fori; i; i
rowsumi ;
forj; j; j
rowsumi dataij ;
MPIWait&reqs &status ;
receive computed rowsums from pid
mtag ;
MPIRecvrowsum, MPIINT, mtag, MPICOMMWORLD, &status ;
fori; i; i
printfd rowsumi ;
ifi printf
;
else pid
mtag ;
MPIRecvdata MPIINT, mtag, MPICOMMWORLD, &status ;
fori; i; i
rowsumi ;
forj; j; j
rowsumi dataij ;
Send computed rowsums to pid
mtag ;
MPISendrowsum, MPIINT, mtag, MPICOMMWORLD ;
MPIFinalize;
return ;
End of function main
For this assignment, please rewrite the code so that on pid there is
significant overlapping of receiving some rows with the computation of doing rowsummation of some other rows.
Since the requirement is that there is significant overlapping of communication
with computation on pid so do not reassign the subcomputations between the
two processes, ie the process with pid does only the row sums for row to
row where the data needed by tis process ie pid for the row sums are
to be received from the process with pid This assignment asks you to achieve
overlapping of receiving of some rows from row to row with the computation
row sums for some other rows from row to row
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started