Skip to content

Commit 6271d98

Browse files
authored
Merge pull request MicrosoftDocs#1997 from mikeblome/mb-openmp
fix for GH issue997 re omp_set_dynamic
2 parents 8a891c6 + 08de974 commit 6271d98

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

docs/parallel/openmp/3-run-time-library-functions.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "3. Run-time library functions"
3-
ms.date: "01/17/2019"
3+
ms.date: "05/13/2019"
44
ms.assetid: b226e512-6822-4cbe-a2ca-74cc2bb7e880
55
---
66
# 3. Run-time library functions
@@ -49,6 +49,8 @@ This function has the effects described above when called from a portion of the
4949
5050
This call has precedence over the `OMP_NUM_THREADS` environment variable. The default value for the number of threads, which may be established by calling `omp_set_num_threads` or by setting the `OMP_NUM_THREADS` environment variable, can be explicitly overridden on a single `parallel` directive by specifying the `num_threads` clause.
5151
52+
For more information, see [omp_set_dynamic](#317-omp_set_dynamic-function).
53+
5254
#### Cross-references
5355
5456
- [omp_set_dynamic](#317-omp_set_dynamic-function) function
@@ -69,6 +71,8 @@ The `num_threads` clause, the `omp_set_num_threads` function, and the `OMP_NUM_T
6971

7072
If the number of threads hasn't been explicitly set by the user, the default is implementation-defined. This function binds to the closest enclosing `parallel` directive. If called from a serial portion of a program, or from a nested parallel region that's serialized, this function returns 1.
7173

74+
For more information, see [omp_set_dynamic](#317-omp_set_dynamic-function).
75+
7276
#### Cross-references
7377

7478
- [OMP_NUM_THREADS](4-environment-variables.md#42-omp_num_threads)
@@ -159,6 +163,12 @@ A call to `omp_set_dynamic` has precedence over the `OMP_DYNAMIC` environment va
159163
160164
The default for the dynamic adjustment of threads is implementation-defined. As a result, user codes that depend on a specific number of threads for correct execution should explicitly disable dynamic threads. Implementations aren't required to provide the ability to dynamically adjust the number of threads, but they're required to provide the interface to support portability across all platforms.
161165
166+
#### Microsoft specific
167+
168+
The current support of `omp_get_dynamic` and `omp_set_dynamic` is as follows:
169+
170+
The input parameter to `omp_set_dynamic` does not affect the threading policy and does not change the number of threads. `omp_get_num_threads` always returns either the user-defined number, if that is set, or the default thread number. In the current Microsoft implementation, `omp_set_dynamic(0)` turns off dynamic threading so that the existing set of threads can be reused for the following parallel region. `omp_set_dynamic(1)` turns on dynamic threading by discarding the existing set of threads and creating a new set for the upcoming parallel region. The number of threads in the new set is the same as the old set, and is based on the return value of `omp_get_num_threads`. Therefore, for best performance, use `omp_set_dynamic(0)` to reuse the existing threads.
171+
162172
#### Cross-references
163173
164174
- [omp_get_num_threads](#312-omp_get_num_threads-function)
@@ -174,7 +184,7 @@ The `omp_get_dynamic` function returns a nonzero value if dynamic adjustment of
174184
int omp_get_dynamic(void);
175185
```
176186

177-
If the implementation doesn't implement dynamic adjustment of the number of threads, this function always returns 0.
187+
If the implementation doesn't implement dynamic adjustment of the number of threads, this function always returns 0. For more information, see [omp_set_dynamic](#317-omp_set_dynamic-function).
178188

179189
#### Cross-references
180190

0 commit comments

Comments
 (0)