Apologies if this has been discussed before (you can link me to an old thread if it has), but does anyone know roughly how much impact compiling code for 32-bit processing has?
The reason I ask is that I am writing some code for work, which might end up being processor intensive, and I've had a bit of difficulty with it compiled for x64, so as a temporary workaround I am compiling it for x86.
Thanks for any advice!
Compiled For 32-bit v 64-bit?
Moderator: Ras
-
towforce
- Posts: 12841
- Joined: Thu Mar 09, 2006 12:57 am
- Location: Birmingham UK
- Full name: Graham Laight
Compiled For 32-bit v 64-bit?
Human chess is partly about tactics and strategy, but mostly about memory
-
hgm
- Posts: 28464
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Compiled For 32-bit v 64-bit?
My engine Shokidoki was slower when I compiled it for x64. (Could also be due to the quality of the respective compilers.)
I guess a lot depends on how many 64bit multiplies your code does.
I guess a lot depends on how many 64bit multiplies your code does.
-
jdart
- Posts: 4427
- Joined: Fri Mar 10, 2006 5:23 am
- Location: http://www.arasanchess.org
Re: Compiled For 32-bit v 64-bit?
Bitboard based programs tend to do better with x64 compiles because POPCNT and other operations are available for 64-bit integers. But it is not a huge benefit - 10-20% typically I think.
--Jon
--Jon
-
Sven
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Compiled For 32-bit v 64-bit?
Many operations on 64 bit numbers are slower with a 32 bit compile since they have to use two 32 bit registers instead of one 64 bit register and combine partial results. This is one of the reasons why 64 bit compiles are faster than 32 bit compiles.jdart wrote:Bitboard based programs tend to do better with x64 compiles because POPCNT and other operations are available for 64-bit integers. But it is not a huge benefit - 10-20% typically I think.
--Jon
The popcnt instruction, if available at all, is also available for 32 bit, so you already get a speedup in a 32 bit program when using HW popcnt instead of a SW algorithm. Non-bitboard programs will rarely make use of that, though.
Sven
-
towforce
- Posts: 12841
- Joined: Thu Mar 09, 2006 12:57 am
- Location: Birmingham UK
- Full name: Graham Laight
Re: Compiled For 32-bit v 64-bit?
Given that the application is mainly a business website to which I am adding some optimisation functionality via a DLL, it sounds as though nobody is going to notice any difference to existing functionality - especially given that most of the delay (which isn't much) comes from SQL lookups to a different server.hgm wrote:I guess a lot depends on how many 64bit multiplies your code does.
In the past, I have found that a 32-bit version of GLPK is actually a lot faster than the 64-bit version for a particular CTF puzzle I was solving, but it is not possible to conclude anything from that because it was an older version, and MIP model solving is notoriously sensitive to exactly how the solver engine is tuned (I rarely tune beyond selecting which planar cuts to use).
Thanks for the practical insight from chess programming!
Human chess is partly about tactics and strategy, but mostly about memory
-
wgarvin
- Posts: 838
- Joined: Thu Jul 05, 2007 5:03 pm
- Location: British Columbia, Canada
Re: Compiled For 32-bit v 64-bit?
General-purpose x86 code usually doesn't benefit much from being compiled for 64-bit instead of 32-bit. You might see a 5-10% speedup with 64-bit, or you might not notice any difference at all--it depends on the application.towforce wrote:Apologies if this has been discussed before (you can link me to an old thread if it has), but does anyone know roughly how much impact compiling code for 32-bit processing has?
The reason I ask is that I am writing some code for work, which might end up being processor intensive, and I've had a bit of difficulty with it compiled for x64, so as a temporary workaround I am compiling it for x86.
Thanks for any advice!
(1) If your program needs to use more than 2 GB of RAM, compiling for 64-bit is the easiest way to achieve this. Most programs don't need anywhere near that much memory though. (At work I use a piece of in-house software that sometimes needs as much as 23 GB of RAM to run.)
(2) If your program does a lot of 64-bit integer math, it might see a 10-20 percent speedup. (This is the case with chess programs that make heavy use of 64-bit bitboards)
(3) If you have a lot of floating-point math, the extra SSE registers available in x64 might help a bit. But in general, x86 is really good at using values directly from L1 cache, so having more architecturally-visible registers (for integer and SSE) does not help as much as you might imagine. There might be weird cases where it helps a lot, but I haven't seen any.
-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Compiled For 32-bit v 64-bit?
That and how much register pressure your program generates when the optimizer pass is made. an extra 8 registers (in 64 bit mode) can make a significant difference.hgm wrote:My engine Shokidoki was slower when I compiled it for x64. (Could also be due to the quality of the respective compilers.)
I guess a lot depends on how many 64bit multiplies your code does.
-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Compiled For 32-bit v 64-bit?
I don't get a measurable speedup with popcnt. Maybe 1-2 % But the extra registers help a lot as does the 64 bit wordsize for bitboards.jdart wrote:Bitboard based programs tend to do better with x64 compiles because POPCNT and other operations are available for 64-bit integers. But it is not a huge benefit - 10-20% typically I think.
--Jon
-
Don
- Posts: 5106
- Joined: Tue Apr 29, 2008 4:27 pm
Re: Compiled For 32-bit v 64-bit?
If the program was not written specifically for a 64 bit processor, it will probably be slightly slower on 64 bits.towforce wrote:Apologies if this has been discussed before (you can link me to an old thread if it has), but does anyone know roughly how much impact compiling code for 32-bit processing has?
The reason I ask is that I am writing some code for work, which might end up being processor intensive, and I've had a bit of difficulty with it compiled for x64, so as a temporary workaround I am compiling it for x86.
Thanks for any advice!
If it's written specifically to take advantage of 64 bit processors (using bitboards) it will run much faster on a 64 bit CPU. This all assumes you are running a 64 bit OS of course.
Most 64 bit programs are significantly faster on 64 bit machines. Komodo is particularly superior on 64 bits compared to 32 bits where it is almost 2 to 1 faster. I think almost all bitboard programs are at least 50% faster on a 64 bit processors.
If the program you are compiling at work is not chess it probably doesn't matter too much. Does is specifically take advantage of 64 bit instructions? In particular does it do a lot of bit manipulation with 64 bit variables?
Capital punishment would be more effective as a preventive measure if it were administered prior to the crime.
-
towforce
- Posts: 12841
- Joined: Thu Mar 09, 2006 12:57 am
- Location: Birmingham UK
- Full name: Graham Laight
Re: Compiled For 32-bit v 64-bit?
Probably not. The general web application would not be doing intense repetitive operations like a chess program.Don wrote:If the program you are compiling at work is not chess it probably doesn't matter too much. Does is specifically take advantage of 64 bit instructions? In particular does it do a lot of bit manipulation with 64 bit variables?
The MIP (mixed integer programming) part I am adding uses double arithmetic, and it's possible that some 64-bit manipulation would be used if I were to use the x64 version of the optimiser DLL (which in this case would be the same code compiled for 64-bits rather than 32-bits) - but for the moment I don't really have a choice but to use the 32-bit DLL.
Human chess is partly about tactics and strategy, but mostly about memory