Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenMP Support in Xcode 5 and later

Tags:

xcode

openmp

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.

like image 238
user2851558 Avatar asked Oct 06 '13 11:10

user2851558


People also ask

Does Mac support OpenMP?

The default C compiler on macOS, Apple clang (confusingly aliased as /usr/bin/gcc ), does not directly support OpenMP.

Does MSVC support OpenMP?

Flang supports parsing of all OpenMP 4.5 constructs and a few OpenMP 5.0 constructs/clauses. Semantic checks and code generation of OpenMP 4.5 and 5.0 constructs are in progress. Read More. The Microsoft Visual C/C++ compiler supports the OpenMP 2.0 standard with the -openmp switch.

Does GCC support OpenMP?

Both OpenMP and OpenACC are supported with GCC's C, C++ and Fortran compilers.


2 Answers

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.

like image 155
Aurélien Avatar answered Oct 28 '22 14:10

Aurélien


"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)

like image 28
Jim Cownie Avatar answered Oct 28 '22 13:10

Jim Cownie