Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance of integer and bitwise operations on GPU

Tags:

Though GPUs are supposed for use with floating point data types, I'd be interested in how fast can GPU process bitwise operations. These are the fastest possible on CPU, but does GPU emulate bitwise operations or are they fully computed on hardware? I'm planning to use them inside shader programs written with GLSL. Also I'd suppose that if bitwise operations have full preformance, integer data types should have also, but I need confirmation on that.

To be more precise, targeted versions are OpenGL 3.2 and GLSL 1.5. Hardware that should run this is any Radeon HD graphics card and GeForce series 8 and newer.. If there are some major changes in newer versions of OpenGL and GLSL related to processing speeds of bitwise operations/integers, I'd be glad if you'll point them out.

like image 401
Raven Avatar asked Dec 30 '11 20:12

Raven


People also ask

Are GPUs good at integer math?

Yes 64 bit integer math is slow on consumer GPUs, but both of the above problems do a great deal of 64 bit integer math and still have great performance. Those benchmarks are a bit old and a single GTX 1080 is about 20% faster for those applications than the GTX Titan X.

Are bitwise operators faster than?

On simple low-cost processors, typically, bitwise operations are substantially faster than division, several times faster than multiplication, and sometimes significantly faster than addition.

Are bitwise operations fast in Python?

Software Engineering Python However, there are other ways to perform the same operations without the use of arithmetic operators. Bitwise operators happen to be much simpler operators, making them quite a bit faster than arithmetic operators.

Is bitwise or faster than logical or?

No. First, using bitwise operators in contrast to logical operators is prone to error (e.g., doing a right-shift by 1 is NOT equivalent to multiplying by two).


1 Answers

This question was partially answered Integer calculations on GPU

In short modern GPUs have equivalent INT and FP performance for 32bit data. So your logical operations will run at the same speed.

From a programming perspective you will lose performance if you are dealing with SCALAR integer data. GPUs like working with PARALLEL and PACKED operations.

for(int i=0; i<LEN_VEC4; i++)
    VEC4[i] = VEC4[i] * VEC4[i]; // (x,y,z,w) * (x,y,z,w)

If you're doing something like...

for(int i=0; i<LEN_VEC4; i++)
    VEC4[i].w = (VEC4[i].x & 0xF0F0F0F0) | (VEC4[i].z ^ 0x0F0F0F0F) ^ VEC4[i].w;

...doing many different operations on elements of the same vector you will run into performance problems.

like image 198
Louis Ricci Avatar answered Oct 01 '22 20:10

Louis Ricci