OpenMP in Xcode with gcc
Hi
I have written some computational electromagnetics code in C from within Xcode and compiled with gcc 4. I recently acquired a Mac Pro Quad core, which runs the code 10 times faster than my 12" G4 Powerbook. But the main reason for acquiring the Mac Pro was to exploit the multiple processors to implement parts of the code that can be performed simulateously. I really want to try openMP, but after some surfing I came to the conclusion only gcc 4.2 is OpenMP compatible and not gcc 4, but it is not yet officially released. Is that correct? Has anyone tried compiling C code with OpenMP directives from within Xcode using gcc 4.2? Did it Work? I also see Intel have a compiler 9.1 that they say is Xcode and OpenMP compatible. Anyone tried that?
Would be interested to hear any experiences.




OpenMP
I recently used gfortran with openmp, but that was command line, not Xcode. I'm not sure you could trick Xcode into using gcc 4.2. Anyone else know?
If you can't you could still use gcc 4.2 from the command line, if that is an option. And I'm sure they will update the compiler in Leopard, but that is still a way off.
The Intel compiler is very good, and should integrate with Xcode well. Even serial code typically runs twice as fast with Intel as GCC.
Drew
---------------------------
Drew McCormack
http://www.maccoremac.com
http://www.macanics.net
http://www.macresearch.org
Thanks for the input
Hello Drew
Thanks for the input. I might download the Intel Compiler and try it, but with Leopard being released in October I guess I will be waiting before I buy anything, and of course to see what Apple does. Hopefully XCode 3 is then bundled with an OpenMP compatible gcc C/C++ compiler version. I will post my findings.
Andrew
Xcode and OpenMP using Intel C Compiler 9.1
Thought I would post my experiences running the Intel Compiler 9.1 under Xcode and my first attempt at OpenMP. I am sure there are other "Mac researchers" out there like me who aren't comfortable at a Unix command line. I downloaded an evaluation version of the Intel compiler and installed it as per directions. I also found on an Intel forum that the following must also be done, quote :
You can set DYLD_LIBRARY_PATH in the executable in properties page.
In Xcode -> Groups & File -> Executables -> double click the executable or "get info"
select "Arguments" tab -> Variables to be set in the environment:
add
Name
DYLD_LIBRARY_PATH
Value
/opt/intel/cc/9.1.037/lib
So I did that. Then I wrote the following short piece of C code which evaluates the reduction directive in OpenMP. When I run it on my Quad Processor Mac Pro I get a speedup factor of 3.4 - I am pretty happy about that.
Andrew
using the command line
Greetings,
You can download GCC 4.3 binary packages complete with OpenMP at hpc.sourceforge.net. Just untar the package and it installs everything in /usr/local, without messing up Apple's installation of GCC. I've been using this to do some speed tests on some E&M code, as well. On the command line all that's required is (for c++)
/usr/local/bin/g++ file1.cpp file2.cpp -o binaryfilename -fopenmp
If you link to additional libraries then they must be included in the the above command. Anyway, with my test code I see a speed increase of about a factor of two when using two threads instead of one, of course your mileage may vary. I just wanted to make sure I could justify the purchase of one of those dual 3 GHz quad core beauties. I would be interested to see if the Intel compiler offers a significant speed increase over gcc 4.3, though.