Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openmp-lab-exercises
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pdc-summer-school
openmp-lab-exercises
Commits
4650ec4d
Commit
4650ec4d
authored
6 years ago
by
Xin Li
Browse files
Options
Downloads
Patches
Plain Diff
updated intro_lab instruction
parent
ef0b3868
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
intro_lab/README.md
+11
-11
11 additions, 11 deletions
intro_lab/README.md
with
11 additions
and
11 deletions
intro_lab/README.md
+
11
−
11
View file @
4650ec4d
...
@@ -55,10 +55,10 @@ export OMP_NUM_THREADS=<number-of-threads>
...
@@ -55,10 +55,10 @@ export OMP_NUM_THREADS=<number-of-threads>
To run an OpenMP code on a computing node of Beskow:
To run an OpenMP code on a computing node of Beskow:
```
```
aprun -n 1 -d number
of
threads -cc none ./name_exec
aprun -n 1 -d
<
number
-
of
-
threads
>
-cc none ./name_exec
```
```
## Exercise
-
1 - OpenMP Hello World: get familiar with OpenMp Environment
## Exercise
1 - OpenMP Hello World: get familiar with OpenMp Environment
_Concepts: Parallel regions, parallel, thread ID_
_Concepts: Parallel regions, parallel, thread ID_
...
@@ -98,14 +98,14 @@ Questions:
...
@@ -98,14 +98,14 @@ Questions:
-
How many different ways are there to change the number of threads? Which one are those?
-
How many different ways are there to change the number of threads? Which one are those?
-
How can you make the output ordered from thread 0 to thread 4?
-
How can you make the output ordered from thread 0 to thread 4?
## Exercise 2 - Creating Threads: calculate pi in parallel
opnalryaulslienlg tphreagma
## Exercise 2 - Creating Threads: calculate
&
pi
;
in parallel
using only pragma omp parallel
_Concepts: Parallel, default data environment, runtime library calls_
_Concepts: Parallel, default data environment, runtime library calls_
Here we are going to implement a first parallel version of the pi.c / pi.f90
Here we are going to implement a first parallel version of the pi.c / pi.f90
code to calculate the value of pi using the parallel construct.
code to calculate the value of
&
pi
;
using the parallel construct.
The figure below shows the numerical technique, we are going to use to calculate pi.
The figure below shows the numerical technique, we are going to use to calculate
&
pi
;
.
<img
src=
"image/pi_int.png"
alt=
"PI_integral"
width=
"350px"
/>
<img
src=
"image/pi_int.png"
alt=
"PI_integral"
width=
"350px"
/>
...
@@ -119,7 +119,7 @@ We can approximate the integral as a sum of rectangles
...
@@ -119,7 +119,7 @@ We can approximate the integral as a sum of rectangles
where each rectangle has width
Δ
x and height F(x
<sub>
i
</sub>
) at the middle of interval i.
where each rectangle has width
Δ
x and height F(x
<sub>
i
</sub>
) at the middle of interval i.
A simple serial C code to calculate pi is the following:
A simple serial C code to calculate
&
pi
;
is the following:
```
```
static long num_steps = 100000000;
static long num_steps = 100000000;
...
@@ -192,12 +192,12 @@ Questions:
...
@@ -192,12 +192,12 @@ Questions:
-
Is there any technique you heard in class to improve the scalability of the
-
Is there any technique you heard in class to improve the scalability of the
technique? How would you implement it?
technique? How would you implement it?
## Exercise 3 -
c
alculate pi
cursintg
ical andatomic directives
## Exercise 3 -
C
alculate
&
pi
; using crit
ical and
atomic directives
_Concepts: parallel region, synchronization, critical, atomic_
_Concepts: parallel region, synchronization, critical, atomic_
Here we are going to implement a second and a third parallel version of the
Here we are going to implement a second and a third parallel version of the
pi.c / pi.f90 code to calculate the value of pi using the critical and atomic
pi.c / pi.f90 code to calculate the value of
&
pi
;
using the critical and atomic
directives.
directives.
Instructions: Create two new parallel versions of the pi.c / pi.f90 program
Instructions: Create two new parallel versions of the pi.c / pi.f90 program
...
@@ -207,7 +207,7 @@ time with 1, 2, 4, 8, 16, 32 threads. Record the timing in a table.
...
@@ -207,7 +207,7 @@ time with 1, 2, 4, 8, 16, 32 threads. Record the timing in a table.
Hints:
Hints:
-
We can use a shared variable pi to be updated concurrently by different
-
We can use a shared variable
&
pi
;
to be updated concurrently by different
threads. However, this variable needs to be protected with a critical section
threads. However, this variable needs to be protected with a critical section
or an atomic access.
or an atomic access.
-
Use critical and atomic before the update
``pi += step``
-
Use critical and atomic before the update
``pi += step``
...
@@ -220,12 +220,12 @@ Questions:
...
@@ -220,12 +220,12 @@ Questions:
-
Do the two version of the codes differ in performance? If so, what do you
-
Do the two version of the codes differ in performance? If so, what do you
think it is the reason?
think it is the reason?
## Exercise 4 -
c
alculate pi with a loop and a reduction
## Exercise 4 -
C
alculate
&
pi
;
with a loop and a reduction
_Concepts: worksharing, parallel loop, schedule, reduction_
_Concepts: worksharing, parallel loop, schedule, reduction_
Here we are going to implement a fourth parallel version of the pi.c / pi.f90
Here we are going to implement a fourth parallel version of the pi.c / pi.f90
code to calculate the value of pi using omp for and reduction operations.
code to calculate the value of
&
pi
;
using omp for and reduction operations.
Instructions: Create a new parallel versions of the pi.c / pi.f90 program using
Instructions: Create a new parallel versions of the pi.c / pi.f90 program using
the parallel construct
``#pragma omp for``
and
``reduction``
operation. Run the new
the parallel construct
``#pragma omp for``
and
``reduction``
operation. Run the new
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment