Skip to content

Skip prepare_state in GC finalizers - #1106

Open
luraess wants to merge 1 commit into
mainfrom
lr/state
Open

luraess wants to merge 1 commit into
mainfrom
lr/state

Conversation

@luraess

@luraess luraess commented Sep 23, 2026

Copy link
Copy Markdown
Member

Every generated HIP wrapper starts with prepare_state(). In a GC finalizer, that created task-local state on whichever task GC interrupted, drained that task's sticky HIP error, and switched the thread back to the task's context, which undid the finalizer's HIP.context!. Item 1 of #1105.

With #1104, #1092 and #1096, the finalizer audit from #1105 drops from 1600 hits to 0 over the full suite. The new core/tls test fails on main and passes here (mi200, 2 GCDs).

🤖 Generated with Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AMDGPU.jl Benchmarks

Details
Benchmark suite Current: 9029179 Previous: 8a66547 Ratio
amdgpu/synchronization/context/device 555 ns 550 ns 1.01
amdgpu/synchronization/stream/blocking 225 ns 222.5 ns 1.01
amdgpu/synchronization/stream/nonblocking 307.5 ns 307.5 ns 1
applications/bitonic_sort 1128998.75 ns 1160103.75 ns 0.97
applications/convolution 74448.5 ns 72376 ns 1.03
applications/floyd_warshall 9036788.25 ns 9100856.25 ns 0.99
applications/histogram 795924 ns 798998.75 ns 1.00
applications/prefix_sum 189635.25 ns 190535 ns 1.00
array/accumulate/Float32/1d 74748.75 ns 79346 ns 0.94
array/accumulate/Float32/dims=1 274434 ns 271536.25 ns 1.01
array/accumulate/Float32/dims=1L 79711.25 ns 72536 ns 1.10
array/accumulate/Float32/dims=2 73951.25 ns 74041 ns 1.00
array/accumulate/Float32/dims=2L 3027629.75 ns 2834326.75 ns 1.07
array/accumulate/Int64/1d 72236.25 ns 79098.5 ns 0.91
array/accumulate/Int64/dims=1 249146.25 ns 248393.25 ns 1.00
array/accumulate/Int64/dims=1L 89091.5 ns 89128.75 ns 1.00
array/accumulate/Int64/dims=2 76356.25 ns 76041 ns 1.00
array/accumulate/Int64/dims=2L 3387365 ns 3139866 ns 1.08
array/broadcast 73443.5 ns 50443.25 ns 1.46
array/construct 1947.5 ns 2247.5 ns 0.87
array/copy 39325.5 ns 39278 ns 1.00
array/copyto!/cpu_to_gpu 85886.25 ns 85676.25 ns 1.00
array/copyto!/gpu_to_cpu 85676.25 ns 85591.25 ns 1.00
array/copyto!/gpu_to_gpu 36640.5 ns 58288.25 ns 0.63
array/iteration/findall/bool 127576.75 ns 125954.25 ns 1.01
array/iteration/findall/int 142167 ns 146617 ns 0.97
array/iteration/findfirst/bool 154669.75 ns 155292.25 ns 1.00
array/iteration/findfirst/int 138127 ns 189260 ns 0.73
array/iteration/findmin/1d 103996.5 ns 103258.75 ns 1.01
array/iteration/findmin/2d 90428.75 ns 90081.25 ns 1.00
array/iteration/logical 228603.25 ns 226565.5 ns 1.01
array/iteration/scalar 302959.25 ns 295931.5 ns 1.02
array/permutedims/2d 71483.5 ns 70736 ns 1.01
array/permutedims/3d 69423.5 ns 69253.5 ns 1.00
array/permutedims/4d 51041 ns 50278.25 ns 1.02
array/random/rand/Float32 46845.75 ns 40065.75 ns 1.17
array/random/rand/Int64 56008.25 ns 48863 ns 1.15
array/random/rand!/Float32 66213.5 ns 65541 ns 1.01
array/random/rand!/Int64 71276 ns 69623.25 ns 1.02
array/random/randn/Float32 71363.5 ns 71161 ns 1.00
array/random/randn!/Float32 82398.75 ns 58721 ns 1.40
array/reductions/mapreduce/Float32/1d 82061.25 ns 81621 ns 1.01
array/reductions/mapreduce/Float32/dims=1 73301 ns 56660.75 ns 1.29
array/reductions/mapreduce/Float32/dims=1L 840037.25 ns 844514.25 ns 0.99
array/reductions/mapreduce/Float32/dims=2 73343.5 ns 74073.5 ns 0.99
array/reductions/mapreduce/Float32/dims=2L 136339.5 ns 136524.5 ns 1.00
array/reductions/mapreduce/Int64/1d 82001.25 ns 81663.5 ns 1.00
array/reductions/mapreduce/Int64/dims=1 73566 ns 73933.5 ns 1.00
array/reductions/mapreduce/Int64/dims=1L 846449.75 ns 839174.25 ns 1.01
array/reductions/mapreduce/Int64/dims=2 74676.25 ns 75486.25 ns 0.99
array/reductions/mapreduce/Int64/dims=2L 137692 ns 137611.75 ns 1.00
array/reductions/reduce/Float32/1d 81788.5 ns 81541.25 ns 1.00
array/reductions/reduce/Float32/dims=1 72821 ns 70296 ns 1.04
array/reductions/reduce/Float32/dims=1L 838959.75 ns 836984.25 ns 1.00
array/reductions/reduce/Float32/dims=2 75286 ns 75123.5 ns 1.00
array/reductions/reduce/Float32/dims=2L 136392 ns 136774.25 ns 1.00
array/reductions/reduce/Int64/1d 81936.25 ns 81368.75 ns 1.01
array/reductions/reduce/Int64/dims=1 73213.5 ns 74831 ns 0.98
array/reductions/reduce/Int64/dims=1L 834839.5 ns 844554 ns 0.99
array/reductions/reduce/Int64/dims=2 73861 ns 75411.25 ns 0.98
array/reductions/reduce/Int64/dims=2L 137109.5 ns 137047 ns 1.00
array/reverse/1d 37023.25 ns 43458 ns 0.85
array/reverse/1dL 71553.5 ns 70606 ns 1.01
array/reverse/1dL_inplace 74546 ns 79671 ns 0.94
array/reverse/1d_inplace 61153.5 ns 60390.75 ns 1.01
array/reverse/2d 47928 ns 47625.75 ns 1.01
array/reverse/2dL 57413.25 ns 57993.5 ns 0.99
array/reverse/2dL_inplace 68601 ns 79096 ns 0.87
array/reverse/2d_inplace 40545.75 ns 61191 ns 0.66
array/sorting/1d 324740 ns 326449.5 ns 0.99
gemm/tiled 1914572.75 ns 1961659.75 ns 0.98
gemm/tiled_unbounded 1946430.75 ns 1960334.75 ns 0.99
integration/byval/reference 38721 ns 39821 ns 0.97
integration/byval/slices=1 40941 ns 40830 ns 1.00
integration/byval/slices=2 136582 ns 130842 ns 1.04
integration/byval/slices=3 241553 ns 241884 ns 1.00
integration/volumerhs 4882560 ns 4900148 ns 1.00
kernel/indexing 36475.5 ns 41880.5 ns 0.87
kernel/indexing_checked 41065.75 ns 37075.5 ns 1.11
kernel/launch 1147.5 ns 1130 ns 1.02
kernel/rand 56170.75 ns 70343.5 ns 0.80
latency/import 1457552506 ns 1456646355 ns 1.00
latency/precompile 22496228084 ns 22642954217 ns 0.99
latency/ttfp 2244637956 ns 2251455325 ns 1.00
stencil/diffusion3d 1616886 ns 1611230 ns 1.00
stencil/diffusion3d_checked 1660316.5 ns 1655470.5 ns 1.00

This comment was automatically generated by workflow using github-action-benchmark.

This branch has not been deployed

No deployments
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.

1 participant