Try   HackMD

Parallel programming HW2

Q1:

Is speedup linear in the number of threads used? In your writeup hypothesize why this is (or is not) the case?

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • Refer to the graph above, the speedup is almost linear.
  • Since all threads doing same thing, using more thread will reduce the loading of threads, which decrease the execution time linearly.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • Speedup is also almost linear too.

Q2:

How do your measurements explain the speedup graph you previously created?

    double start = CycleTimer::currentTime();
    /*
     * code of copy arguments
    */
    double end = CycleTimer::currentTime();
    double execTime = end - start;
  • Adding code above to measure the copy time, copy operations take about
    108
    second.
  • Since the thread amount is small, the copy time won't dominate the execution time. Therefore, the speedup should be linear.

Q3:

In your write-up, describe your approach to parallelization and report the final 4-thread speedup obtained.

  • The thread would do mandelbrotSerial every numThreads rows, which starts from threadId row. For instance, thread0 would calculate row {0, 0+numThreads, 0+numThreads*2, etc}
  • The speedup of 4-thread is 3.81 in view1, and 3.79 in view2.

Q4:

Now run your improved code with eight threads. Is performance noticeably greater than when running with four threads? Why or why not? (Notice that the workstation server provides 4 cores 4 threads.)

  • No, since the machine have only 4 hardware threads available, creating more software thread could not increase parallelism.