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

From HPC Wiki
OpenMP in Small Bites/Worksharing
Jump to navigation Jump to search
Line 26: Line 26:
  
 
{{hidden begin  
 
{{hidden begin  
|title = What is one of the key concepts of the OpenMP execution model?
+
|title = Give an example for a parallel vector addition using OpenMP worksharing!
 
}}
 
}}
 
<quiz display=simple>
 
<quiz display=simple>
Line 32: Line 32:
 
|type="()"}
 
|type="()"}
 
+ Click and submit to see the answer
 
+ Click and submit to see the answer
|| Fork-Join: An OpenMP program starts with just one worker thread (<code>master</code>). The <code>worker</code> threads are spawned in the parallel region and form a <code>team</code> of threads together with the <code>master</code>. They all join at the end of a parallel region.
+
|| Fork-Join: C/C++:<br /> <code> int i; <br /> #pragma omp parallel <br /> #pragma omp for <br /> for (i = 0; i < 100; i++){ <br />  a[i] = b[i] + c[i];<br /> } </code> <br /> Fortran: <br /> <code> INTEGER :: i
 +
!$omp parallel <br /> !$omp do <br /> DO i = 0, 99<br />   a[i] = b[i] + c[i]<br /> END DO </code>
 
</quiz>
 
</quiz>
 
{{hidden end}}
 
{{hidden end}}
 +
 +
 +
    Give an example for a parallel vector addition using OpenMP worksharing!
 +
    (C/C++:
 +
 +
 +
 +
 +
 +
 
 +
 +
 +
 +
 +
 +
 +
 +
  
 
{{hidden begin  
 
{{hidden begin  

Revision as of 17:09, 30 October 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

What is most commenly used worksharing construct in OpenMP to distribute work among loop interations?

Click and submit to see the answer

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

Click and submit to see the answer


   Give an example for a parallel vector addition using OpenMP worksharing!
   (C/C++:








How can you control the number of threads?

Click and submit to see the answer