Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

x86-64 with 32 bit int?

jeff_keasler
Beginner
721 Views

Hi,

I'm having trouble finding a compiler option that will force an int declaration to use 32 bit integers in x86-64 mode. I am bandwidth constrained, and I'm thinking it might be useful if I could cut down the size of the integers. If I am not bandwidth constrained, would using 32 bit integer operations slow me down in x86-64 mode?

Thanks,
-Jeff
0 Kudos
6 Replies
TimP
Honored Contributor III
721 Views
Quoting - jeff_keasler
If I am not bandwidth constrained, would using 32 bit integer operations slow me down in x86-64 mode?

Not necessarily; it's certainly not a typical concern, as there is native support for 32-bit int. It's hard to guess why you want to "force" 32-bit integers, unless you mean using data types to increase assurance that you have a 32-bit type on some other platform. If you want the fastest data type with 32-bit or larger int, caters to that as well.
0 Kudos
srimks
New Contributor II
721 Views
Quoting - jeff_keasler

Hi,

I'm having trouble finding a compiler option that will force an int declaration to use 32 bit integers in x86-64 mode. I am bandwidth constrained, and I'm thinking it might be useful if I could cut down the size of the integers. If I am not bandwidth constrained, would using 32 bit integer operations slow me down in x86-64 mode?

Thanks,
-Jeff

Could you try "-m32" which generates code for a 32-bit, probably the 32-bit environment sets int, long and pointer to 32 bits.
0 Kudos
manu-gupta
Beginner
721 Views
Quoting - srimks

Could you try "-m32" which generates code for a 32-bit, probably the 32-bit environment sets int, long and pointer to 32 bits.


Can you please tell me in which compiler are you using this switch -m32
0 Kudos
srimks
New Contributor II
721 Views
Quoting - manugupt1


Can you please tell me in which compiler are you using this switch -m32

Both GNU & ICC supports pobably..
0 Kudos
TimP
Honored Contributor III
721 Views
Quoting - srimks

Both GNU & ICC supports pobably..
No, gcc -m32 selects the 32-bit gcc compiler, if installed. That's a prerequisite for the icc ia32 compiler, but icc doesn't act on -m32. Anyway, it has little bearing on the original question.
long int does change from a 32-bit type in the 32-bit compiler to 64-bit in the 64-bit compiler, on linux. I guess the idea is that long is the largest type with efficient native support.
I suppose the original question was somewhat ambiguous, as it didn't specify clearly that 64-bit mode was intended, although it didn't make sense otherwise.
0 Kudos
jeff_keasler
Beginner
721 Views
Quoting - tim18
No, gcc -m32 selects the 32-bit gcc compiler, if installed. That's a prerequisite for the icc ia32 compiler, but icc doesn't act on -m32. Anyway, it has little bearing on the original question.
long int does change from a 32-bit type in the 32-bit compiler to 64-bit in the 64-bit compiler, on linux. I guess the idea is that long is the largest type with efficient native support.
I suppose the original question was somewhat ambiguous, as it didn't specify clearly that 64-bit mode was intended, although it didn't make sense otherwise.

Sorry, I had a small test where I had absentmindedlyprinted sizeof(double) whenI had meant to type sizeof(int). I was under the impression that in x86-64 mode, the integers were 64-bit. I'm actually a bit more troubled now, since we will soon be scaling to hundreds of thousands of processors where I work, and int will need to be 64-bit for those runs.

Thanks to everyone who tried to answer my original bogus question.

-Jeff
0 Kudos
Reply