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

Integer Size

chauvjo
Novice
370 Views
A quick general question. 

Does it provide any benefit (other than some memory savings) to tailor your integer size to fit your data range instead of just assuming INTEGER*4 for all integers? I have numerous integer variables which are used as flag which have values of between -10 and 10. In this case, INTEGER*1 would be the best fit. Is there an optimum integer size for maximum performance using the Intel compiler?  In other words, does using a small integer size impact performance in any way?

Thanks...

0 Kudos
4 Replies
Steven_L_Intel1
Employee
370 Views

No, assuming that the integer size's range is sufficient. For example, if you are using a variable to keep track of indexes or sizes of an object whose size can exceed 2GB, then you'll want it to be the larger size (like C's size_t).

0 Kudos
chauvjo
Novice
370 Views

Thanks Steve.  Just to be sure I understand.  There is no performance penalty in using an integer size small than INTEGER*4.  

Do most people bother to tailor the size of their integer variables?

0 Kudos
chauvjo
Novice
370 Views

Thanks Steve.  Just to be sure I understand.  There is no performance penalty in using an integer size small than INTEGER*4.  

Do most people bother to tailor the size of their integer variables?

0 Kudos
Steven_L_Intel1
Employee
370 Views

Smaller than INTEGER(4)? No, don't do that - there is a performance penalty. I thought you were asking about using INTEGER(8) on a 64-bit platform. Use INTEGER(4) unless you require a different size.

0 Kudos
Reply