Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
SIT315- Seminar 5- Multithreading - OMP
Overview
Form a group of 5-6 students and work on the following activities.
Submission Details
Each student should submit the answers in the onTrack individually. Please write the names of all of your
group members in the first page of your submission.
Activity 1 - Parallel Vector Addition- OMP
In the resources, you have been provided with a simple vector addition program. In last week seminar, you
implemented a parallel version of this program using pthread/std::thread library. In this activity, you need to:
1. Modify the sequential program to use OpenMP to achieve parallelism using omp parallel and omp
for directives.
2. Evaluate the performance of the OpenMP implementation vs pthread implementation vs the sequential
program. Discuss your findings.
Activity 2 - Parallel Vector Addition part 2- OMP++
Continue with the previous vector addition example and
1. Add the default(none)attribute to the #pargma omp parallel directive. Compile and run your code.
If you get any compilation error, try to identify the reason. As required, add any of the shared,
private or firstprivate attributes to fix the compilation error. Try different variations of data
sharing (e.g. shared(size) private(v1) or private(size) shared(v1) or ...). Is the outcome
of your program different? Explain why.
2. Compute the total sum of all the elements in v3 using a shared variable called total and atomic
update directive.
3. Use the reduction clause to compute the total sum of all the elements in v3.
4. Implement an alternative version where each thread computes its own part to a private variable and
then use a critical section (#pragma omp critical) after the loop to calculate the total sum. Do you
get the exact same results in all cases?
5. Try different OpenMP Scheduling techniques by adding schedule(type[,chunk]) attribute to
#pargma omp for directive. Experiment with the chunk size to understand how each Scheduling
technique works. Does changing the scheduling techniques or chunk size impact the execution time.
Briefly explain your observations.
After finishing these activities, use the remaining time of the seminar to work on TaskM2.T1p
individually. You can find the task description from OnTrack.