Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28445 Discussions

Differences between 32-bit and 64-bit compiler

Saidani__Tarik
Beginner
1,510 Views
Hi,

I use ifort t build my code in precise model -fp-model precise. However, I have arithmetic differences between the version built with the intel 32-bit ifort and the version built with the 64-bit ifort. The gnu compiler gives the same values as the 64-bit ifort.
Could someone please provide me with and explanation on the source of the differences.

ifort version 12.1.4

Thanks

Tarik
0 Kudos
1 Solution
Ron_Green
Moderator
1,510 Views
32bit may use x87 instructions. With optimized code, It is unrealistic to expect the same results when moving between architectures, compiler versions, or OS. there are various options to assist with tightening down the fp model. -fp-model, -fimf-* option family, -assume protect-parens, -prec-div, -prec-sqrt You may need any or all of these.

Here is a good overview article: http://software.intel.com/file/39386/

View solution in original post

0 Kudos
6 Replies
Steven_L_Intel1
Employee
1,510 Views
Without detailed analysis of your program, it's difficult to know. When generating code for 64-bit platforms, there are additional integer registers that can be used and the order of operations may be different. In general, you should not expect bit-for-bit same results when making any changes, including compiler versions, platform or compiler options. Floating point results can change just by a different order of instructions, use of vectorization, etc. Even stack alignment can change results due to differing vectorization.
0 Kudos
Saidani__Tarik
Beginner
1,510 Views
Hi Steve,

Thanks for your quick answer. Is there any way to force the compiler to generate the same code on 32-bit and 64-bit, without cross-compiling 32-bit on 64 of course? I would understand the differences if the data types were different but in my case the source code is the same and it uses the REAL type.
Do you know any Intel (or non-Intel) document that I can refer to for the differences between 32 and 64-bit?

Thanks,

Tarik
0 Kudos
Ron_Green
Moderator
1,511 Views
32bit may use x87 instructions. With optimized code, It is unrealistic to expect the same results when moving between architectures, compiler versions, or OS. there are various options to assist with tightening down the fp model. -fp-model, -fimf-* option family, -assume protect-parens, -prec-div, -prec-sqrt You may need any or all of these.

Here is a good overview article: http://software.intel.com/file/39386/
0 Kudos
TimP
Honored Contributor III
1,510 Views
Running the Intel ia32 compiler on x86_64 shouldn't change the results from 32-bit OS.
Are you saying that gfortran -m32 gives identical results to gfortran -m64? In general, that wouldn't happen without passing options to make gfortran -m32 use the same instruction set as with -m64.
Usually, the differences in default action of gfortran are bigger than the default differences between ifort ia32 and intel64, because recent ifort defaults to -msse2 in either case.
There are differences in default unrolling between ifort ia32 and intel64, which may be suppressed by -unroll0. That's equivalent to gfortran default of no unrolling.
Ron's reference should be helpful as well. You should consider using equivalent options between gfortran and ifort, the defaults are entirely different. If you are running on AMD CPU, the option -imf-arch-consistency=true is important.
0 Kudos
Saidani__Tarik
Beginner
1,510 Views
Hi Ronald,

Thanks for the document, it was quite helpful. I have tried with the -fp-model source option and I could have similar values between 32 and 64-bit.

Thanks very much for your help
0 Kudos
Saidani__Tarik
Beginner
1,510 Views
Hi Tim,

There's no difference between running the ia32 compiler on a i386 and x86_64 in terms of floating-point values. Furthermore, gfortran -m32 gives the same results as ifort 64-bit.
I could finally get similar results between ifort 32-bit and ifort 64-bit using the -fp-model source.

Thanks to all for you precious help.

Tarik
0 Kudos
Reply