Skip to content

Commit ac56693

Browse files
author
Colin Robertson
committed
Add /openmp:llvm compiler switch docs
1 parent 3621c02 commit ac56693

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

docs/build/reference/openmp-enable-openmp-2-0-support.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,57 @@
11
---
22
description: "Learn more about: /openmp (Enable OpenMP Support)"
33
title: "/openmp (Enable OpenMP Support)"
4-
ms.date: "04/15/2019"
5-
f1_keywords: ["/openmp", "VC.Project.VCCLCompilerTool.OpenMP"]
6-
helpviewer_keywords: ["/openmp compiler option [C++]", "-openmp compiler option [C++]"]
7-
ms.assetid: 9082b175-18d3-4378-86a7-c0eb95664e13
4+
ms.date: 04/01/2021
5+
f1_keywords: ["/openmp", "/openmp:experimental", "/openmp:llvm", "VC.Project.VCCLCompilerTool.OpenMP"]
6+
helpviewer_keywords: ["/openmp compiler option [C++]", "/openmp:experimental compiler option [C++]", "/openmp:llvm compiler option [C++]", "-openmp compiler option [C++]"]
87
---
9-
# /openmp (Enable OpenMP Support)
8+
# `/openmp` (Enable OpenMP Support)
109

1110
Causes the compiler to process [`#pragma omp`](../../preprocessor/omp.md) directives in support of OpenMP.
1211

1312
## Syntax
1413

1514
::: moniker range=">= msvc-160"
1615

17-
> **/openmp**\[**:**__experimental__]
16+
> **`/openmp`**\
17+
> **`/openmp:experimental`**\
18+
> **`/openmp:llvm`**
1819
1920
::: moniker-end
2021

2122
::: moniker range="<= msvc-150"
2223

23-
> **/openmp**
24+
> **`/openmp`**
2425
2526
::: moniker-end
2627

2728
## Remarks
2829

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.
3031

3132
::: moniker range=">= msvc-160"
3233

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`**.
3439

3540
::: moniker-end
3641

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).
3843

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.
4045

4146
These exceptions can also be raised in the following situations:
4247

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`**.
4449

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.
4651

4752
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.
4853

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.
5055

5156
### To set this compiler option in the Visual Studio development environment
5257

@@ -64,9 +69,9 @@ Microsoft doesn't recommend that you write **/openmp** apps that allow partially
6469

6570
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.
6671

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.
6873

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`**.
7075

7176
```cpp
7277
// cpp_compiler_options_openmp.cpp
@@ -114,6 +119,6 @@ int main(int argc, char* argv[]) {
114119
115120
## See also
116121
117-
[MSVC Compiler Options](compiler-options.md) \
118-
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md) \
122+
[MSVC compiler options](compiler-options.md) \
123+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md) \
119124
[OpenMP in MSVC](../../parallel/openmp/openmp-in-visual-cpp.md)

0 commit comments

Comments
 (0)