Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the problem so that aggregation is performed on the integer values sent to the Aggregate ( ) function, and the float average of the
Modify the problem so that aggregation is performed on the integer values sent to the Aggregate function, and the float average of the values the aggregation broadcast back to the processes.
Use the attached C template. Pay close attention to the comments in the template.
The output should be approximately:
finished loops
SEQUENTIAL EXECUTION TIME:
PARALLEL EXECUTION TIME:
SPEEDUP:
NUMBER OF PROCESSORS USED:
below is the template
Assign
Compute, Aggregate, and Broadcast using streams
#define LOOPS
#define PROCESSES
typedef struct
int addr;
int valu;
float aggr;
aggmsgt;
float verifyLOOPS;
define a stream array of the correct type and size named 'aga'
Aggregate receives a process count parameter. Aggregate must initially block on a receive,
waiting for its input. It counts its input, and performs steps needed for aggregation.
When it has received all messages, it completes the aggregation and broadcasts the result.
It leaves itself in a state so that it can be reused, until receiving an endmarker message,
one with an addr field of
void Aggregateint prct
process tests the Aggregation function.
void processint i int j
aggmsgt pmsg;
pmsgaddr i;
pmsgvalu j PROCESSES i;
pmsgaggr ;
sendaga pmsg;
recvagai pmsg;
if pmsgaggr verifyj
cout "process myid aggr pmsgaggr not equal to expect value verifyj endl;
initialization for Aggregate if needed
void initAgg
return;
int main
int i j;
aggmsgt emsg;
initialization code
for j ; j LOOPS; j
forall i to PROCESSES do
processi j;
termination code
cout "finished j loops" endl;
return ;
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