CUDA: Why are bitwise operators sometimes faster than logical operators?

前端 未结 3 1071
一向
一向 2021-01-11 17:46

When I am down to squeezing the last bit of performance out of a kernel, I usually find that replacing the logical operators (&& and

3条回答
  •  时光说笑
    2021-01-11 18:31

    Bitwise operations can be carried out in registers at hardware level. Register operations are the fastest, this is specially true when the data can fit in the register. Logical operations involve expression evaluation which may not be register bound. Typically &, |, ^, >>... are some of the fastest operations and used widely in high performance logic.

提交回复
热议问题