You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/parallel/openmp/4-environment-variables.md
+78-9Lines changed: 78 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,21 +9,90 @@ This chapter describes the OpenMP C and C++ API environment variables (or equiva
9
9
10
10
The environment variables are as follows:
11
11
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.
13
13
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.
15
15
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.
17
17
18
-
-**OMP_NESTED** enables or disables nested parallelism.
18
+
-[OMP_NESTED](#4-4-omp-nested) enables or disables nested parallelism.
19
19
20
20
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:
21
21
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.
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
+
```
24
95
25
-
ksh:
26
-
export OMP_SCHEDULE="dynamic"
96
+
### Cross-reference
27
97
28
-
DOS:
29
-
set OMP_SCHEDULE="dynamic"
98
+
-[omp_set_nested](3-1-9-omp-set-nested-function.md) function
0 commit comments