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

Does x64 Compile create 64 bit integers ?

fbalderasintel
2,034 Views
This must be a silly question but when I compile Fortran using VS2008 with "x64" option
is the INTEGER type a 64 bit integer by default ? I assume yes but want to be sure. Someone
suggested that its not automatically a 64bit, but I would think it is as I dont see a flag to choose otherwise.
Also what would be the point of it NOT being automatically 64 bit.
1 Solution
John4
Valued Contributor I
2,034 Views

INTEGER is equivalent to INTEGER(4) on both ia32 and x86_64 architectures. INTEGER(POINTER_LEN), on the other hand, is equivalent to INTEGER(4) on ia32, and to INTEGER(8) on x86_64 ---so, it all comes down to having a range wide enough to store a memory address... which tends not to be very useful in Fortran.

The fact that the default INTEGER doesn't vary, is similar in other programming languages ---e.g., C's int is 32 bit for both ia32 ande x86_64, whereas long varies depending on both the architecture and operating system.

The relation between the number of bytes for default INTEGER and default REAL is also an important factor, but Intel certainly has flags to override it.

View solution in original post

4 Replies
John4
Valued Contributor I
2,035 Views

INTEGER is equivalent to INTEGER(4) on both ia32 and x86_64 architectures. INTEGER(POINTER_LEN), on the other hand, is equivalent to INTEGER(4) on ia32, and to INTEGER(8) on x86_64 ---so, it all comes down to having a range wide enough to store a memory address... which tends not to be very useful in Fortran.

The fact that the default INTEGER doesn't vary, is similar in other programming languages ---e.g., C's int is 32 bit for both ia32 ande x86_64, whereas long varies depending on both the architecture and operating system.

The relation between the number of bytes for default INTEGER and default REAL is also an important factor, but Intel certainly has flags to override it.

TimP
Honored Contributor III
2,034 Views
Fortran default integer size doesn't change between ia32 and X64 modes. What does change is the efficiency of 64-bit integer implementation. In 32-bit mode, 64-bit scalar integers are composed of pairs of 32-bit integers, requiring multiple low-level operations for each source operation, and avoiding 8-byte alignment requirements. 64-bit mode provides native 64-bit integer operations, with a requirement for 8-byte aligned storage for efficiency. 32-bit integers also are supported efficiently, so that large integer arrays could be dealt with without expanded memory requirements.

Needless to say, there have been non-Intel 64-bit platforms where default integer would be 64 bits (due to lack of efficient support for 32-bit integer), but those probably are no longer in widespread use.

As mentioned above, most Fortran compilers, including ifort, provide options to change the default data type sizes. The c_long interoperability type does change from 32 bits in ia32 mode to 64 bits in x86_64 linux, but in X64 Windows it remains 32 bits. The c_ interoperability types aren't affected by the default size command switches, which aren't present in most C compilers.
Les_Neilson
Valued Contributor II
2,034 Views
Others have pointed out that theDEFAULT size of integer, (and real etc.) do not change when you change from the 32-bit compiler to the 64bit compiler.

May I just add a word of caution here on programming style.
Wherever possible declare the size of yourvariables within the code.
There is a project setting which allows you to change the default sizes. Unless you have a good reason to do soI would recommend that you don't use that facility. If you do use it then document it somewhere (possibly even in the code itself.) Ispent many a happy hourstaring atcode listings containingREALbefore finally discovering that this one particular library had been compiled with different default data sizes. All integers were kind(2) and all reals were kind(8)and it wasn't documented anywhere! So :
REAL X
and REAL(8) Y
specified variables of the same size.
as did
INTEGER K
and INTEGER(2) M

And yes, the debugger would have told me instantly the sizes of the variables but I was looking through a paper copy, in the days when we still had paper :-)

Les
fbalderasintel
2,034 Views
Thanks everyone, I enjoyed all the answers and pearls of wisdom.
0 Kudos
Reply