Skip to content

Conversation

@HannoSpreeuw
Copy link
Collaborator

Solves #1195
The problem was with this line:

  float inv_ds  = rsqrt(ds2 + EPS2) * (__float_as_int(pos_i.w.y) != __float_as_int(pos_j.w.y));

This caused inv_ds==NaN.

Solves #1193

Apparently, this line of code:
"
  float inv_ds  = rsqrt(ds2 + EPS2) * (__float_as_int(pos_i.w.y) != __float_as_int(pos_j.w.y));
"
which should result in "inv_ds==0" for "i==j" results in "inv_ds==NaN" for "i==j" for modern CUDA versions.
We suspect that for older CUDA versions this worked well and resulted in "inv_ds==0" for "i==j", i.e. for fictious self-gravitation - which we exclude, of course.
Most likely, older CUDA versions did not comply with IEEE 754.
See https://developer.download.nvidia.com/compute/DevZone/docs/html/C/doc/html/group__CUDART__THREAD__DEPRECATED_gf423ba04af587d42b52799455a7c094d.html: "cudaThreadExit" has been deprecated:
"
Note that this function is deprecated because its name does not reflect its behavior. Its functionality is identical to the non-deprecated function cudaDeviceReset(), which should be used instead.
"
@HannoSpreeuw
Copy link
Collaborator Author

I can confirm that this branch not only compiles with CUDA 13, i.e. that this fixes #1193, but also runs with CUDA 13.

@HannoSpreeuw HannoSpreeuw added kind: bug kind: update Update of a community code to a newer version labels Dec 19, 2025
Copy link
Collaborator

@ErwanH29 ErwanH29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the code on the AMUSE script sun_venus.py and it gives near identical results to the CPU mode of Ph4 in both solutions and energy conservation. I compiled and tested using CUDA 13.

@spzwart spzwart merged commit 8dd292c into amusecode:main Dec 19, 2025
2 of 4 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Development Board Dec 19, 2025
@spzwart
Copy link
Contributor

spzwart commented Dec 19, 2025

Checked by Erwan, and considered ok.

@HannoSpreeuw HannoSpreeuw deleted the 1195_fix branch December 19, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: bug kind: update Update of a community code to a newer version

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants