Fixed issue with Cordic XMath.Pow/Exp on Cuda.#1334
Merged
m4rs-mt merged 1 commit intom4rs-mt:branch/v1.5.xfrom Jul 6, 2025
Merged
Fixed issue with Cordic XMath.Pow/Exp on Cuda.#1334m4rs-mt merged 1 commit intom4rs-mt:branch/v1.5.xfrom
m4rs-mt merged 1 commit intom4rs-mt:branch/v1.5.xfrom
Conversation
m4rs-mt
approved these changes
Jun 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1328 and #1331.
The implementation of
XMath.Pow(double)callsXMath.Exp(double). And the implementation ofXMath.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.