Skip to content

FIX: CUDA misaligned address (716) error by avoiding merged return in BSphere construction from triangle vertices - #22

Merged
anicusan merged 1 commit into
StellaOrg:mainfrom
fjbarter:cuda_misaligned_fix
Apr 7, 2026
Merged

FIX: CUDA misaligned address (716) error by avoiding merged return in BSphere construction from triangle vertices#22
anicusan merged 1 commit into
StellaOrg:mainfrom
fjbarter:cuda_misaligned_fix

Conversation

@fjbarter

@fjbarter fjbarter commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Rather than constructing centre and radius in the branches, and merging before returning, just return inside the branches.

Changed src/bounding_volumes/bsphere.jl

Stella's examples/rotating_drum/rotating_drum.jl now works (05/04/2026) with PrecisionSettings(CUDA) with both single and double precision

Benchmarked and proven equivalent performance:

Merged return:
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (min … max):  105.800 μs …  3.796 ms  ┊ GC (min … max): 0.00% … 0.00%
  ▃▅▃▂▃▃▄▅▅▇███████▆▇███▆▅▅▄▄▃▂▂▂▂▂▂▂▁▁▁▁▂▄▄▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▃
  106 μs          Histogram: frequency by time          168 μs <

 Memory estimate: 704 bytes, allocs estimate: 44.
Early return:
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (min … max):  105.900 μs …  3.403 ms  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     122.600 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   126.722 μs ± 56.277 μs  ┊ GC (mean ± σ):  0.00% ± 0.00%

            ▂█▂▁      ▁▁
  ▂▃▂▂▂▂▃▃▄▄████▇▇▇▆▅▅██▇▅▄▅▄▃▃▂▂▂▁▁▂▁▁▁▁▁▁▂▅▄▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  106 μs          Histogram: frequency by time          166 μs <

 Memory estimate: 208 bytes, allocs estimate: 13.
Median merged: 0.122 ms
Median early : 0.123 ms

@fjbarter
fjbarter requested a review from anicusan April 5, 2026 16:49
@anicusan

anicusan commented Apr 7, 2026

Copy link
Copy Markdown
Member

This is great, thanks Freddie!

@anicusan
anicusan merged commit 6b0b48c into StellaOrg:main Apr 7, 2026
16 checks passed
anicusan referenced this pull request Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants