In order to successfully complete this assignment you must do the required reading, watch the provided videos and complete all instructions. The embedded survey form must be entirely filled out and submitted on or before 11:59pm. Students must come to class the next day prepared to discuss the material covered in this assignment.
PCA 16: Into the OpenMP Weeds#
Goals for today’s pre-class assignment#
1. Getting into the weeds#
✅ DO THIS: Watch the following video on YouTube, which discusses barriers in OpenMP Introduction to OpenMP: 11 part 1 Module 6
from IPython.display import YouTubeVideo
YouTubeVideo("iQSls3ITcp0",width=640,height=360)
✅ QUESTION: Why is there always an implied barrier at the end of a parrallel region?
Put your answer to the above question here.
✅ QUESTION: What is the single
section used.
Put your answer to the above question here.
2. Locks#
✅ DO THIS: Watch the following video on YouTube, which is an introduction to locks in OpenMP Introduction to OpenMP: 11 part 2 Module 6
from IPython.display import YouTubeVideo
YouTubeVideo("Te7msPhJbdU",width=640,height=360)
Here is the code from the video for your review.
#pragma omp parallel for
for(int i=0;INBUCKETS;i++){
omp_init_lock(&hist_locks[i]);
hist[i] = 0;
}
#pragma omp parallel for
for(int i=0;INVALS;i++){
ival = (int) sample(arr[i]);
omp_set_lock(&hist_locks[ival]);
hist[ival]++;
omp_unset_lock(&hist_locks[ival]);
}
for(int i=0;i<NBUCKETS;i++)
omp_destroy_lock(&hist_locks[i]);
3. RunTime Libraries#
✅ DO THIS: Watch the following video on YouTube, which is an introduction to OpenMP runtime libraries Introduction to OpenMP: 11 part 3 Module 6
from IPython.display import YouTubeVideo
YouTubeVideo("A3VgOlM4IsI",width=640,height=360)
4. Assignment wrap up#
Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credits for the assignment!
✅ Assignment-Specific QUESTION: Why is there always an implied barrier at the end of a parrallel region?
Put your answer to the above question here
✅ QUESTION: Summarize what you did in this assignment.
Put your answer to the above question here
✅ QUESTION: What questions do you have, if any, about any of the topics discussed in this assignment after working through the jupyter notebook?
Put your answer to the above question here
✅ QUESTION: How well do you feel this assignment helped you to achieve a better understanding of the above mentioned topic(s)?
Put your answer to the above question here
✅ QUESTION: What was the most challenging part of this assignment for you?
Put your answer to the above question here
✅ QUESTION: What was the least challenging part of this assignment for you?
Put your answer to the above question here
✅ QUESTION: What kind of additional questions or support, if any, do you feel you need to have a better understanding of the content in this assignment?
Put your answer to the above question here
✅ QUESTION: Do you have any further questions or comments about this material, or anything else that’s going on in class?
Put your answer to the above question here
✅ QUESTION: Approximately how long did this pre-class assignment take?
Put your answer to the above question here
from IPython.display import HTML
HTML(
"""
<iframe
src="https://cmse.msu.edu/cmse401-pc-survey"
width="100%"
height="500px"
frameborder="0"
marginheight="0"
marginwidth="0">
Loading...
</iframe>
"""
)
Congratulations, we’re done!#
To get credit for this assignment you must fill out and submit the above survey from on or before the assignment due date.
Written by Dr. Dirk Colbry, Michigan State University (Updated by Dr. Nathan Haut in Spring 2025)
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.