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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pdc-summer-school
openmp-lab-exercises
Commits
90ca39c7
Commit
90ca39c7
authored
Aug 24, 2018
by
Xin Li
Browse files
Options
Downloads
Patches
Plain Diff
updated intro_lab instruction
parent
d65dd711
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
intro_lab/README.md
+6
-6
6 additions, 6 deletions
intro_lab/README.md
intro_lab/hello.c
+3
-2
3 additions, 2 deletions
intro_lab/hello.c
intro_lab/pi.c
+17
-20
17 additions, 20 deletions
intro_lab/pi.c
with
26 additions
and
28 deletions
intro_lab/README.md
+
6
−
6
View file @
90ca39c7
...
...
@@ -94,7 +94,7 @@ Questions:
-
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?
## Exercise 2 - Creating Threads: calculate π in parallel using
only
pragma omp parallel
## Exercise 2 - Creating Threads: calculate π in parallel using pragma omp parallel
_Concepts: Parallel, default data environment, runtime library calls_
...
...
@@ -213,15 +213,15 @@ Questions:
-
What would happen if you hadn’t used critical or atomic a shared variable?
-
How does the execution time change varying the number of threads? Is it what
you expected?
-
Do the two version of the code
s
differ in performance? If so, what do you
think
it
is the reason?
-
Do the two version
s
of the code differ in performance? If so, what do you
think is the reason?
## Exercise 4 - Calculate π with a loop and a reduction
_Concepts: worksharing, parallel loop, schedule, reduction_
Here we are going to implement a fourth parallel version of the pi.c / pi.f90
code to calculate the value of
π
using omp for and reduction operations.
code to calculate the value of
π
using
``
omp for
``
and
``
reduction
``
operations.
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
...
...
@@ -231,7 +231,7 @@ the execution time for 1, 2, 4, 8, 16, 32 threads.
Hints:
To change the schedule, you can either change the environment variable with
-
To change the schedule, you can either change the environment variable with
``export OMP_SCHEDULE=type``
where
``type``
can be any of static, dynamic, guided or in
the source code as
``omp parallel for schedule(type)``
.
...
...
@@ -239,5 +239,5 @@ Questions:
-
What is the scheduling that provides the best performance? What is the reason for that?
-
What is the fastest parallel implementation of pi.c / pi.f90 program? What is
the reason for being the fastest? What would be an even faster implementation
the reason for
it
being the fastest? What would be an even faster implementation
of pi.c / pi.f90 program?
This diff is collapsed.
Click to expand it.
intro_lab/hello.c
+
3
−
2
View file @
90ca39c7
#include
<stdio.h>
int
main
()
{
int
ID
=
0
;
//
thread
id
int
thread
_
id
=
0
;
printf
(
"Hello World from thread %d
\n
"
,
ID
);
printf
(
"Hello World from thread %d
\n
"
,
thread_id
);
}
This diff is collapsed.
Click to expand it.
intro_lab/pi.c
+
17
−
20
View file @
90ca39c7
...
...
@@ -13,10 +13,13 @@ from the OpenMP runtime library
History: Written by Tim Mattson, 11/99.
*/
#include
<stdio.h>
#include
<omp.h>
static
long
num_steps
=
100000000
;
double
step
;
int
main
()
{
int
i
;
...
...
@@ -25,7 +28,6 @@ int main ()
step
=
1
.
0
/
(
double
)
num_steps
;
start_time
=
omp_get_wtime
();
for
(
i
=
1
;
i
<=
num_steps
;
i
++
){
...
...
@@ -37,8 +39,3 @@ int main ()
run_time
=
omp_get_wtime
()
-
start_time
;
printf
(
"
\n
pi with %ld steps is %lf in %lf seconds
\n
"
,
num_steps
,
pi
,
run_time
);
}
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
sign in
to comment