In VS22, OpenMP is still at version 2.0. Is it possible to update it to 5.0 or at least 3.0? I haven't managed to find any options in VS22 Installer which would allow that.
-
3You can use LLVM (clang-cl) compiler in Visual Studio 2022, which has OpenMP 5.0. To do so, select "C++ Clang tools for windows" option in the installer. – Laci Apr 18 '22 at 10:39
-
@Laci will I be able to switch between compilers without uninstalling clang? – Kaiyakha Apr 18 '22 at 10:44
-
2Of course, just change "General Properties/Platform Toolset". – Laci Apr 18 '22 at 10:50
2 Answers
For a long time, MSVC used its own runtime that is completely obsolete now since it only support OpenMP 2.0 released 20 years ago. Since recently, MSCV now support the LLVM runtime (libomp also used by ICC) as a new backend. You can enable it using the flag /openmp:llvm
meant to support OpenMP 3.1 (released 11 years ago). You can also use the /openmp:experimental
so to be able to use some features of OpenMP 4.5 (typically tasks though this is the most experimental part). Offloading features (eg. on GPU) is not supported yet. The support of OpenMP 5.0 is not planed yet. For more information, please read this.
As pointed out by @Laci in the comments, an alternative solution is to use the Clang-cl compiler so to benefit from a relatively complete support of OpenMP in Visual studio. Please note that using Clang-cl instead of the default compiler can result in some incompatibility (especially for large codes). For example, Clang does not support some C++17/C++20 features like the parallel STL, polymorphic allocators or some advanced atomic features yet (as opposed to MSVC). You can get more information about the support of C++ features for each compiler here.

- 41,678
- 6
- 29
- 59
-
I tried these option to enable support for _tasking_ in OpenMP as the compiler required these options explicitly. The thing is, with these options enabled and the task directive present in the code, the compilation just crashes with _C1001: Internal compiler error_. This is not the case if I do not apply tasking. Also, it does not matter what exactly I'm tasking, it can be either a huge block of code of almost empty, the error is the same. – Kaiyakha Apr 18 '22 at 19:20
-
Check [this](https://learn.microsoft.com/en-us/cpp/build/reference/openmp-enable-openmp-2-0-support?view=msvc-170) and [this](https://devblogs.microsoft.com/cppblog/improved-openmp-support-for-cpp-in-visual-studio/), which tells "Limited support for `#pragma omp task` has been added, but clauses on the task pragma are not guaranteed to work." – Laci Apr 19 '22 at 05:32
Visual Studio 2022 (version 17.3) supports all tasking constructs and most other features from OpenMP 3.1. See related blogs: https://devblogs.microsoft.com/cppblog/category/openmp/ The support is still experimental, libomp140* runtime is not part of redist yet. @kaiyakha: if you can please open a ticket for the compiler crash here: https://developercommunity.visualstudio.com/search?space=62&entry=problem that would be great, thank you!

- 41
- 5