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).
10
+
Causes the compiler to process [`#pragmaomp`](../../preprocessor/omp.md) directives in support of OpenMP.
11
11
12
12
## Syntax
13
13
14
-
```
15
-
/openmp
16
-
```
14
+
::: moniker range=">= vs-2019"
15
+
16
+
> **/openmp**[**:**__experimental__]
17
+
18
+
::: moniker-end
19
+
20
+
::: moniker range="<= vs-2017"
21
+
22
+
> **/openmp**
23
+
24
+
::: moniker-end
17
25
18
26
## Remarks
19
27
20
28
`#pragma omp` is used to specify [Directives](../../parallel/openmp/reference/openmp-directives.md) and [Clauses](../../parallel/openmp/reference/openmp-clauses.md). If **/openmp** is not 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** is not specified.
21
29
22
-
Applications compiled with **/openmp** and **/clr** can only be run in a single application domain process; multiple application domains are not supported. That is, when the module constructor (.cctor) is run, it will detect the process is compiled with **/openmp** and if the application is being 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).
30
+
::: moniker range=">= vs-2019"
23
31
24
-
If you attempt to load an application compiled with **/openmp** and **/clr** into a non-default application domain, a <xref:System.TypeInitializationException> exception will be thrown outside the debugger and a OpenMPWithMultipleAppdomainsException exception will be thrown in the debugger.
32
+
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.
33
+
34
+
::: moniker-end
35
+
36
+
Applications compiled by using both **/openmp** and **/clr** can only be run in a single application domain process; multiple application domains are not supported. That is, when the module constructor (.cctor) is run, it detects if the process is compiled with **/openmp**, and if the application 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).
37
+
38
+
If you attempt to load an application compiled with **/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.
25
39
26
40
These exceptions can also be raised in the following situations:
27
41
28
-
- If your application compiled with **/clr**, but not with **/openmp**, is loaded into a non-default application domain but where the process includes an application that was compiled with **/openmp**.
42
+
- If your application is compiled with **/clr** but not **/openmp**, and is loaded into a non-default application domain, where the process includes an application that was compiled with **/openmp**.
29
43
30
-
- If you pass your **/clr** application to a utility, such as regasm.exe ([Regasm.exe (Assembly Registration Tool)](/dotnet/framework/tools/regasm-exe-assembly-registration-tool)), which loads its target assemblies into a non-default application domain.
44
+
- If you pass your **/clr** application 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.
31
45
32
46
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.
33
47
34
-
Microsoft advises that you do not write **/openmp** applications that allows partially trusted callers, using <xref:System.Security.AllowPartiallyTrustedCallersAttribute>, or any CLR code access security attributes.
48
+
Microsoft doesn't recommend that you write **/openmp** applications that allow partially trusted callers, using <xref:System.Security.AllowPartiallyTrustedCallersAttribute>, or any CLR code access security attributes.
35
49
36
50
### To set this compiler option in the Visual Studio development environment
37
51
38
52
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
@@ -57,7 +67,7 @@ When you compile with **/openmp**, the second call to test2 never runs any longe
57
67
58
68
So if you have only one loop in your application and it runs in less than 15ms (adjusted for the approximate overhead on your machine), **/openmp** may not be appropriate, but if it's anything more than that, you may want to consider using **/openmp**.
59
69
60
-
```
70
+
```cpp
61
71
// cpp_compiler_options_openmp.cpp
62
72
#include<omp.h>
63
73
#include<stdio.h>
@@ -103,5 +113,6 @@ int main(int argc, char* argv[]) {
0 commit comments