Difference between revisions of "OpenMP in Small Bites/Worksharing"

From HPC Wiki
OpenMP in Small Bites/Worksharing
Jump to navigation Jump to search
(Set correct link to video)
Line 37: Line 37:
  
 
{{hidden begin  
 
{{hidden begin  
|title = 3. Can the following code snipped be parallelized with the OpenMP for-construct with out breaking the semantic? Justify your answer.
+
|title = 3. Can the following code snipped be parallelized with the OpenMP for-construct with out breaking the semantic? Justify your answer. <br>
 +
<code> int i, int s = 0; <br /> for (i = 1; i < 100; i++){ </code> <div style="margin-left: 1em;"><code> s = a[i-1] + a[i]; </code></div> <code>}  </code> <br />
 
}}
 
}}
 
<quiz display=simple>
 
<quiz display=simple>
Line 43: Line 44:
 
|type="()"}
 
|type="()"}
 
+ Click and submit to see the answer
 
+ Click and submit to see the answer
|| <code> int i, int s = 0; <br /> for (i = 1; i < 100; i++){ </code> <div style="margin-left: 1em;"><code> s = a[i-1] + a[i]; </code></div> <code>}  </code> <br /> {{Note|'''Due to the dependency between the loop iterations this would cause a data race'''}}  
+
|| {{Note|'''No. Due to the dependency between the loop iterations this would cause a data race'''}}  
 
</quiz>
 
</quiz>
 
{{hidden end}}
 
{{hidden end}}

Revision as of 18:38, 2 November 2020



HPC.NRW
HPC.NRW
Other HPC Courses
1. Gprof Tutorial
2. Introduction to Linux in HPC
OpenMP in Small Bites
1. Overview
2. Worksharing
3. Data Scoping
4. Non-Uniform Memory Access







Video

Quiz

1. What is most commonly used worksharing construct in OpenMP to distribute work among loop interations?

Click and submit to see the answer

2. Give an example for a parallel vector addition using OpenMP worksharing!

Click and submit to see the answer


3. Can the following code snipped be parallelized with the OpenMP for-construct with out breaking the semantic? Justify your answer.
int i, int s = 0;
for (i = 1; i < 100; i++){
s = a[i-1] + a[i];
}

Click and submit to see the answer