Skip to content

Key the stream pool on the task's device - #1159

Merged
luraess merged 2 commits into
mainfrom
lr/stream-pool-device
Oct 15, 2026
Merged

luraess merged 2 commits into
mainfrom
lr/stream-pool-device

Conversation

@luraess

@luraess luraess commented Oct 15, 2026

Copy link
Copy Markdown
Member

Fixes a regression from #1120 that made core/codegen "Launch bounds" fail with hipErrorInvalidHandle on CSCS MI250 (Julia 1.13, main 9d33b4b).

HIP.task_stream picks the pool from HIP.device(). That is hipGetDevice, the one wrapper without prepare_state(), so it returns the device the OS thread was last used with, not the task's device. A fresh task on device 2, running on a thread last used with device 1, claims an idle device-1 stream. Its module is loaded on device 2, and HIP rejects the launch because the stream belongs to another device (ihipModuleLaunchKernel: stream device != ihipGetDevice() → hipErrorInvalidResourceHandle).

In CI, the KernelInterface testsuite's cross-device events test leaves device 2 as the default device (#1105, item 3), and its main task leaves an idle device-1 stream in the pool. core/codegen ran next on the same worker, and "Launch bounds" is its only launch.

The fix picks the pool from AMDGPU.device(), the task's device. That matches how test/core/tls.jl already looks up the pool.

Validated on MI250X (beverin mi200, Julia 1.13):

  • new multi_gpu test "Pooled streams match the task's device": fails on main (47/48), passes with the fix (48/48)
  • kernelinterface_tests → core/codegen in the same process: every launch fails on main, all pass with the fix
  • core/tls passes

luraess and others added 2 commits October 15, 2026 19:19
`task_stream` picked the pool from `HIP.device()`, i.e. `hipGetDevice`, which
skips `prepare_state` and reports the device the thread was last used with.
A fresh task on another device could then claim an idle stream of the wrong
device, and its kernel launches failed with `hipErrorInvalidHandle`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@luraess
luraess merged commit dfd8675 into main Oct 15, 2026
2 checks passed
@luraess
luraess deleted the lr/stream-pool-device branch October 15, 2026 19:43
@github-actions

Copy link
Copy Markdown
Contributor

AMDGPU.jl Benchmarks

Details
Benchmark suite Current: 291ec15 Previous: 353b621 Ratio
amdgpu/synchronization/context/device 1787.5 ns 1812.5 ns 0.99
amdgpu/synchronization/stream/blocking 235 ns 225 ns 1.04
amdgpu/synchronization/stream/nonblocking 350 ns 340 ns 1.03
applications/bitonic_sort 1112918 ns 1105353.75 ns 1.01
applications/convolution 80536.25 ns 73976 ns 1.09
applications/floyd_warshall 8999922.75 ns 9054960.25 ns 0.99
applications/histogram 812431.25 ns 793314 ns 1.02
applications/prefix_sum 190512.75 ns 190742.75 ns 1.00
array/accumulate/Float32/1d 91579 ns 92523.75 ns 0.99
array/accumulate/Float32/dims=1 68426 ns 60563.5 ns 1.13
array/accumulate/Float32/dims=1L 87313.75 ns 87806.25 ns 0.99
array/accumulate/Float32/dims=2 103901.25 ns 88358.75 ns 1.18
array/accumulate/Float32/dims=2L 130944.25 ns 175740.25 ns 0.75
array/accumulate/Int64/1d 108129 ns 90441.5 ns 1.20
array/accumulate/Int64/dims=1 82528.5 ns 70633.5 ns 1.17
array/accumulate/Int64/dims=1L 98301.25 ns 92791.5 ns 1.06
array/accumulate/Int64/dims=2 108511.5 ns 92341.25 ns 1.18
array/accumulate/Int64/dims=2L 196562.75 ns 198483 ns 0.99
array/broadcast 53788.25 ns 57918.5 ns 0.93
array/construct 2390.25 ns 2355 ns 1.01
array/copy 39098 ns 38483 ns 1.02
array/copyto!/cpu_to_gpu 86036.25 ns 85918.75 ns 1.00
array/copyto!/gpu_to_cpu 85791.25 ns 86248.75 ns 0.99
array/copyto!/gpu_to_gpu 58781 ns 59498.25 ns 0.99
array/iteration/findall/bool 115549.25 ns 93529 ns 1.24
array/iteration/findall/int 129084.25 ns 104056.5 ns 1.24
array/iteration/findfirst/bool 49550.75 ns 56560.75 ns 0.88
array/iteration/findfirst/int 51920.75 ns 56940.75 ns 0.91
array/iteration/findmin/1d 79881 ns 97464 ns 0.82
array/iteration/findmin/2d 67583.5 ns 80563.5 ns 0.84
array/iteration/logical 91838.75 ns 93809 ns 0.98
array/iteration/scalar 295784.25 ns 296092 ns 1.00
array/permutedims/2d 60703.5 ns 61688.5 ns 0.98
array/permutedims/3d 53105.5 ns 59256 ns 0.90
array/permutedims/4d 61910.75 ns 63150.75 ns 0.98
array/random/rand/Float32 45160.5 ns 46740.75 ns 0.97
array/random/rand/Int64 37873 ns 46675.75 ns 0.81
array/random/rand!/Float32 65695.75 ns 63673.5 ns 1.03
array/random/rand!/Int64 47825.75 ns 47478.25 ns 1.01
array/random/randn/Float32 73983.5 ns 72703.5 ns 1.02
array/random/randn!/Float32 82866 ns 82786.25 ns 1.00
array/reductions/mapreduce/Float32/1d 68823.5 ns 60425.75 ns 1.14
array/reductions/mapreduce/Float32/dims=1 43063 ns 43863 ns 0.98
array/reductions/mapreduce/Float32/dims=1L 58333.25 ns 51120.75 ns 1.14
array/reductions/mapreduce/Float32/dims=2 59455.75 ns 51973.5 ns 1.14
array/reductions/mapreduce/Float32/dims=2L 71441 ns 60900.75 ns 1.17
array/reductions/mapreduce/Int64/1d 70656 ns 61768.25 ns 1.14
array/reductions/mapreduce/Int64/dims=1 50313.25 ns 44065.75 ns 1.14
array/reductions/mapreduce/Int64/dims=1L 69691 ns 71006 ns 0.98
array/reductions/mapreduce/Int64/dims=2 58010.75 ns 50543.25 ns 1.15
array/reductions/mapreduce/Int64/dims=2L 74773.5 ns 76458.75 ns 0.98
array/reductions/reduce/Float32/1d 68635.75 ns 70176.25 ns 0.98
array/reductions/reduce/Float32/dims=1 49548 ns 51108.25 ns 0.97
array/reductions/reduce/Float32/dims=1L 58450.75 ns 59610.75 ns 0.98
array/reductions/reduce/Float32/dims=2 59143.5 ns 60643.5 ns 0.98
array/reductions/reduce/Float32/dims=2L 59298.25 ns 71181 ns 0.83
array/reductions/reduce/Int64/1d 70185.75 ns 72013.5 ns 0.97
array/reductions/reduce/Int64/dims=1 50028.25 ns 51468.25 ns 0.97
array/reductions/reduce/Int64/dims=1L 56020.75 ns 62391 ns 0.90
array/reductions/reduce/Int64/dims=2 57773.25 ns 59108.5 ns 0.98
array/reductions/reduce/Int64/dims=2L 61478.25 ns 62808.5 ns 0.98
array/reverse/1d 39800.5 ns 41488.25 ns 0.96
array/reverse/1dL 59875.75 ns 61570.75 ns 0.97
array/reverse/1dL_inplace 78263.75 ns 56503.25 ns 1.39
array/reverse/1d_inplace 46490.75 ns 39880.5 ns 1.17
array/reverse/2d 47400.5 ns 48433.25 ns 0.98
array/reverse/2dL 78006 ns 79033.75 ns 0.99
array/reverse/2dL_inplace 99731.25 ns 94686.5 ns 1.05
array/reverse/2d_inplace 57540.75 ns 67056 ns 0.86
array/sorting/1d 334162 ns 336870 ns 0.99
gemm/tiled 1905571.25 ns 1936281 ns 0.98
gemm/tiled_unbounded 1920509.25 ns 1949061 ns 0.99
integration/byval/reference 39140 ns 40880 ns 0.96
integration/byval/slices=1 40201 ns 41501 ns 0.97
integration/byval/slices=2 138162 ns 139832 ns 0.99
integration/byval/slices=3 235713 ns 239204 ns 0.99
integration/volumerhs 4866018 ns 4832111 ns 1.01
kernel/indexing 54630.75 ns 45395.5 ns 1.20
kernel/indexing_checked 47450.75 ns 59176 ns 0.80
kernel/launch 1245 ns 1230 ns 1.01
kernel/rand 72033.5 ns 72708.75 ns 0.99
latency/import 1958672081 ns 1953052041 ns 1.00
latency/precompile 34529641898 ns 34369458538 ns 1.00
latency/ttfp 2501540707 ns 2491942642 ns 1.00
stencil/diffusion3d 1594964.5 ns 1595708.5 ns 1.00
stencil/diffusion3d_checked 1633037.75 ns 1633254 ns 1.00

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

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