Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance 32 bit vs. 64 bit arithmetic

Are native 64 bit integer arithmetic instructions slower than their 32 bit counter parts (on x86_64 machine with 64 bit OS)?

Edit: On current CPUs such Intel Core2 Duo, i5/i7 etc.

like image 679
Cartesius00 Avatar asked Jan 20 '12 22:01

Cartesius00


People also ask

Does 32 bit run faster than 64 bit?

Simply put, a 64-bit processor is more capable than a 32-bit processor because it can handle more data at once. A 64-bit processor can store more computational values, including memory addresses, which means it can access over 4 billion times the physical memory of a 32-bit processor.

Should I be using 32 bit or 64 bit?

For most people, 64-bit Windows is today's standard and you should use it to take advantage of security features, better performance, and increased RAM capability. The only rare reasons you'd want to stick with 32-bit Windows are: Your computer has a 32-bit processor.

Does 32 bit run slower than 64 bit?

No, and it will run faster than an Windows x64 bit OS. Mostly all CPUs released in the past few years are 64 bit, but have the ability to run 32 bit code.

What is the biggest advantage of 64bit vs 32bit?

Using 64 bit operating system with 64 bit processer, the system can perform an increased number of calculations per second. As a result, it increases the processing power and makes a computer run faster. This is limited in case of 32 bit operating system. You can multi-task, switch between various application etc.


1 Answers

It depends on the exact CPU and operation. On 64-bit Pentium IVs, for example, multiplication of 64-bit registers was quite a bit slower. Core 2 and later CPUs have been designed for 64-bit operation from the ground up.

Generally, even code written for a 64-bit platform uses 32-bit variables where values will fit in them. This isn't primarily because arithmetic is faster (on modern CPUs, it generally isn't) but because it uses less memory and memory bandwidth.

A structure containing a dozen integers will be half the size if those integers are 32-bit than if they are 64-bit. This means it will take half as many bytes to store, half as much space in the cache, and so on.

64-bit native registers and arithmetic are used where values may not fit into 32-bits. But the main performance benefits come from the extra general purpose registers available in the x86_64 instruction set. And of course, there are all the benefits that come from 64-bit pointers.

So the real answer is that it doesn't matter. Even if you use x86_64 mode, you can (and generally do) still use 32-bit arithmetic where it will do, and you get the benefits of larger pointers and more general purpose registers. When you use 64-bit native operations, it's because you need 64-bit operations, and you know they'll be faster than faking it with multiple 32-bit operations -- your only other choice. So the relative performance of 32-bit versus 64-bit registers should never be a deciding factor in any implementation decision.

like image 98
David Schwartz Avatar answered Sep 19 '22 03:09

David Schwartz