7979 CuArrayDeviceProc
8080 end
8181 @test DaggerGPU. processor (:CUDA ) === cuproc
82- b = generate_thunks ()
83- c = Dagger. with_options (;scope= Dagger. scope (cuda_gpu= 1 )) do
84- @test fetch (Dagger. @spawn isongpu (b))
85- Dagger. @spawn sum (b)
82+ ndevices = length (collect (CUDA. devices ()))
83+
84+ @testset " Arrays (GPU $gpu )" for gpu in 1 : min (ndevices, 2 )
85+ b = generate_thunks ()
86+ c = Dagger. with_options (;scope= Dagger. scope (cuda_gpu= gpu)) do
87+ @test fetch (Dagger. @spawn isongpu (b))
88+ Dagger. @spawn sum (b)
89+ end
90+ @test ! fetch (Dagger. @spawn isongpu (b))
91+ @test fetch (Dagger. @spawn identity (c)) == 20
8692 end
87- @test ! fetch (Dagger. @spawn isongpu (b))
88- @test fetch (Dagger. @spawn identity (c)) == 20
8993
90- @testset " KernelAbstractions" begin
94+ @testset " KernelAbstractions (GPU $gpu ) " for gpu in 1 : min (ndevices, 2 )
9195 A = rand (Float32, 8 )
92- DA, T = Dagger. with_options (;scope= Dagger. scope (cuda_gpu= 1 )) do
96+ DA, T = Dagger. with_options (;scope= Dagger. scope (cuda_gpu= gpu )) do
9397 fetch (Dagger. @spawn fill_thunk (A, 2.3f0 ))
9498 end
9599 @test all (DA .== 2.3f0 )
96100 @test T <: CuArray
97101
98- A = CUDA. rand (128 )
99- B = CUDA. zeros (128 )
100- Dagger. with_options (;scope= Dagger. scope (worker= 1 ,cuda_gpu= 1 )) do
102+ local A, B
103+ CUDA. device! (gpu- 1 ) do
104+ A = CUDA. rand (128 )
105+ B = CUDA. zeros (128 )
106+ end
107+ Dagger. with_options (;scope= Dagger. scope (worker= 1 ,cuda_gpu= gpu)) do
101108 fetch (Dagger. @spawn Kernel (copy_kernel)(B, A; ndrange= length (A)))
102109 end
103- @test all (B .== A)
110+ CUDA. device! (gpu- 1 ) do
111+ @test all (B .== A)
112+ end
104113 end
105114 end
106115end
@@ -115,28 +124,37 @@ end
115124 ROCArrayDeviceProc
116125 end
117126 @test DaggerGPU. processor (:ROC ) === rocproc
118- b = generate_thunks ()
119- c = Dagger. with_options (;scope= Dagger. scope (rocm_gpu= 1 )) do
120- @test fetch (Dagger. @spawn isongpu (b))
121- 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
122137 end
123- @test ! fetch (Dagger. @spawn isongpu (b))
124- @test fetch (Dagger. @spawn identity (c)) == 20
125138
126- @testset " KernelAbstractions" begin
139+ @testset " KernelAbstractions (GPU $gpu ) " for gpu in 1 : min (ndevices, 2 )
127140 A = rand (Float32, 8 )
128- 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
129142 fetch (Dagger. @spawn fill_thunk (A, 2.3f0 ))
130143 end
131144 @test all (DA .== 2.3f0 )
132145 @test T <: ROCArray
133146
134- A = AMDGPU. rand (128 )
135- B = AMDGPU. zeros (128 )
136- 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
137153 fetch (Dagger. @spawn Kernel (copy_kernel)(B, A; ndrange= length (A)))
138154 end
139- @test all (B .== A)
155+ AMDGPU. device! (AMDGPU. devices ()[gpu]) do
156+ @test all (B .== A)
157+ end
140158 end
141159 end
142160end
0 commit comments