float func (float data, float floor)
{
float s = 0.0;
for (int i=0; i<10; i++) {
float v = process(data[i]);
if (v<floor[i]) v=floor[i];
s += log(v);
}
return s;
}
based on CUDA.
As you can see, it has “if” statement. I expect that I can become it faster if I can remove if statement.
Does anyone have good ideas to remove “if” statement from this?
If statements like that are very fast on CUDA. CUDA’s predicate system will handle this in a single clock, perhaps even 0.
This is confirmed by actual throughput measurements.
No need to worry about the cost in your case at all, unless you’re just curious.
As an aside, the use of “floor” as a variable name is likely a bad idea, since floor() is also a very common math function name.