Skip to content

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

Merged
m4rs-mt merged 1 commit intom4rs-mt:branch/v1.5.xfrom
MoFtZ:bug/xmath-pow-exp
Jul 6, 2025
Merged

Fixed issue with Cordic XMath.Pow/Exp on Cuda.#1334
m4rs-mt merged 1 commit intom4rs-mt:branch/v1.5.xfrom
MoFtZ:bug/xmath-pow-exp

Conversation

@MoFtZ
Copy link
Copy Markdown
Collaborator

@MoFtZ MoFtZ commented May 28, 2025

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 MoFtZ added this to the v1.5.3 milestone May 28, 2025
@MoFtZ MoFtZ force-pushed the bug/xmath-pow-exp branch from 32871d8 to b5d3a45 Compare May 28, 2025 05:58
@MoFtZ MoFtZ added the bug label May 28, 2025
@m4rs-mt m4rs-mt merged commit a11dfee into m4rs-mt:branch/v1.5.x Jul 6, 2025
31 checks passed
@MoFtZ MoFtZ deleted the bug/xmath-pow-exp branch July 8, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants