Skip to content

Commit 10f3c85

Browse files
committed
ROCm: Add multi-GPU tests
1 parent 77b0ab2 commit 10f3c85

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MetalExt = "Metal"
2626
ROCExt = "AMDGPU"
2727

2828
[compat]
29-
AMDGPU = "0.4"
29+
AMDGPU = "0.8.1"
3030
Adapt = "1, 2, 3, 4"
3131
CUDA = "3, 4, 5"
3232
Dagger = "0.17, 0.18"

test/runtests.jl

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,37 @@ end
124124
ROCArrayDeviceProc
125125
end
126126
@test DaggerGPU.processor(:ROC) === rocproc
127-
b = generate_thunks()
128-
c = Dagger.with_options(;scope=Dagger.scope(rocm_gpu=1)) do
129-
@test fetch(Dagger.@spawn isongpu(b))
130-
Dagger.@spawn sum(b)
127+
ndevices = length(AMDGPU.devices())
128+
129+
@testset "Arrays (GPU $gpu)" for gpu in 1:min(ndevices, 2)
130+
b = generate_thunks()
131+
c = Dagger.with_options(;scope=Dagger.scope(rocm_gpu=gpu)) do
132+
@test fetch(Dagger.@spawn isongpu(b))
133+
Dagger.@spawn sum(b)
134+
end
135+
@test !fetch(Dagger.@spawn isongpu(b))
136+
@test fetch(Dagger.@spawn identity(c)) == 20
131137
end
132-
@test !fetch(Dagger.@spawn isongpu(b))
133-
@test fetch(Dagger.@spawn identity(c)) == 20
134138

135-
@testset "KernelAbstractions" begin
139+
@testset "KernelAbstractions (GPU $gpu)" for gpu in 1:min(ndevices, 2)
136140
A = rand(Float32, 8)
137-
DA, T = Dagger.with_options(;scope=Dagger.scope(rocm_gpu=1)) do
141+
DA, T = Dagger.with_options(;scope=Dagger.scope(rocm_gpu=gpu)) do
138142
fetch(Dagger.@spawn fill_thunk(A, 2.3f0))
139143
end
140144
@test all(DA .== 2.3f0)
141145
@test T <: ROCArray
142146

143-
A = AMDGPU.rand(128)
144-
B = AMDGPU.zeros(128)
145-
Dagger.with_options(;scope=Dagger.scope(worker=1,rocm_gpu=1)) do
147+
local A, B
148+
AMDGPU.device!(AMDGPU.devices()[gpu]) do
149+
A = AMDGPU.rand(128)
150+
B = AMDGPU.zeros(128)
151+
end
152+
Dagger.with_options(;scope=Dagger.scope(worker=1,rocm_gpu=gpu)) do
146153
fetch(Dagger.@spawn Kernel(copy_kernel)(B, A; ndrange=length(A)))
147154
end
148-
@test all(B .== A)
155+
AMDGPU.device!(AMDGPU.devices()[gpu]) do
156+
@test all(B .== A)
157+
end
149158
end
150159
end
151160
end

0 commit comments

Comments
 (0)