S1: a := 7; S2: b := 2; S3: c := 3; S4: read(d); S5: a := b + 2; S6: b := a - 3;
ID: 3717399 • Letter: S
Question
S1: a := 7;
S2: b := 2;
S3: c := 3;
S4: read(d);
S5: a := b + 2;
S6: b := a - 3;
S7: c := d / b;
S8: e := a + 2;
S9: print(e);
S10: print(c);
1. Give the statement-level dependence graph for the above program. A node in the statement-level dependence graph represents a statement, an edge represents dependence between the statements (nodes). Label each edge as a true data dependence, an anti data dependence, or an output data dependence.
2. Assume that each statement takes 1 cycle to execute. What is the execution time of the sequential code? What is the fastest parallel execution time of the program (critical path)? You may assume that I/O operations (read, print) can be done in parallel.
Explanation / Answer
Sequential Execution:
I am executing this code in matlab. I got the results
for reading "D" value 9.758sec.
for displaying "C" and "E" got the result 0.001sec
S: e=e+2 takes 0sec and
S:c=b*d takes 0sec.
All other statements takes 0sec while executing sequential.
The total time equals to 9.760sec.
To calculate the execution time determine the total number of times for execution.
Cycles To Execute
S1: a := 3; 1
S2: b := 5; 1
S3: c := 7; 1
S4: read(d); 1
S5: a := b + 2; 1
S6: b := a - 3; 1
S7: c := b * d; 1
S8: e := a + 2; 1
S9: print(e); 1
S10: print(c); 1.
Total number of cycles for execution is 10. so execution time is C*T(Cycles * Time) i.e.,97.6sec.
Parallel Execution:
So while executing in parallel, if read and print are done in parallel total time equals to
for reading "D" value and printing "C" and "E" values takes 9.758sec.
S: e=e+2 takes 0sec and
S:c=b*d takes 0sec.
All other statements takes 0sec while executing sequential.
The total time equals to 9.758sec.
Total number of cycles for execution is 10. so execution time is C*T(Cycles * Time) i.e.,97.58 sec.
So Parallel execution takes less time when compare to the sequential time.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.