7

I read here in What algorithms are best be cracked by GPU? that, hashing algorithms such as SHA1, SHA224, SHA256 which do 32 bit integer arithmetic and logical operations are better implemented on GPU as opposed to SHA512 hashing algorithm which work on 64 bit integers.

What is the reason behind this? GPUs do not provide a good support for development using 64 bit integers?

I read on the Nvidia CUDA Developer's FAQ the question: Does CUDA support long integers?

And the answer is Yes, however it says that operations on 64 bit long integers compile to multiple instruction sequences. Is that the reason why GPUs can handle 32 bit integers much better than 64 bit integers?

More information around this would be helpful. Also if there are any references which discuss this more in depth, I would like to know.

Neon Flash
  • 929
  • 2
  • 11
  • 17
  • Might be [this](http://en.wikipedia.org/wiki/GPGPU#Data_types) will help you to your question. –  May 26 '12 at 19:54

2 Answers2

6

To me, your question boils down to, "Why are GPUs 32 bits systems?"

The answer to the multiple instructions for a 64 bit number is the same as a regular CPU. If the architecture is 64 bits, then everything fits into the registers. If the architecture is 32 bits, not everything fits and multiple passes must be made to load and process everything.

What's the reasoning? As with the progression of all processors, GPU architecture has grown to the size it needs to be. Presently, 32 bit GPUs do a fantastic job of processing graphics and nobody's really clamoring for a 64 bit video card.

Consider looking at your question another way: why aren't modern CPUs 128 bit systems? I'm certain there are people out there who would like to run 128 bit operations, but it just doesn't make sense for the bounds of technology as it stands right now.

Jeff Ferland
  • 38,170
  • 9
  • 94
  • 172
  • Thanks. So, GPUs are essentially, 32 Bit Systems. Is it ok to conclude that the reason why GPUs do not perform so well with 64 bit integer operations is because a 64 bit integer cannot fit in a register and a small operation also needs to be broken down into multiple instructions. Due to the increase in number of instructions to be executed by the GPU, the performance comes down with 64 bit integers. Let me know if this is correct. – Neon Flash May 26 '12 at 13:23
  • Oh and to add to that, it says, operations on 64 bit integers are compiled to multiple instruction sequences on "some GPUs" based on "compute capability". If all GPUs are 32 bit systems, then why have they mentioned this condition? It would be helpful to understand with an example. – Neon Flash May 26 '12 at 13:27
  • 2
    @NeonFlash - See http://en.wikipedia.org/wiki/GPGPU#Data_types GPUs are massively parallel dumbed down CPUs. The extra precision of a 64-bit float (e.g., accuracy of 1 part in ~10^15 vs 1 part in ~10^8) is not needed for typical graphics purposes. Also to store the fanciest common color you only need 32-bits (8-bits (256 choices) for each RGB and alpha). There's no reason you couldn't construct a 64-bit GPU; however for most graphical purposes it would underperform a comprable 32-bit system as the extra precision is not needed. – dr jimbob May 26 '12 at 19:51
  • @NeonFlash - I am sure there are 64-bit GPU on the market. They are just not common and are design to perform specfic tasks ( i.e. guess the number of stars in the universe ). Where exactly did you get that "compute capability" quote? My guess the worst case they CUDA developers are leaving the possability open for x64 GPU. – Ramhound May 31 '12 at 12:46
1

GPU have 32-bit registers and 32-bit operations because this is sufficient for their needs. The main role of a GPU is to perform 3D rendering, which is all about operation on floating-point values with limited requirements for precision -- 32 bits are enough for that. There are some GPU which offer 64-bit registers, but use them only for floating-point operations, and not for arithmetic computations like those needed by "64-bit" hash functions like SHA-512.

An addition is something relatively expensive in hardware; carry propagation can be done with logarithmic time, so a 64-bit addition induces a bit more latency than a 32-bit addition -- and substantially many more transistors. The driving force for arithmetic operations on big registers, in CPU, is the need to address a lot of RAM: when a computer has more than 4 GB of RAM, and wants to use it as one big flat contiguous array of bytes, then it needs to compute offsets and addresses with 64-bit integers. This is why modern CPU can do 64-bit arithmetic operations. The same CPU come with 256-bit registers but cannot do efficient 256-bit additions, which shows that register size is not, in itself, the main issue.

GPU will be good at computing 64-bit hashes when they have more than 4 GB of RAM to deal with. Which should not take many years to happen, at the current rate.

Thomas Pornin
  • 322,884
  • 58
  • 787
  • 955