Skip to content

Use GPUArrays 12's reductions, sorting, scans and findall - #1145

Merged
maleadt merged 3 commits into
mainfrom
tb/gpuarrays-12
Oct 10, 2026
Merged

maleadt merged 3 commits into
mainfrom
tb/gpuarrays-12

Conversation

@maleadt

@maleadt maleadt commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Ports AMDGPU.jl to GPUArrays 12, which implements Base's reductions, sorting, scans, findall, logical indexing and reverse once for every GPU array, on AcceleratedKernels 0.5 (JuliaGPU/GPUArrays.jl#790), and removes the GPUArrays.mapreducedim! hook.

  • Deletes AMDGPU's own reduction kernel, sort!/sortperm!, scans, findall, logical indexing and reverse (src/kernels/). The vector sort!/sortperm! were ambiguous with GPUArrays' methods, and the scans used AcceleratedKernels 0.4's API.
  • Drops the direct AcceleratedKernels dependency; its AMDGPU extension still loads through GPUArrays. (AMDGPU's current compat, 0.3.1, 0.4, couldn't load AK 0.5 anyway.)
  • GPUArrays.default_rng is gone in GPUArrays 12; the RNG lives in gpuarrays_rng().

Intended as a minor release.

Tested on gfx1036 (Julia 1.13): core/rocarray_base, hip_rocarray, the GPUArrays testsuite and the KernelAbstractions tests, 17,968 pass. The 3 cholesky(::Diagonal) errors are fixed in Adapt 4.7.3.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

AMDGPU.jl Benchmarks

Details
Benchmark suite Current: 70f2603 Previous: 1554014 Ratio
amdgpu/synchronization/context/device 1777.5 ns 1760 ns 1.01
amdgpu/synchronization/stream/blocking 225 ns 230 ns 0.98
amdgpu/synchronization/stream/nonblocking 350 ns 337.5 ns 1.04
applications/bitonic_sort 1073345.25 ns 1081902.5 ns 0.99
applications/convolution 55503.25 ns 91548.75 ns 0.61
applications/floyd_warshall 9030625 ns 9056864.25 ns 1.00
applications/histogram 796388.75 ns 762330.5 ns 1.04
applications/prefix_sum 189467.75 ns 188532.75 ns 1.00
array/accumulate/Float32/1d 99116.25 ns 82493.5 ns 1.20
array/accumulate/Float32/dims=1 269243.75 ns 260561.25 ns 1.03
array/accumulate/Float32/dims=1L 107301.75 ns 102981.5 ns 1.04
array/accumulate/Float32/dims=2 105019 ns 106454 ns 0.99
array/accumulate/Float32/dims=2L 2459177.5 ns 2936696.25 ns 0.84
array/accumulate/Int64/1d 96868.75 ns 87393.75 ns 1.11
array/accumulate/Int64/dims=1 254568.5 ns 244228.5 ns 1.04
array/accumulate/Int64/dims=1L 133529.5 ns 112424 ns 1.19
array/accumulate/Int64/dims=2 87161.25 ns 107009 ns 0.81
array/accumulate/Int64/dims=2L 2762979.5 ns 3363919.75 ns 0.82
array/broadcast 63143.5 ns 29065.5 ns 2.17
array/construct 2305 ns 2027.5 ns 1.14
array/copy 40495.5 ns 38108 ns 1.06
array/copyto!/cpu_to_gpu 86103.75 ns 89163.75 ns 0.97
array/copyto!/gpu_to_cpu 85953.75 ns 89608.75 ns 0.96
array/copyto!/gpu_to_gpu 37040.5 ns 33963 ns 1.09
array/iteration/findall/bool 94348.75 ns 121821.75 ns 0.77
array/iteration/findall/int 103793.75 ns 112161.5 ns 0.93
array/iteration/findfirst/bool 128786.75 ns 153429.5 ns 0.84
array/iteration/findfirst/int 132737 ns 166444.75 ns 0.80
array/iteration/findmin/1d 107331.5 ns 115776.5 ns 0.93
array/iteration/findmin/2d 101094 ns 83061.25 ns 1.22
array/iteration/logical 90586.25 ns 182632.5 ns 0.50
array/iteration/scalar 306969.5 ns 296154.25 ns 1.04
array/permutedims/2d 60321 ns 58833.25 ns 1.03
array/permutedims/3d 58843.25 ns 56508.25 ns 1.04
array/permutedims/4d 65126 ns 65433.25 ns 1.00
array/random/rand/Float32 40975.5 ns 37123 ns 1.10
array/random/rand/Int64 39088.25 ns 44115.5 ns 0.89
array/random/rand!/Float32 37783 ns 41313 ns 0.91
array/random/rand!/Int64 58300.75 ns 37768 ns 1.54
array/random/randn/Float32 68746 ns 71366 ns 0.96
array/random/randn!/Float32 76478.5 ns 53588.25 ns 1.43
array/reductions/mapreduce/Float32/1d 77531.25 ns 110251.75 ns 0.70
array/reductions/mapreduce/Float32/dims=1 58948.5 ns 88178.75 ns 0.67
array/reductions/mapreduce/Float32/dims=1L 66343.5 ns 817171.25 ns 0.0811867769454689
array/reductions/mapreduce/Float32/dims=2 69021 ns 74603.5 ns 0.93
array/reductions/mapreduce/Float32/dims=2L 69668.5 ns 136832 ns 0.51
array/reductions/mapreduce/Int64/1d 80393.75 ns 110986.5 ns 0.72
array/reductions/mapreduce/Int64/dims=1 59181 ns 88126.25 ns 0.67
array/reductions/mapreduce/Int64/dims=1L 78348.5 ns 820481.5 ns 0.09549087944091365
array/reductions/mapreduce/Int64/dims=2 67785.75 ns 92678.75 ns 0.73
array/reductions/mapreduce/Int64/dims=2L 85068.75 ns 136504.25 ns 0.62
array/reductions/reduce/Float32/1d 79106.25 ns 112186.5 ns 0.71
array/reductions/reduce/Float32/dims=1 59108.25 ns 70328.5 ns 0.84
array/reductions/reduce/Float32/dims=1L 59401 ns 814998.75 ns 0.07288477436315087
array/reductions/reduce/Float32/dims=2 69165.75 ns 95113.75 ns 0.73
array/reductions/reduce/Float32/dims=2L 81406 ns 137447 ns 0.59
array/reductions/reduce/Int64/1d 80153.75 ns 110429 ns 0.73
array/reductions/reduce/Int64/dims=1 59428.25 ns 88551.25 ns 0.67
array/reductions/reduce/Int64/dims=1L 79213.5 ns 821399 ns 0.09643729782967839
array/reductions/reduce/Int64/dims=2 67653.5 ns 92529 ns 0.73
array/reductions/reduce/Int64/dims=2L 85053.75 ns 136359.5 ns 0.62
array/reverse/1d 40718 ns 43333.25 ns 0.94
array/reverse/1dL 68648.5 ns 68421 ns 1.00
array/reverse/1dL_inplace 77951.25 ns 53655.75 ns 1.45
array/reverse/1d_inplace 37983 ns 37160.5 ns 1.02
array/reverse/2d 48020.75 ns 46538.25 ns 1.03
array/reverse/2dL 77591 ns 90628.75 ns 0.86
array/reverse/2dL_inplace 82726.25 ns 64456 ns 1.28
array/reverse/2d_inplace 54603.25 ns 36693 ns 1.49
array/sorting/1d 324219.5 ns 322582 ns 1.01
gemm/tiled 1917469.5 ns 2811927 ns 0.68
gemm/tiled_unbounded 1912107 ns 2830087 ns 0.68
integration/byval/reference 39241 ns 38111 ns 1.03
integration/byval/slices=1 41600 ns 40750 ns 1.02
integration/byval/slices=2 128632 ns 140552 ns 0.92
integration/byval/slices=3 228744 ns 213973 ns 1.07
integration/volumerhs 4851009 ns 4851138 ns 1.00
kernel/indexing 57620.75 ns 30203 ns 1.91
kernel/indexing_checked 39893 ns 35820.5 ns 1.11
kernel/launch 1225 ns 1272.5 ns 0.96
kernel/rand 72798.5 ns 50990.75 ns 1.43
latency/import 1801892031 ns 1628767420 ns 1.11
latency/precompile 32543029095 ns 29419546616 ns 1.11
latency/ttfp 2366949199 ns 2181231733 ns 1.09
stencil/diffusion3d 1567239.5 ns 1557121.75 ns 1.01
stencil/diffusion3d_checked 1620250.5 ns 1593372.25 ns 1.02

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

GPUArrays 12 removes default_rng, and nothing outside AMDGPU called AMDGPU's
method for it.
GPUArrays 12 implements these once for every GPU array on top of
AcceleratedKernels and removes the mapreducedim! hook, so delete AMDGPU's own
reduction kernel and its sort!, sortperm!, accumulate, findall, logical
indexing and reverse methods. The vector sort! and sortperm! methods were
ambiguous with GPUArrays', and the scans called AcceleratedKernels 0.4's API.
AMDGPU no longer depends on AcceleratedKernels directly; its AMDGPU extension
still loads through GPUArrays.
@maleadt maleadt closed this Oct 10, 2026
@maleadt maleadt reopened this Oct 10, 2026
Base.dataids returned the array's own pointer, which missed overlaps between
a contiguous view (a ROCArray at an offset) and a wrapped array of the same
memory, made every empty ROCArray alias every other one (all have address 0;
AcceleratedKernels' alias checks rejected that on Julia 1.10), and made
disjoint views of one buffer alias. GPUArrays 12.1 defines `Base.dataids` and
`Base.mightalias` for every GPU array from where its elements live, so
implement that hook instead, using the buffer's device address rather than
`pointer`, which takes stream ownership of the memory.
@maleadt
maleadt merged commit 8e8e3fe into main Oct 10, 2026
11 checks passed
@maleadt
maleadt deleted the tb/gpuarrays-12 branch October 10, 2026 16:27
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