Skip to content

Commit 0e73194

Browse files
Consolidated chapter 4.
1 parent 1e085a0 commit 0e73194

File tree

5 files changed

+78
-98
lines changed

5 files changed

+78
-98
lines changed

docs/parallel/openmp/4-1-omp-schedule.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/parallel/openmp/4-2-omp-num-threads.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/parallel/openmp/4-3-omp-dynamic.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

docs/parallel/openmp/4-4-omp-nested.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs/parallel/openmp/4-environment-variables.md

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,90 @@ This chapter describes the OpenMP C and C++ API environment variables (or equiva
99

1010
The environment variables are as follows:
1111

12-
- **OMP_SCHEDULE** sets the run-time schedule type and chunk size.
12+
- [OMP_SCHEDULE](#4-1-omp-schedule) sets the run-time schedule type and chunk size.
1313

14-
- **OMP_NUM_THREADS** sets the number of threads to use during execution.
14+
- [OMP_NUM_THREADS](#4-2-omp-num-threads) sets the number of threads to use during execution.
1515

16-
- **OMP_DYNAMIC** enables or disables dynamic adjustment of the number of threads.
16+
- [OMP_DYNAMIC](#4-3-omp-dynamic) enables or disables dynamic adjustment of the number of threads.
1717

18-
- **OMP_NESTED** enables or disables nested parallelism.
18+
- [OMP_NESTED](#4-4-omp-nested) enables or disables nested parallelism.
1919

2020
The examples in this chapter only demonstrate how these variables might be set in Unix C shell (csh) environments. In Korn shell and DOS environments the actions are similar, as follows:
2121

22-
csh:
22+
csh:
23+
`setenv OMP_SCHEDULE "dynamic"`
24+
25+
ksh:
26+
`export OMP_SCHEDULE="dynamic"`
27+
28+
DOS:
29+
`set OMP_SCHEDULE="dynamic"`
30+
31+
## 4.1 OMP_SCHEDULE
32+
33+
`OMP_SCHEDULE` applies only to `for` and `parallel for` directives that have the schedule type `runtime`. The schedule type and chunk size for all such loops can be set at run time by setting this environment variable to any of the recognized schedule types and to an optional *chunk_size*.
34+
35+
For `for` and `parallel for` directives that have a schedule type other than `runtime`, `OMP_SCHEDULE` is ignored. The default value for this environment variable is implementation-defined. If the optional *chunk_size* is set, the value must be positive. If *chunk_size* is not set, a value of 1 is assumed, except in the case of a `static` schedule. For a `static` schedule, the default chunk size is set to the loop iteration space divided by the number of threads applied to the loop.
36+
37+
Example:
38+
39+
```shell
40+
setenv OMP_SCHEDULE "guided,4"
2341
setenv OMP_SCHEDULE "dynamic"
42+
```
43+
44+
### Cross-references
45+
46+
- [for](2-4-1-for-construct.md) directive
47+
- [parallel for](2-5-1-parallel-for-construct.md) directive
48+
49+
## 4.2 OMP_NUM_THREADS
50+
51+
The `OMP_NUM_THREADS` environment variable sets the default number of threads to use during execution, unless that number is explicitly changed by calling the `omp_set_num_threads` library routine or by an explicit `num_threads` clause on a `parallel` directive.
52+
53+
The value of the `OMP_NUM_THREADS` environment variable must be a positive integer. Its effect depends upon whether dynamic adjustment of the number of threads is enabled. For a comprehensive set of rules about the interaction between the `OMP_NUM_THREADS` environment variable and dynamic adjustment of threads, see Section 2.3.
54+
55+
If no value is specified for the `OMP_NUM_THREADS` environment variable, or if the value specified is not a positive integer, or if the value is greater than the maximum number of threads the system can support, the number of threads to use is implementation-defined.
56+
57+
Example:
58+
59+
```shell
60+
setenv OMP_NUM_THREADS 16
61+
```
62+
63+
### Cross-references
64+
65+
- [num_threads](2-3-parallel-construct.md) clause
66+
- [omp_set_num_threads](3-1-1-omp-set-num-threads-function.md) function
67+
- [omp_set_dynamic](3-1-7-omp-set-dynamic-function.md) function
68+
69+
## 4.3 OMP_DYNAMIC
70+
71+
The `OMP_DYNAMIC` environment variable enables or disables dynamic adjustment of the number of threads available for execution of parallel regions unless dynamic adjustment is explicitly enabled or disabled by calling the `omp_set_dynamic` library routine. Its value must be `TRUE` or `FALSE`.
72+
73+
If set to `TRUE`, the number of threads that are used for executing parallel regions may be adjusted by the runtime environment to best utilize system resources. If set to `FALSE`, dynamic adjustment is disabled. The default condition is implementation-defined.
74+
75+
Example:
76+
77+
```shell
78+
setenv OMP_DYNAMIC TRUE
79+
```
80+
81+
### Cross-references
82+
83+
- [Parallel regions](2-3-parallel-construct.md)
84+
- [omp_set_dynamic](3-1-7-omp-set-dynamic-function.md) function
85+
86+
## 4.4 OMP_NESTED
87+
88+
The `OMP_NESTED` environment variable enables or disables nested parallelism unless nested parallelism is enabled or disabled by calling the `omp_set_nested` library routine. If set to `TRUE`, nested parallelism is enabled; if it is set to `FALSE`, nested parallelism is disabled. The default value is `FALSE`.
89+
90+
Example:
91+
92+
```shell
93+
setenv OMP_NESTED TRUE
94+
```
2495

25-
ksh:
26-
export OMP_SCHEDULE="dynamic"
96+
### Cross-reference
2797

28-
DOS:
29-
set OMP_SCHEDULE="dynamic"
98+
- [omp_set_nested](3-1-9-omp-set-nested-function.md) function

0 commit comments

Comments
 (0)