improbable if statement cost

Discussion created by mihzaha on Aug 13, 2010
Latest reply on Aug 13, 2010 by mihzaha

I have something like this:


while(some long loop)


if(something very improbable (0.001%) )






what exactly happens there? Will the if ever converge, or will I have a single thread running alone after entering that if, making everything 2x slower in the workgroup until the end of the kernel?


and another off topic question:

is this correct for replacing an if? : b=(a+b!=0)*b/(a+b);

I want to result to be 0 when both are 0, otherwise b/a+b

(if the sum of a and b is 0,  a+b!=0 returns 0, 0*anything is 0, otherwise, the comparison returns 1?)



and what about a simple if:

if(something improbable ) do something small

else do something else

is that costly?


Thank you again for the great help