# Parallel Programming Homework 2 ## Q1 ![](https://i.imgur.com/H0u5qXc.png) ![](https://i.imgur.com/X0Sz04L.png) The speed up is not linear! And strangely, The three-threads case performs worse than the two-threads case! The reason might be that the workload of threads are uneven, since the total runtime depends on the runtime of the longest job. ## Q2 The following is the case with three threads. ![](https://i.imgur.com/Z5sg5IR.png) The runtime is uneven as expected. The reason is that each pixel takes different time to render. It takes more iterations to produce a bright pixel than a dark pixel, which expain why the 1st thread takes the longest in the first view. ![](https://i.imgur.com/ul1i1xl.png) ## Q3 To tackle such problem, we can randomize the permutation of rows, which should make the workload more uniform. ![](https://i.imgur.com/KivfHF0.png) The final speedup for 4 threads is 3.74x. ## Q4 When running with 8-threads, the performance is actually slightly worse than running with 4 threads. This is likely because the server have only 4 cores, running with more than four threads will only cause more context switching, which will not benefit the performance.