ILGPU icon indicating copy to clipboard operation
ILGPU copied to clipboard

Fixed issue with Cordic XMath.Pow/Exp on Cuda.

Open MoFtZ opened this issue 10 months ago • 0 comments

Fixes #1328 and #1331.

The implementation of XMath.Pow(double) calls XMath.Exp(double). And the implementation of XMath.Exp(double) on Cuda uses a custom implementation in ILGPU, using the CORDIC algorithm.

Within the implementation of Exp, it handles negative inputs by calling Exp again, with a positive input.

It looks like when mixed with LocalMemory in a kernel, Cuda will sometimes generate an illegal memory access. This occurs even if the local memory is not accessed, as per this investigation.

This "recursive" call should only be a single level deep, but the compiler probably cannot determine this.

This PR separates the core implementation of Exp into two functions, so that the compiler can predict that there is no recursion.

MoFtZ avatar May 28 '25 05:05 MoFtZ