Skip to content

1195 fix#1205

Merged
spzwart merged 2 commits into
amusecode:mainfrom
HannoSpreeuw:1195_fix
Dec 19, 2025
Merged

1195 fix#1205
spzwart merged 2 commits into
amusecode:mainfrom
HannoSpreeuw:1195_fix

Conversation

@HannoSpreeuw

Copy link
Copy Markdown
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
Copy Markdown
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

@ErwanH29 ErwanH29 left a comment

Copy link
Copy Markdown
Collaborator

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

spzwart commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Checked by Erwan, and considered ok.

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