使用clang-cl用openmp编译C代码 [英] Compiling C code with openmp using clang-cl

查看:149
本文介绍了使用clang-cl用openmp编译C代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有Openmp代码的Clang-Cl(通过平台工具集中的llvm-vs2014)在Visual Studio中编译C代码。当我使用/ openmp启用openmp时,我在clang-cl.exe中收到一条警告,指出编译期间未使用它,并且我的测试代码确认openmp无法正常工作。

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.

此外,我已经使用Microsoft CodeGen尝试了Clang 3.7,但它似乎还不支持openmp(通过代码验证)。

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

切换到Visual Studio 2015可以使代码可以工作,但是我的默认代码(没有任何openmp)运行速度降低了50%。

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

是否可以通过某种方式使openmp与llvm-vs2014平台工具集一起工作?我应该在Visual Studio之外使用某些东西来使它正常工作吗?

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?

推荐答案

您可以使用:

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

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

(不过请注意,Microsoft尚未正式支持

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

很显然,您必须拥有一份OpenMP运行时库。您可以从 https://www.openmprtl.org/ 中获取并构建它。

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

或者,您可以自己从 http:/一起构建clang编译器和OpenMP RTL。 /clang.llvm.org/

这篇关于使用clang-cl用openmp编译C代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆