2

I am trying to compile C code in Visual Studio using Clang-Cl (via llvm-vs2014 in the platform toolset) with openmp code. When I enable openmp with /openmp I get a warning in clang-cl.exe that it was not used during compilation and my test code confirms that openmp is not working.

In addition I've tried Clang 3.7 with Microsoft CodeGen but it doesn't appear to support openmp yet (as verified by code).

Switching to Visual Studio 2015 allows the code to work but my default code (without any openmp) runs 50% slower.

Is there some way of getting openmp to work with the llvm-vs2014 platform toolset? Should I be using something outside of visual studio to get this to work?

5
  • Did you manage to solve this? Commented May 12, 2018 at 21:33
  • I've switched to using mingw - w64 for all my Windows C code Commented May 13, 2018 at 15:12
  • On what IDE? MinGW64 with Clang? Commented May 13, 2018 at 15:15
  • Just a text editor and the command line using gcc Commented May 13, 2018 at 16:47
  • The answer I posted at stackoverflow.com/a/68378031/7268445 may help you / some future reader out. Commented Jul 14, 2021 at 12:27

1 Answer 1

1

You can use:

clang -Xclang -fopenmp -l .\libiomp5md.lib

(note, though, that this is not officially supported by Microsoft)

Obviously, you have to have a copy of OpenMP runtime library. You can get and build it from https://www.openmprtl.org/.

Alternatively, you can build clang compiler along with OpenMP RTL yourself, from http://clang.llvm.org/.

Sign up to request clarification or add additional context in comments.

4 Comments

please provide a prebuilt runtime.
Pre-built OpenMP runtime is included in clang Windows/Linux/FreeBSD binaries: llvm.org/releases/download.html
indeed. This is true since version 3.8. Could you add that in the answer please and i delete my downvote.
They have it in 5.0.2 but they stopped in 6.0.0 (Which doesn't include OpenMP). Is there a way to enable OpenMP with clang-cl.exe?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.