[codebox]//First version
if(NP == 0) EP = 0;
else EP = inputArray[barNumber + INPUT_O];
//Second version
EP = inputArray[barNumber + INPUT_O] * abs(NP);[/codebox]
The above code statements produce the same result.
The question is which is faster.
Worst case scenario for the first, must be, half a warp goes if, half a warp goes else, taking 100% more cycles, but how many cycles is an if to begin with?
The later always performs an addition and a multiplication, that’s 8 cycles. How can I find out how many cycles the abs takes?
The time taken by the memory read and then write can differ quite a lot, I know that, I’m trying to understand it now.