@@ -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
151160end
0 commit comments