Table of Contents

Parallelize a pipeline

First parallelisation

Text

Assume the computations of the increment and the square operations of the previous example take 0.2 seconds each (add a

usleep(500000)

before returning from svc. Further parallelize the previous program using a single farm. Try to figure out the expected completion/service time before running the program (function of m, the number of tasks). Remember: the service time of a pipeline is roughly Ts = max { Ti }, being Ti the latency of the i-th stage. The completion time may be approximated with Tc = m Ts, with m being the number of tasks to be computed.

Sample solution

Find code here.

Load balancing

Text

Assume incr takes 0.1 secs, while square takes 0.5 secs. Further transform/tune the previous parallellization such that you get optimal performance. (Hint: try to get the same service time out of the two stages, considering the amount of resources available.)

Sample solution

Find code here.

Lesson goal

Evaluate how simple rewriting of the original program may improve the performance of the simple stream parallel application. Appreciate the way farms may be used to improve the pipeline stage performance in such a way load balancing is achieved.