Though just starting to get into OpenCL realm, I have already noticed a strange effect.
Namely, my OpenCL code works very efficiently, until I add a very simple “if” statement that chooses the largest of two floats.
My estimation shows that it consumes about 2/3 of the algorithm’s total time.
I have tried various ways to avoid using “if”:
- calling max() and fmax(),
- using a formula based on sign(x - y)
but always it’s too slow
Due to this, the same algo is x3 times more efficient on AMD Athlon™ II X4 620 2.61 GHz than on NVIDIA GeForce 9600 GT I’m using as OpenCL hardware. So the idea of GPU-based computing seems quite “unripe”…
Is there any general recommendations how to avoid dramatic performance loss on conditional statements? Or is it unavoidable?