http://www.psc.edu/general/software/packages/ieee/ieee.php suggest you can do a bit of shifting (=bit-shifting) which ought to work as long as a variable can be cast into an (unsigned) int, without rounding it. I needed a device-function which determines whether two linearly dependent vectors point in the same direction:[codebox]device int same_colinear_direction(MVECTOR &a, MVECTOR &b)
Ignoring the fabs() which I needed to discern values too close to zero, you can see the way the sign bit is isolated. Do you think this is sufficiently robust?
http://www.psc.edu/general/software/packages/ieee/ieee.php suggest you can do a bit of shifting (=bit-shifting) which ought to work as long as a variable can be cast into an (unsigned) int, without rounding it. I needed a device-function which determines whether two linearly dependent vectors point in the same direction:[codebox]device int same_colinear_direction(MVECTOR &a, MVECTOR &b)
Ignoring the fabs() which I needed to discern values too close to zero, you can see the way the sign bit is isolated. Do you think this is sufficiently robust?
I guess in this case each branch contains very few instructions which means there’s a predicate placed infront of each instruction and no actual warp divergence happens?
I guess in this case each branch contains very few instructions which means there’s a predicate placed infront of each instruction and no actual warp divergence happens?
Thanks for pointing out signbit. Didn’t know and will use it, of course.
Branches (is this from another topic?):
Like them on trees, in data structures and cpu code, but dislike in cuda, because I think you risk an execution time which is the sum of all branches… (with some suitable qualifications). Divergence. If all threads in a warp take the same branch, it is no problem but no use either, I guess.