Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Question to 64 bit experts

Author: Aaron Gordon

Date: 16:43:53 01/19/05

Go up one level in this thread


On January 19, 2005 at 19:11:10, Dann Corbit wrote:

>On January 19, 2005 at 17:56:42, Aaron Gordon wrote:
>
>>On January 19, 2005 at 17:46:32, Dann Corbit wrote:
>>
>>>On January 19, 2005 at 17:27:57, Aaron Gordon wrote:
>>>
>>>>On January 19, 2005 at 11:55:43, Rémi Coulom wrote:
>>>>
>>>>>Hi,
>>>>>
>>>>>I am porting my chess program to 64 bit on an AMD64 Athlon processor. I have
>>>>>noticed that, with gcc, sizeof(int)=4. I would have expected sizeof(int)=8. On
>>>>>32-bit platforms, 32-bit variables are faster than 16-bit variables. I wonder if
>>>>>64-bit variables are faster than 32-bit variables on 64-bit machines. I have
>>>>>made a few experiments and did not notice much difference.
>>>>>
>>>>>Rémi
>>>>
>>>>Try using longs instead of ints. I have a DEC Alpha 21164 here (64bit also), and
>>>>wondered the same thing. Here is the output I got when running sizeof().
>>>>
>>>>short = 2 (16 bits)
>>>>int = 4 (32 bits)
>>>>long = 8 (64 bits)
>>>>long long = 8 (64 bits)
>>>>float = 4 (32 bits)
>>>>double = 8 (64 bits)
>>>>
>>>>On my Athlon XP, as expected, I get:
>>>>short = 2 (16 bits)
>>>>int = 4 (32 bits)
>>>>long = 4 (32 bits)
>>>>long long = 8 (64 bits)
>>>>float = 4 (32 bits)
>>>>double = 8 (64 bits)
>>>
>>>Depends on the compiler you use too.
>>>
>>>A compiler vendor can use any type they want for int, as long as it will hold
>>>+/- 32767 or larger.
>>
>>The only ones I've tested so far have been GCC (DGJPP and MingW), the Intel C
>>compiler, MSVC and the Compaq C compiler (for the Alpha). Though I think
>>MSVC/Intel C (windows) uses __int64 instead of long/longlong. So far though it
>>seems like all the linux compilers treat a long as 32bits unless you have a
>>64bit cpu & 64bit compiler. I'm guessing/hoping it would be alright to just use
>>longs from now on and if you have a 64bit cpu you'll just get the benefit from a
>>recompile.
>>
>>Just wishful thinking perhaps ;)
>
>On the Alpha (for instance) the DEC/COMPAQ/HP C++ compiler uses ints and longs
>of 32 bits, like the MS compiler.  For example:
>
>$ cxx s.c
>$ link s
>$ run s
>sizeof char is by definition 1.  This machine reports 1
>sizeof int is 4
>sizeof long is 4
>sizeof long long is 8
>$ type s.c
>#include <stdio.h>
>int main(void)
>{
>    printf("sizeof char is by definition 1.  This machine reports %u\n",
>(unsigned) sizeof (char));
>    printf("sizeof int is %u\n", (unsigned) sizeof (int));
>    printf("sizeof long is %u\n", (unsigned) sizeof (long));
>#ifdef __GNUC__
>    printf("sizeof long long is %u\n", (unsigned) sizeof (long long));
>#else
>    printf("sizeof long long is %u\n", (unsigned) sizeof (__int64));
>#endif
>    return 0;
>}
>$
>
>The GCC compiler on the same platform will report different values.

What version of the Compaq C compiler are you using? I believe mine is
6.5.6.002-1. It reports a long as 64 bits (same as my copy of GCC).



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.