Starting from:
$25

$19

HW 1: Parallel Programming with Threads

Compile and execute the program in the file compute_pi.c, which computes an estimate of using the parallel algorithm discussed in class. The program is available on the shared Google Drive for this class. It should be compiled and executed on either ada.tamu.edu or terra.tamu.edu.

Load the Intel software stack prior to compiling and executing the code.

module load intel/2017A

To compile, use the command:

icc -o compute_pi.exe compute_pi.c -lpthread

To execute the program, use

./compute_pi.exe <n> <p>

where <n> represents the number of points and <p> represents the number of threads. The output of a sample run is shown below.

./compute_pi.exe 1000000 4

Trials = 1000000, Threads = 4, pi =    3.1433480000, error = 5.59e-

04, time (sec) =    0.0043

The run time of the code should be measured when it is executed in dedicated mode. Use the batch file compute_pi.ada_job to execute the code in dedicated mode using the following command on ADA:

bsub < compute_pi.ada_job

On Terra, you will need to use compute_pi.terra_job, and the corresponding command is:

sbatch compute_pi.terra_job

Execute the code for n=108 with p chosen to be 2k, for k = 0, 1, …, 13. Using the experimental data obtained from these experiments, answer the following questions.

    1. (20 points) Plot execution time versus p to demonstrate how time varies with the number of threads. Use a logarithmic scale for the x-axis.

    2. (20 points) Plot speedup versus p to demonstrate the change in speedup with p.

    3. (10 points) Using the definition: efficiency = speedup/p, plot efficiency versus p to demonstrate how efficiency changes as the number of threads are increased.

    4. (10 points) What value of p minimizes the parallel runtime?

    5. (10 points) Repeat the experiments with n=109 To obtain the execution time for p=2k, for k = 0, 1, …, 13. In this case, what value of p minimizes the parallel runtime?

    6. (10 points) Why does the runtime start to increase as p is increased beyond a certain value?


Page 1 of 2

    7. (10 points) Why is there a difference in the number of threads needed to obtain the minimum execution time for two values of n?

    8. (10 points) Plot error versus n to illustrate accuracy of the algorithm as a function of n. You may have to run experiments with different values of n; for example n could be chosen to be 10k, for k = 3, …, 9. Use p = 20.

Submission: Upload a single PDF or MSWord document with your answers to Canvas.

























































Page 2 of 2

More products