Skip to content

Commit

Permalink
Use native_powr() in costly _calc_refavg()
Browse files Browse the repository at this point in the history
As b in native_powr(a,b) is always in safe range here we can use the native variant
for a significant performance gain.
  • Loading branch information
jenshannoschwalm authored and TurboGit committed Aug 26, 2024
1 parent 02c08c0 commit b70b25e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions data/kernels/basic.cl
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,12 @@ static float _calc_refavg(
}
}

const float onethird = 1.0f / 3.0f;
for(int c = 0; c < 3; c++)
mean[c] = (cnt[c] > 0.0f) ? pow((correction[c] * sum[c]) / cnt[c], onethird) : 0.0f;
mean[c] = (cnt[c] > 0.0f) ? native_powr((correction[c] * sum[c]) / cnt[c], 0.33333333333f) : 0.0f;

const float croot_refavg[3] = { 0.5f * (mean[1] + mean[2]), 0.5f * (mean[0] + mean[2]), 0.5f * (mean[0] + mean[1])};
const int color = (filters == 9u) ? FCxtrans(row, col, xtrans) : FC(row, col, filters);
return pow(croot_refavg[color], 3.0f);
return native_powr(croot_refavg[color], 3.0f);
}

kernel void highlights_initmask(
Expand Down

0 comments on commit b70b25e

Please sign in to comment.