64 bit compiling help

Discussion of chess software programming and technical issues.

Moderator: Ras

Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

64 bit compiling help

Post by Edsel Apostol »

I have managed to compile my engine in 64 bit. I don't have a 64 bit system to test it so I have a couple of questions to the experts on this matter.

My engine is bitboard based and my tester noticed a speed increase of only 37% compared to the 32 bit version. Is this speed-up normal? His machine is an Athlon X2 3600+ running XP 64 bit.

I'm also not sure about this:

Code: Select all

#if defined(_WIN64) || defined(_LP64)
    #define VERSION64BIT
#endif

#if defined(VERSION64BIT)
// 64 bit code here
#else
// 32 bit code here
#endif
I'm using the macro VERSION64BIT to separate my 32 bit specific to 64 bit specific code. Is this implementation correct?

And lastly:

Code: Select all

typedef unsigned long long u64;
typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;
typedef signed long long s64;
typedef signed int s32;
typedef signed short s16;
typedef signed char s8;
Is the code above correct? Or I need to revise it for the 64 bit compile? The compile seems to work with that code above.
brianr
Posts: 540
Joined: Thu Mar 09, 2006 3:01 pm
Full name: Brian Richardson

Re: 64 bit compiling help

Post by brianr »

The 64-bit speed-up varies quite a bit based on the engine.
Crafty gains about 50%, IIRC.
Tinker, which is bitboard, but less so than Crafty, only about 25%.
Your results seem to be well within an expected range.

Has anyone seen greater than a 50% increase?
User avatar
beachknight
Posts: 3533
Joined: Tue Jan 09, 2007 8:33 pm
Location: Antalya, Turkey

Re: 64 bit compiling help

Post by beachknight »

Hi Edsel,

I'd be interested including both versions
of new TL beta in my tourneys. So I'll wait
for your notice for a download on your
website.

best,
hi, merhaba, hallo HT
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: 64 bit compiling help

Post by Edsel Apostol »

I think there are engines that has a speed-up of more than 50% but I couldn't remember the results posted here before. Maybe Glaurung and Rybka does.
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: 64 bit compiling help

Post by Edsel Apostol »

I will try to finish the tests first on the settings and I will try to add Chess 960 support before I will release a new version. If you want, just send me an e-mail and I will send you the latest beta including the 64 bit version.
Aleks Peshkov
Posts: 895
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Full name: Aleks Peshkov

Re: 64 bit compiling help

Post by Aleks Peshkov »

It is impossible to predict how much source code is portable without testing.
After reading Agner's optimization guids, that is what I use:

Code: Select all

#if !defined PLATFORM_BASE
    #if defined __x86_64__ || defined _M_X64
        #define USE_ASM
        #define PLATFORM_BASE 64
    #elif defined __i386__ || defined _M_IX86 || defined __INTEL__
        #define USE_ASM
        #define PLATFORM_BASE 32
    #elif defined __IA64__ || _WIN64 || __LP64__
        #define PLATFORM_BASE 64
    #else
        #define PLATFORM_BASE 32
    #endif
#endif
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: 64 bit compiling help

Post by Edsel Apostol »

It seems to cover everything. Can I use this code in my engine?

Code: Select all

#if !defined PLATFORM_BASE
    #if defined __x86_64__ || defined _M_X64
        #define USE_ASM
        #define PLATFORM_BASE 64
    #elif defined __i386__ || defined _M_IX86 || defined __INTEL__
        #define USE_ASM
        #define PLATFORM_BASE 32
    #elif defined __IA64__ || _WIN64 || __LP64__
        #define PLATFORM_BASE 64
    #else
        #define PLATFORM_BASE 32
    #endif
#endif
User avatar
Bo Persson
Posts: 259
Joined: Sat Mar 11, 2006 8:31 am
Location: Malmö, Sweden
Full name: Bo Persson

Re: 64 bit compiling help

Post by Bo Persson »

Edsel Apostol wrote:I think there are engines that has a speed-up of more than 50% but I couldn't remember the results posted here before. Maybe Glaurung and Rybka does.
I think you should be rather satisfied with a 37% speedup from a simple recompile! :)

If you do some tuning for the 64 bit version, I am sure you can also reach 50% and beyond. Some things that a relatively expensive in 32 bit mode are now cheaper, and can be used in 64 bit mode. That would affect your nps, if you try it out.
Edsel Apostol
Posts: 803
Joined: Mon Jul 17, 2006 5:53 am
Full name: Edsel Apostol

Re: 64 bit compiling help

Post by Edsel Apostol »

Thanks Bo. I'm just asking for other engine performance to have something to compare my engine's 64 bit speed-up.

I may be a little disappointed as I expect something more than 50%. Maybe my 32 bit version is optimized already.