Performance of integer and bitwise operations on GPU

后端 未结 1 1762
感情败类
感情败类 2021-01-03 21:46

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, bu

相关标签:
1条回答
  • 2021-01-03 22:42

    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.

    0 讨论(0)
提交回复
热议问题