The programming guide advises that “integer division and modulo operations are particularly costly and should be avoided if possible.” Just how costly is “particularly costly?” Are we talking about hundreds of cycles? Thousands of cycles? More?
My kernel needs to make regular use of integer division and multiplication, but only for small positive numbers; generally indexes of arrays. It’s running much slower than I had hoped, and having basically ruled out non-coalesced memory access, I’m wondering if integer arithmetic might be the culprit. Would it be safe to replace my integers with floating points, given that I should be able to restrict my computation to the mantissa? How expensive is it to cast a float back to an int before using it as an index into an array?