OpenMP Support in Xcode 5 and later

别等时光非礼了梦想. 提交于 2019-12-28 18:14:14

问题


I have a proprietary library (>150,000 lines) of quantum mechanics C++ code that relies on OpenMP for parallisation. This code used to compile fine with Xcode 4.6 and its' real GCC compiler, but the LLVM compiler that ships with Xcode 5 doesn't seem to support OpenMP. My code is developed on a Mac but needs to be portable to non-Apple hardware such as massively parallel supercomputers, so re-writing the code is not an option. Does anyone know of a suitable compiler that can be used? Many thanks for any help.


回答1:


I come back from my comment as I tested hpc.sourceforge.net and it is working like a charm for me.

Simply untar the archive as explained:

sudo tar -xvf gcc-4.8-bin.tar -C /

Update your .profile to use by default the hpc compiled version of gcc if you want.

Compile your program with option -fopenmp then link it with option -lgomp.




回答2:


"Does anyone know of a suitable compiler that can be used?"

The Intel compilers on MacOS support OpenMP, as they do on other platforms. http://software.intel.com/en-us/intel-software-development-products-for-mac-os-x

Of course, they cost money, but they may be worth it.

(Full disclosure: I work for Intel on the OpenMP runtime used by the compiler)




回答3:


See Clang + OpenMP Setup in Xcode. The steps are basically:

  1. Install Homebrew.
  2. Install llvm with brew install llvm.
  3. “Build Settings” and then “Editor” » “Add Build Setting” » “Add User-Defined Setting” with key of CC and value of /usr/local/opt/llvm/bin/clang.
  4. Search for “Enable Modules” and turn that off.
  5. Add /usr/local/opt/llvm/lib to “Library Search Paths”.
  6. Add /usr/local/opt/llvm/lib/clang/7.0.1/include to “Header Search Paths”. (The version number may vary based upon your installation.)
  7. Add -fopenmp compilation flag to “Other C Flags”.
  8. Turn off “Enable Index-While-Building Functionality”.
  9. Add /usr/local/opt/llvm/lib/libiomp5.dylib to “Build Phases” » “Link Binary with Libraries”.


来源:https://stackoverflow.com/questions/19208281/openmp-support-in-xcode-5-and-later

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!