[PATCH 3/3] Implementations for exp(float) and exp(double)

+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE exp(__CLC_GENTYPE val) {
+ // exp(x) = exp2(x) * log2(e)

This identity doesn't look right to me. Here's a counter example x=0
exp(0) ≠ exp2(0) * log2(e)
1≠ log2(e)

I think the correct identity is

exp(x) == exp2(x * log2(e))

Thanks,
Dan.

Hi Dan,

Thanks for spotting the mistake.

I think I messed up the parenthesis while moving things around. I’ll update the patch.

Irrespective of this mistake. I’m wondering if this is the best way to separate the float from double behaviour or whether there’s a clearer way to do this.

Jeroen

Thanks for spotting the mistake.

No problem.

Irrespective of this mistake. I’m wondering if this is the best way to separate the float from double behaviour or whether there’s a clearer way to do this.

It's not the easiest of code to follow due to all the macros but
that's probably because I'm not that familiar with libclc's code base.

Maybe this is a dumb question but would it be possible to just always
use the high precision constant (LOG2E) and rely on the compiler to
implicitly cast down to float (32-bit) for the float types? This would
simplify the implementation.

Thanks,
Dan.

Irrespective of this mistake. I’m wondering if this is the best way to separate the float from double behaviour or whether there’s a clearer way to do this.

It's not the easiest of code to follow due to all the macros but
that's probably because I'm not that familiar with libclc's code base.

Maybe this is a dumb question but would it be possible to just always
use the high precision constant (LOG2E) and rely on the compiler to
implicitly cast down to float (32-bit) for the float types? This would
simplify the implementation.

Unfortunately not, when you disable the 64-bit extensions, the high precision constant is no longer available.

Jeroen