Use separate implementations instead of a macro

to ensure the constant multiplied with is of

higher precision.

v2: Use the correct formula, spotted by Dan Liew

Use separate implementations instead of a macro

to ensure the constant multiplied with is of

higher precision.

v2: Use the correct formula, spotted by Dan Liew

Assuming that the math is right, I don't see any inherent issues with

this method. We'll have to extend it eventually to handle half

floats, but it's at least going to give us exactly the value of

M_LOG2E that we want.

An alternative that also works, but I haven't double checked the

precision for float inputs when double is enabled:

#ifdef cl_khr_fp64

return exp2(val * (__CLC_GENTYPE)M_LOG2E);

#else

return exp2(val * M_LOG2E_F);

#endif

Also, if we want to add half to this method, we just need to add

another cast of M_LOG2E_F in the else branch (if double is not

available but half is). Once again, I haven't checked to make sure if

the cast values meet the precision requirements of the spec...

--Aaron

Use separate implementations instead of a macro

to ensure the constant multiplied with is of

higher precision.v2: Use the correct formula, spotted by Dan Liew

LGTM.

Thanks,

Committed.

I’m not in favour of depending on the behaviour of casting as suggested by Aaron, so I committed this version.

I’m not sure if this version gives enough precision to satisfy the specification, but at least this is better than what we had.

Jeroen