From 5c6fe242576c7dd70b99a6137bd32b1743d78861 Mon Sep 17 00:00:00 2001 From: Colin Robertson Date: Mon, 15 Apr 2019 14:18:57 -0700 Subject: [PATCH 1/6] Fix issues found in LNK4286 addition --- .../tool-errors/linker-tools-warning-lnk4049.md | 6 ++++-- .../tool-errors/linker-tools-warning-lnk4217.md | 12 ++++++++++-- .../tool-errors/linker-tools-warning-lnk4286.md | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md b/docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md index 76b60d97867..71f1025bd48 100644 --- a/docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md +++ b/docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md @@ -1,6 +1,6 @@ --- title: "Linker Tools Warning LNK4049" -ms.date: "04/09/2019" +ms.date: "04/15/2019" f1_keywords: ["LNK4049"] helpviewer_keywords: ["LNK4049"] ms.assetid: 5fd5fb24-c860-4149-a557-0ac26a65d97c @@ -9,7 +9,9 @@ ms.assetid: 5fd5fb24-c860-4149-a557-0ac26a65d97c > symbol '*symbol*' defined in '*filename.obj*' is imported -The symbol was both exported from and imported to the program. +[__declspec(dllimport)](../../cpp/dllexport-dllimport.md) was specified for *symbol* even though the symbol is defined in object file *filename.obj* in the same image. Remove the `__declspec(dllimport)` modifier to resolve this warning. + +## Remarks This warning is generated by the linker when you define a symbol in one object file and reference it by using the `__declspec(dllimport)` declaration modifier in another. diff --git a/docs/error-messages/tool-errors/linker-tools-warning-lnk4217.md b/docs/error-messages/tool-errors/linker-tools-warning-lnk4217.md index 6c95de6ea14..462909e2646 100644 --- a/docs/error-messages/tool-errors/linker-tools-warning-lnk4217.md +++ b/docs/error-messages/tool-errors/linker-tools-warning-lnk4217.md @@ -1,6 +1,6 @@ --- title: "Linker Tools Warning LNK4217" -ms.date: "04/09/2019" +ms.date: "04/15/2019" f1_keywords: ["LNK4217"] helpviewer_keywords: ["LNK4217"] ms.assetid: 280dc03e-5933-4e8d-bb8c-891fbe788738 @@ -11,6 +11,8 @@ ms.assetid: 280dc03e-5933-4e8d-bb8c-891fbe788738 [__declspec(dllimport)](../../cpp/dllexport-dllimport.md) was specified for a symbol even though the symbol is defined in an object file in the same image. Remove the `__declspec(dllimport)` modifier to resolve this warning. +## Remarks + *symbol* is the symbol name that's defined within the image. *function* is the function that's importing the symbol. This warning doesn't appear when you compile by using the [/clr](../../build/reference/clr-common-language-runtime-compilation.md) option. @@ -33,4 +35,10 @@ And then, __declspec(dllexport) void func(unsigned short*) {} ``` -Attempting to link these two modules will result in LNK4217. Compile the second sample with the import library of the first sample to resolve. \ No newline at end of file +Attempting to link these two modules will result in LNK4217. Compile the second sample with the import library of the first sample to resolve. + +## See also + +[Linker Tools Warning LNK4049](linker-tools-warning-lnk4049.md) \ +[Linker Tools Warning LNK4286](linker-tools-warning-lnk4286.md) \ +[dllexport, dllimport](../../cpp/dllexport-dllimport.md) \ No newline at end of file diff --git a/docs/error-messages/tool-errors/linker-tools-warning-lnk4286.md b/docs/error-messages/tool-errors/linker-tools-warning-lnk4286.md index 725eebef072..904ee7fb37b 100644 --- a/docs/error-messages/tool-errors/linker-tools-warning-lnk4286.md +++ b/docs/error-messages/tool-errors/linker-tools-warning-lnk4286.md @@ -1,6 +1,6 @@ --- title: "Linker Tools Warning LNK4286" -ms.date: "04/09/2019" +ms.date: "04/15/2019" f1_keywords: ["LNK4286"] helpviewer_keywords: ["LNK4286"] --- @@ -23,5 +23,5 @@ For more information on import and export data declarations, see [dllexport, dll ## See also [Linker Tools Warning LNK4049](linker-tools-warning-lnk4049.md) \ -[Linker Tools Warning LNK4286](linker-tools-warning-lnk4286.md) \ +[Linker Tools Warning LNK4217](linker-tools-warning-lnk4217.md) \ [dllexport, dllimport](../../cpp/dllexport-dllimport.md) \ No newline at end of file From 127742debc65a8de7541eeb07bacaf58a42368d3 Mon Sep 17 00:00:00 2001 From: Colin Robertson Date: Mon, 15 Apr 2019 14:26:46 -0700 Subject: [PATCH 2/6] which -> that --- docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md b/docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md index 71f1025bd48..9147752a770 100644 --- a/docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md +++ b/docs/error-messages/tool-errors/linker-tools-warning-lnk4049.md @@ -27,7 +27,7 @@ To resolve LNK4049, try one of the following procedures: - Remove the `__declspec(dllimport)` modifier from the forward declaration of the symbol that triggered LNK4049. You can search for symbols within a binary image by using the **DUMPBIN** utility. The **DUMPBIN /SYMBOLS** switch displays the COFF symbol table of the image. For more information on the **DUMPBIN** utility, see [DUMPBIN Reference](../../build/reference/dumpbin-reference.md). -- Temporarily disable incremental linking and whole-program optimization. When recompiled, the application generates Warning LNK4217, which includes the name of the function which references the imported symbol. Remove the `__declspec(dllimport)` declaration modifier from the imported symbol and re-enable incremental linking or whole-program optimization as required. +- Temporarily disable incremental linking and whole-program optimization. When recompiled, the application generates Warning LNK4217, which includes the name of the function that references the imported symbol. Remove the `__declspec(dllimport)` declaration modifier from the imported symbol and re-enable incremental linking or whole-program optimization as required. Although the final generated code behaves correctly, the code generated to call the imported function is less efficient than calling the function directly. This warning doesn't appear when you compile by using the [/clr](../../build/reference/clr-common-language-runtime-compilation.md) option. From 3951085ab722fbb488ca40864f4a0553f7b71855 Mon Sep 17 00:00:00 2001 From: Colin Robertson Date: Mon, 15 Apr 2019 15:33:32 -0700 Subject: [PATCH 3/6] Add /openmp:experimental for 2019 --- .../openmp-enable-openmp-2-0-support.md | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/docs/build/reference/openmp-enable-openmp-2-0-support.md b/docs/build/reference/openmp-enable-openmp-2-0-support.md index c4b9986171a..632224fe3bc 100644 --- a/docs/build/reference/openmp-enable-openmp-2-0-support.md +++ b/docs/build/reference/openmp-enable-openmp-2-0-support.md @@ -1,47 +1,57 @@ --- -title: "/openmp (Enable OpenMP 2.0 Support)" -ms.date: "11/04/2016" +title: "/openmp (Enable OpenMP Support)" +ms.date: "04/15/2019" f1_keywords: ["/openmp", "VC.Project.VCCLCompilerTool.OpenMP"] helpviewer_keywords: ["/openmp compiler option [C++]", "-openmp compiler option [C++]"] ms.assetid: 9082b175-18d3-4378-86a7-c0eb95664e13 --- -# /openmp (Enable OpenMP 2.0 Support) +# /openmp (Enable OpenMP Support) -Causes the compiler to process `#pragma`[omp](../../preprocessor/omp.md). +Causes the compiler to process [`#pragma omp`](../../preprocessor/omp.md) directives in support of OpenMP. ## Syntax -``` -/openmp -``` +::: moniker range=">= vs-2019" + +> **/openmp**[**:**__experimental__] + +::: moniker-end + +::: moniker range="<= vs-2017" + +> **/openmp** + +::: moniker-end ## Remarks `#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. -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). +::: moniker range=">= vs-2019" -If you attempt to load an application compiled with **/openmp** and **/clr** into a non-default application domain, a exception will be thrown outside the debugger and a OpenMPWithMultipleAppdomainsException exception will be thrown in the debugger. +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. + +::: moniker-end + +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). + +If you attempt to load an application compiled with **/openmp** and **/clr** into a non-default application domain, a exception is thrown outside the debugger, and a `OpenMPWithMultipleAppdomainsException` exception is thrown in the debugger. These exceptions can also be raised in the following situations: -- 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**. +- 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**. -- 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. +- 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. 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. -Microsoft advises that you do not write **/openmp** applications that allows partially trusted callers, using , or any CLR code access security attributes. +Microsoft doesn't recommend that you write **/openmp** applications that allow partially trusted callers, using , or any CLR code access security attributes. ### To set this compiler option in the Visual Studio development environment 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). -1. Expand the **Configuration Properties** node. - -1. Expand the **C/C++** node. - -1. Select the **Language** property page. +1. Expand the **Configuration Properties** > **C/C++** > **Language** property page. 1. Modify the **OpenMP Support** property. @@ -57,7 +67,7 @@ When you compile with **/openmp**, the second call to test2 never runs any longe 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**. -``` +```cpp // cpp_compiler_options_openmp.cpp #include #include @@ -103,5 +113,6 @@ int main(int argc, char* argv[]) { ## See also -[MSVC Compiler Options](compiler-options.md)
-[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md) +[MSVC Compiler Options](compiler-options.md) \ +[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md) \ +[OpenMP in MSVC](../../parallel/openmp/openmp-in-visual-cpp.md) From d6a641fd8733453f9c9a12eb9b7f9a90fa6f7dfc Mon Sep 17 00:00:00 2001 From: Colin Robertson Date: Mon, 15 Apr 2019 15:47:38 -0700 Subject: [PATCH 4/6] Acrolinx tax --- .../reference/openmp-enable-openmp-2-0-support.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/build/reference/openmp-enable-openmp-2-0-support.md b/docs/build/reference/openmp-enable-openmp-2-0-support.md index 632224fe3bc..58d138dd6b2 100644 --- a/docs/build/reference/openmp-enable-openmp-2-0-support.md +++ b/docs/build/reference/openmp-enable-openmp-2-0-support.md @@ -25,7 +25,7 @@ Causes the compiler to process [`#pragma omp`](../../preprocessor/omp.md) direct ## Remarks -`#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. +`#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. ::: moniker range=">= vs-2019" @@ -33,13 +33,13 @@ The C++ compiler currently supports the OpenMP 2.0 standard. However, Visual Stu ::: moniker-end -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). +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 using **/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). -If you attempt to load an application compiled with **/openmp** and **/clr** into a non-default application domain, a exception is thrown outside the debugger, and a `OpenMPWithMultipleAppdomainsException` exception is thrown in the debugger. +If you attempt to load an application compiled using both **/openmp** and **/clr** into a non-default application domain, a exception is thrown outside the debugger, and a `OpenMPWithMultipleAppdomainsException` exception is thrown in the debugger. These exceptions can also be raised in the following situations: -- 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**. +- If your application is compiled using **/clr** but not **/openmp**, and is loaded into a non-default application domain, where the process includes an application compiled using **/openmp**. - 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. @@ -61,11 +61,11 @@ Microsoft doesn't recommend that you write **/openmp** applications that allow p ## Example -The following sample shows some of the effects of threadpool startup versus using the threadpool after it started up. Assuming an x64, single core, dual processor the threadpool takes about 16ms to startup. After that though there is very little cost for the threadpool. +The following sample shows some of the effects of thread pool startup versus using the thread pool after it started up. Assuming an x64, single core, dual processor the thread pool takes about 16 ms to start up. After that, there is little cost for the thread pool. -When you compile with **/openmp**, the second call to test2 never runs any longer than if you compile with **/openmp-**, as there is no threadpool startup. At a million iterations the **/openmp** version is faster than the **/openmp-** version for the second call to test2, and at 25 iterations both **/openmp-** and **/openmp** versions register less than the clock granularity. +When you compile using **/openmp**, the second call to test2 never runs any longer than if you compile using **/openmp-**, as there is 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. -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**. +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 anything more, you may want to consider using **/openmp**. ```cpp // cpp_compiler_options_openmp.cpp From 27a64f9f2a13706e591468644fa233825ab0931d Mon Sep 17 00:00:00 2001 From: Colin Robertson Date: Mon, 15 Apr 2019 16:01:46 -0700 Subject: [PATCH 5/6] Tax part 2 --- .../openmp-enable-openmp-2-0-support.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/build/reference/openmp-enable-openmp-2-0-support.md b/docs/build/reference/openmp-enable-openmp-2-0-support.md index 58d138dd6b2..09aa27497e5 100644 --- a/docs/build/reference/openmp-enable-openmp-2-0-support.md +++ b/docs/build/reference/openmp-enable-openmp-2-0-support.md @@ -33,19 +33,19 @@ The C++ compiler currently supports the OpenMP 2.0 standard. However, Visual Stu ::: moniker-end -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 using **/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). +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). -If you attempt to load an application compiled using both **/openmp** and **/clr** into a non-default application domain, a exception is thrown outside the debugger, and a `OpenMPWithMultipleAppdomainsException` exception is thrown in the debugger. +If you attempt to load an app compiled using both **/openmp** and **/clr** into a non-default application domain, a exception is thrown outside the debugger, and a `OpenMPWithMultipleAppdomainsException` exception is thrown in the debugger. These exceptions can also be raised in the following situations: -- If your application is compiled using **/clr** but not **/openmp**, and is loaded into a non-default application domain, where the process includes an application compiled using **/openmp**. +- 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**. -- 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. +- 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. 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. -Microsoft doesn't recommend that you write **/openmp** applications that allow partially trusted callers, using , or any CLR code access security attributes. +Microsoft doesn't recommend that you write **/openmp** apps that allow partially trusted callers. Don't use , or any CLR code access security attributes. ### To set this compiler option in the Visual Studio development environment @@ -61,11 +61,11 @@ Microsoft doesn't recommend that you write **/openmp** applications that allow p ## Example -The following sample shows some of the effects of thread pool startup versus using the thread pool after it started up. Assuming an x64, single core, dual processor the thread pool takes about 16 ms to start up. After that, there is little cost for the thread pool. +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. -When you compile using **/openmp**, the second call to test2 never runs any longer than if you compile using **/openmp-**, as there is 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. +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. -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 anything more, you may want to consider using **/openmp**. +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**. ```cpp // cpp_compiler_options_openmp.cpp From 24b2d5002e5654d4b884f4d70eead233403cc93a Mon Sep 17 00:00:00 2001 From: Colin Robertson Date: Mon, 15 Apr 2019 16:28:21 -0700 Subject: [PATCH 6/6] escape! --- docs/build/reference/openmp-enable-openmp-2-0-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build/reference/openmp-enable-openmp-2-0-support.md b/docs/build/reference/openmp-enable-openmp-2-0-support.md index 09aa27497e5..45098f1ec73 100644 --- a/docs/build/reference/openmp-enable-openmp-2-0-support.md +++ b/docs/build/reference/openmp-enable-openmp-2-0-support.md @@ -13,7 +13,7 @@ Causes the compiler to process [`#pragma omp`](../../preprocessor/omp.md) direct ::: moniker range=">= vs-2019" -> **/openmp**[**:**__experimental__] +> **/openmp**\[**:**__experimental__] ::: moniker-end