Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2021
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
lecture-HPC
2021
Commits
270e1430
Commit
270e1430
authored
3 years ago
by
thierry
Browse files
Options
Downloads
Patches
Plain Diff
Update
parent
4eea90d8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
openmp/1-intro-critical.cpp
+20
-0
20 additions, 0 deletions
openmp/1-intro-critical.cpp
openmp/1-intro-mutex.cpp
+32
-0
32 additions, 0 deletions
openmp/1-intro-mutex.cpp
openmp/1-intro.cpp
+4
-1
4 additions, 1 deletion
openmp/1-intro.cpp
with
56 additions
and
1 deletion
openmp/1-intro-critical.cpp
0 → 100644
+
20
−
0
View file @
270e1430
#include
<iostream>
#include
<omp.h>
int
main
(
int
argc
,
char
**
argv
)
{
#pragma omp parallel num_threads(3)
#pragma omp critical
std
::
cout
<<
"Parallel region 1: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
#pragma omp parallel num_threads(4)
#pragma omp critical
std
::
cout
<<
"Parallel region 2: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
#pragma omp parallel num_threads(2)
#pragma omp critical
std
::
cout
<<
"Parallel region 3: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
}
This diff is collapsed.
Click to expand it.
openmp/1-intro-mutex.cpp
0 → 100644
+
32
−
0
View file @
270e1430
#include
<iostream>
#include
<omp.h>
int
main
(
int
argc
,
char
**
argv
)
{
omp_lock_t
writelock
;
omp_init_lock
(
&
writelock
);
#pragma omp parallel num_threads(3)
{
omp_set_lock
(
&
writelock
);
std
::
cout
<<
"Parallel region 1: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
omp_unset_lock
(
&
writelock
);
}
#pragma omp parallel num_threads(4)
{
omp_set_lock
(
&
writelock
);
std
::
cout
<<
"Parallel region 2: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
omp_unset_lock
(
&
writelock
);
}
#pragma omp parallel num_threads(2)
{
omp_set_lock
(
&
writelock
);
std
::
cout
<<
"Parallel region 3: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
omp_unset_lock
(
&
writelock
);
}
}
This diff is collapsed.
Click to expand it.
openmp/1-intro.cpp
+
4
−
1
View file @
270e1430
#include
<iostream>
#include
<iostream>
#include
<omp.h>
#include
<omp.h>
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
#pragma omp parallel num_threads(3)
#pragma omp parallel num_threads(3)
std
::
cout
<<
"Parallel region 1: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
std
::
cout
<<
"Parallel region 1: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
...
@@ -12,3 +14,4 @@ int main()
...
@@ -12,3 +14,4 @@ int main()
#pragma omp parallel num_threads(2)
#pragma omp parallel num_threads(2)
std
::
cout
<<
"Parallel region 3: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
std
::
cout
<<
"Parallel region 3: tid:"
<<
omp_get_thread_num
()
<<
std
::
endl
;
}
}
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