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
Causes the compiler to process [`#pragma omp`](../../preprocessor/omp.md) directives in support of OpenMP.
12
11
13
12
## Syntax
14
13
15
14
::: moniker range=">= msvc-160"
16
15
17
-
> **/openmp**\[**:**__experimental__]
16
+
> **`/openmp`**\
17
+
> **`/openmp:experimental`**\
18
+
> **`/openmp:llvm`**
18
19
19
20
::: moniker-end
20
21
21
22
::: moniker range="<= msvc-150"
22
23
23
-
> **/openmp**
24
+
> **`/openmp`**
24
25
25
26
::: moniker-end
26
27
27
28
## Remarks
28
29
29
-
`#pragma omp` is used to specify [Directives](../../parallel/openmp/reference/openmp-directives.md) and [Clauses](../../parallel/openmp/reference/openmp-clauses.md). If **/openmp** isn't specified in a compilation, the compiler ignores OpenMP clauses and directives. [OpenMP Function](../../parallel/openmp/reference/openmp-functions.md) calls are processed by the compiler even if **/openmp** isn't specified.
30
+
`#pragma omp` is used to specify [Directives](../../parallel/openmp/reference/openmp-directives.md) and [Clauses](../../parallel/openmp/reference/openmp-clauses.md). If **`/openmp`** isn't specified in a compilation, the compiler ignores OpenMP clauses and directives. [OpenMP Function](../../parallel/openmp/reference/openmp-functions.md) calls are processed by the compiler even if **`/openmp`** isn't specified.
30
31
31
32
::: moniker range=">= msvc-160"
32
33
33
-
The C++ compiler currently supports the OpenMP 2.0 standard. However, Visual Studio 2019 also now offers SIMD functionality. To use SIMD, compile by using the **/openmp:experimental** option. This option enables both the usual OpenMP features, and additional OpenMP SIMD features not available when using the **/openmp** switch.
34
+
The C++ compiler currently supports the OpenMP 2.0 standard. However, Visual Studio 2019 also now offers SIMD functionality. To use SIMD, compile by using the **`/openmp:experimental`** option. This option enables both the usual OpenMP features, and OpenMP SIMD features not available when using the **`/openmp`** switch.
35
+
36
+
Starting in Visual Studio 2019 version 16.9, you can use the experimental **`/openmp:llvm`** option instead of **`/openmp`** to target the LLVM OpenMP runtime. Support currently isn't available for production code, since the required libomp DLLs aren't redistributable. The option supports the same OpenMP 2.0 directives as **`/openmp`**. And, it supports all the SIMD directives supported by the **`/openmp:experimental`** option. It also supports unsigned integer indices in parallel for loops according to the OpenMP 3.0 standard. For more information, see [Improved OpenMP Support for C++ in Visual Studio](https://devblogs.microsoft.com/cppblog/improved-openmp-support-for-cpp-in-visual-studio/).
37
+
38
+
Currently, the **`/openmp:llvm`** option only works on the x64 architecture. The option isn't compatible with **`/clr`** or **`/ZW`**.
34
39
35
40
::: moniker-end
36
41
37
-
Applications compiled by using both **/openmp** and **/clr** can only be run in a single application domain process. Multiple application domains aren't supported. That is, when the module constructor (`.cctor`) is run, it detects if the process is compiled using **/openmp**, and if the app is loaded into a non-default runtime. For more information, see [appdomain](../../cpp/appdomain.md), [/clr (Common Language Runtime Compilation)](clr-common-language-runtime-compilation.md), and [Initialization of Mixed Assemblies](../../dotnet/initialization-of-mixed-assemblies.md).
42
+
Applications compiled by using both **`/openmp`** and **`/clr`** can only be run in a single application domain process. Multiple application domains aren't supported. That is, when the module constructor (`.cctor`) is run, it detects if the process is compiled using **`/openmp`**, and if the app is loaded into a non-default runtime. For more information, see [`appdomain`](../../cpp/appdomain.md), [`/clr` (Common Language Runtime Compilation)](clr-common-language-runtime-compilation.md), and [Initialization of Mixed Assemblies](../../dotnet/initialization-of-mixed-assemblies.md).
38
43
39
-
If you attempt to load an app compiled using both **/openmp** and **/clr** into a non-default application domain, a <xref:System.TypeInitializationException> exception is thrown outside the debugger, and a `OpenMPWithMultipleAppdomainsException` exception is thrown in the debugger.
44
+
If you attempt to load an app compiled using both **`/openmp`** and **`/clr*`* into a non-default application domain, a <xref:System.TypeInitializationException> exception is thrown outside the debugger, and a `OpenMPWithMultipleAppdomainsException` exception is thrown in the debugger.
40
45
41
46
These exceptions can also be raised in the following situations:
42
47
43
-
- If your application is compiled using **/clr** but not **/openmp**, and is loaded into a non-default application domain, where the process includes an app compiled using **/openmp**.
48
+
- If your application is compiled using **`/clr`** but not **`/openmp`**, and is loaded into a non-default application domain, where the process includes an app compiled using **`/openmp`**.
44
49
45
-
- If you pass your **/clr** app to a utility, such as [regasm.exe](/dotnet/framework/tools/regasm-exe-assembly-registration-tool), which loads its target assemblies into a non-default application domain.
50
+
- If you pass your **`/clr`** app to a utility, such as [regasm.exe](/dotnet/framework/tools/regasm-exe-assembly-registration-tool), which loads its target assemblies into a non-default application domain.
46
51
47
52
The common language runtime's code access security doesn't work in OpenMP regions. If you apply a CLR code access security attribute outside a parallel region, it won't be in effect in the parallel region.
48
53
49
-
Microsoft doesn't recommend that you write **/openmp** apps that allow partially trusted callers. Don't use <xref:System.Security.AllowPartiallyTrustedCallersAttribute>, or any CLR code access security attributes.
54
+
Microsoft doesn't recommend that you write **`/openmp`** apps that allow partially trusted callers. Don't use <xref:System.Security.AllowPartiallyTrustedCallersAttribute>, or any CLR code access security attributes.
50
55
51
56
### To set this compiler option in the Visual Studio development environment
52
57
@@ -64,9 +69,9 @@ Microsoft doesn't recommend that you write **/openmp** apps that allow partially
64
69
65
70
The following sample shows some of the effects of thread pool startup versus using the thread pool after it has started. Assuming an x64, single core, dual processor, the thread pool takes about 16 ms to start up. After that, there's little extra cost for the thread pool.
66
71
67
-
When you compile using **/openmp**, the second call to test2 never runs any longer than if you compile using **/openmp-**, as there's no thread pool startup. At a million iterations, the **/openmp** version is faster than the **/openmp-** version for the second call to test2. At 25 iterations, both **/openmp-** and **/openmp** versions register less than the clock granularity.
72
+
When you compile using **`/openmp`**, the second call to test2 never runs any longer than if you compile using **`/openmp-`**, as there's no thread pool startup. At a million iterations, the **`/openmp`** version is faster than the **`/openmp-`** version for the second call to test2. At 25 iterations, both **`/openmp-`** and **`/openmp`** versions register less than the clock granularity.
68
73
69
-
If you have only one loop in your application and it runs in less than 15 ms (adjusted for the approximate overhead on your machine), **/openmp** may not be appropriate. If it's higher, you may want to consider using **/openmp**.
74
+
If you have only one loop in your application and it runs in less than 15 ms (adjusted for the approximate overhead on your machine), **`/openmp`** may not be appropriate. If it's higher, you may want to consider using **`/openmp`**.
70
75
71
76
```cpp
72
77
// cpp_compiler_options_openmp.cpp
@@ -114,6 +119,6 @@ int main(int argc, char* argv[]) {
0 commit comments