FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Examples/program_control/pause_resource.tex at main · OpenMP/Examples · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
OpenMP
/
Examples
Public
Notifications
You must be signed in to change notification settings
Fork
68
Star
264
Code
Issues
8
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Examples
/
program_control
/
pause_resource.tex
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (40 loc) · 2.34 KB
Breadcrumbs
Examples
/
program_control
/
pause_resource.tex
Copy path
File metadata and controls
44 lines (40 loc) · 2.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
%
\pagebreak
\section
{
\kcode
{omp_pause_resource} and
\\
\kcode
{omp_pause_resource_all} Routines
}
\label
{
sec:pause_resource
}
\index
{routines!omp_pause_resource@
\kcode
{omp_pause_resource}}
\index
{omp_pause_resource routine@
\kcode
{omp_pause_resource} routine}
\index
{routines!omp_get_max_threads@
\kcode
{omp_get_max_threads}}
\index
{omp_get_max_threads routine@
\kcode
{omp_get_max_threadsi} routine}
\index
{routines!omp_get_initial_device@
\kcode
{omp_get_initial_device}}
\index
{omp_get_initial_device routine@
\kcode
{omp_get_initial_device} routine}
Sometimes, it is necessary to relinquish resources created or allocated
for the OpenMP runtime environment to avoid interference with subsequent
actions as illustrated by the following example. In the beginning
either a call to the
\kcode
{omp_get_max_threads} routine
or the subsequent
\kcode
{parallel} construct may trigger resource allocation
by the OpenMP runtime, which may cause unexpected side effects
for the subsequent
\ucode
{fork} call.
It is desirable to relinquish OpenMP resources allocated before
the fork by using the
\kcode
{omp_pause_resource} routine for a given
device, in this case the host device. The host device number is returned by
the
\kcode
{omp_get_initial_device} routine.
The
\kcode
{omp_pause_hard} value is used here to free as many
OpenMP resources as possible.
After the fork, the child process will initialize its OpenMP runtime
environment when encountering the
\kcode
{parallel} construct.
\cexample
[5.0]{pause_resource}{1}
\index
{routines!omp_pause_resource_all@
\kcode
{omp_pause_resource_all}}
\index
{omp_pause_resource_all routine@
\kcode
{omp_pause_resource_all} routine}
The following example illustrates a different use case.
After executing the first parallel code (parallel region 1),
the
\ucode
{relinquish} program switches to executing an external parallel program
(called
\ucode
{subprogram}, which is compiled from
\example
{pause_resource.2b}).
In order to make resources available for the external
subprogram,
\ucode
{relinquish} calls
\kcode
{omp_pause_resource_all}
to relinquish OpenMP resources used by the current program before
calling
\ucode
{execute_command_line} to execute
\ucode
{subprogram}.
The
\kcode
{omp_pause_soft} value is used here to allow subsequent
OpenMP regions (parallel region 2) to restart more quickly.
\ffreeexample
[5.0]{pause_resource}{2a}
\ffreeexample
{pause_resource}{2b}
Back
|
FazBrowse Home
|
New Git URL