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/3-run-time-library-functions.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: "3. Run-time library functions"
3
-
ms.date: "01/17/2019"
3
+
ms.date: "05/13/2019"
4
4
ms.assetid: b226e512-6822-4cbe-a2ca-74cc2bb7e880
5
5
---
6
6
# 3. Run-time library functions
@@ -49,6 +49,8 @@ This function has the effects described above when called from a portion of the
49
49
50
50
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.
51
51
52
+
For more information, see [omp_set_dynamic](#317-omp_set_dynamic-function).
53
+
52
54
#### Cross-references
53
55
54
56
- [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
69
71
70
72
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.
71
73
74
+
For more information, see [omp_set_dynamic](#317-omp_set_dynamic-function).
@@ -159,6 +163,12 @@ A call to `omp_set_dynamic` has precedence over the `OMP_DYNAMIC` environment va
159
163
160
164
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.
161
165
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.
@@ -174,7 +184,7 @@ The `omp_get_dynamic` function returns a nonzero value if dynamic adjustment of
174
184
int omp_get_dynamic(void);
175
185
```
176
186
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).
0 commit comments