Possible Duplicate:
Compilation fails with OpenMP on Mac OS X Lion (memcpy and SSE intrinsics)
I have decided to convert my pthreaded code to OpenMP.
Prior I was doing a lot of synchronisations using the Intel/GCC atomic builtins (__sync_fetch_and_add
family).
As expected those compile into lock xadd
with both GCC and ICC on x64.
But when compiling on GCC with -fopenmp
I start getting calls in those locations. callq ___sync_fetch_and_add_8
and family. ICC still generates properly optimised code.
Edit: The linker refuses to link that GCC code:
$ gcc -O3 -Wall *.o -lpthread -ldl -lgomp
Undefined symbols for architecture x86_64:
"___sync_fetch_and_add_8"
Edit2: This seems to be specific to Apple's GCC. I do not get that phenomenon on a Red Hat gcc 4.4.6
How can I make GCC generate the same optimised inlined asm it does without -fopenmp
?
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
$ icc --version
icc (ICC) 12.0.2 20110112
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
Compiling with
icc -O3 -Wall -std=gnu99 -ipo -xSSE4.1 -axAVX -O3 -Wall -openmp
gcc -O3 -Wall -std=gnu99 -finline-functions -funroll-loops -O3 -Wall -fopenmp