32/64 bit confusion
I have a core 2 duo Macbook which I believe is 64 bit. I have installed g95 through fink and gfortran binaries from the gcc website. I use gcc that comes with Apple's Xcode
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5465~16/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5465)
If use gcc/g95/gfortran to create a binary is it 32 or 64 bit ? What about libraries I create with them ?
I also have ifort 10.1.014, both 32 and 64 bit. Which version should I use ? I tried to use the 64 bit version of ifort and link with some external libraries which were generated using gcc. But I get architecture differs error. But it works fine with the 32 bit ifort. So should I stick to 32 bit ifort ?
This seems strange since I would have expected gcc to be 64 bit ? What am I missing ?
praveen



Re: 32/64 bit confusion
Hi Praveen,
By default regardless of the CPU type, gcc/g95/gfortran produce 32-bit binaries. To build 64-bit binaries you pass the -m64 flag at compile and link time. You can verify a binaries type by using the command 'file'
macpro:bin gohara$ file lp
lp: Mach-O universal binary with 2 architectures
lp (for architecture ppc7400): Mach-O executable ppc
lp (for architecture i386): Mach-O executable i386
Which means it's a fat binary with two architectures one for 32-bit PPC and one for 32-bit Intel.
ifort/icc are different. If you used there installer and simply reference ifort/icc from the command line (without sourcing their setup scripts), then you are almost certainly using the 64-bit version of the compiler. If you want to use the 32-bit version, you can source the setup scripts in cc/fc folders (versus cce/fce folders which will activate the 64-bit version).
32-bit libraries cannot be linked against 64-bit binaries (and vice versa).
Regarding which to use... that depends. There are two compelling reasons to use 64-bit from a performance standpoint and one from a memory standpoint.
Performance:
1) The compiler can produce code that uses more registers
2) The ABI for 64-bit is much cleaner than for 32-bit (on Intel), since values are passed in register (for function calls and the like) rather than via the stack
Memory:
You get access to more memory for large memory calculations
Of course 64-bit means your longs and pointers require twice as much memory etc... But I've yet to come across a case in my own work where the performance went down going from 32- to 64-bit. There are cases where this is true, however.
Hope that helps,
Dave
Thank you for clarifying the
Thank you for clarifying the issue. What about fink; does it compile everything in 32 bit ? I can probably manage with 32 bit; this is a macbook and I only have 2 GB RAM. Anyway I use it mostly for development and testing small problems.