Skip to content

Commit 320795e

Browse files
committed
test/GPU: Factor out scopes to test
1 parent 421ec70 commit 320795e

File tree

3 files changed

+94
-57
lines changed

3 files changed

+94
-57
lines changed

test/gpu.jl

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,7 @@
11
using Random
22
using LinearAlgebra
33

4-
if USE_CUDA
5-
using Pkg
6-
Pkg.add("CUDA")
7-
end
8-
if USE_ROCM
9-
using Pkg
10-
Pkg.add("AMDGPU")
11-
end
12-
if USE_ONEAPI
13-
using Pkg
14-
Pkg.add("oneAPI")
15-
end
16-
if USE_METAL
17-
using Pkg
18-
Pkg.add("Metal")
19-
end
20-
if USE_OPENCL
21-
using Pkg
22-
Pkg.add("OpenCL")
23-
Pkg.add("pocl_jll")
24-
end
25-
264
@everywhere begin
27-
if $USE_CUDA
28-
using CUDA
29-
elseif !$IN_CI
30-
try using CUDA
31-
catch end
32-
end
33-
34-
if $USE_ROCM
35-
using AMDGPU
36-
elseif !$IN_CI
37-
try using AMDGPU
38-
catch end
39-
end
40-
41-
if $USE_ONEAPI
42-
using oneAPI
43-
elseif !$IN_CI
44-
try using oneAPI
45-
catch end
46-
end
47-
48-
if $USE_METAL
49-
using Metal
50-
elseif !$IN_CI
51-
try using Metal
52-
catch end
53-
end
54-
55-
if $USE_OPENCL
56-
using pocl_jll, OpenCL
57-
elseif !$IN_CI
58-
try using pocl_jll, OpenCL
59-
catch end
60-
end
61-
625
using Distributed, Dagger
636
import Dagger: Kernel
647
using KernelAbstractions

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ using Dagger
136136
using UUIDs
137137
import MemPool
138138

139+
GPU_SCOPES = Pair{Symbol, Dagger.AbstractScope}[]
140+
if USE_GPU
141+
include("setup_gpu.jl")
142+
end
143+
139144
try
140145
for test in to_test
141146
test_title = tests[findfirst(x->x[2]==test * ".jl", tests)][1]

test/setup_gpu.jl

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
if USE_CUDA
2+
using Pkg
3+
Pkg.add("CUDA")
4+
end
5+
if USE_ROCM
6+
using Pkg
7+
Pkg.add("AMDGPU")
8+
end
9+
if USE_ONEAPI
10+
using Pkg
11+
Pkg.add("oneAPI")
12+
end
13+
if USE_METAL
14+
using Pkg
15+
Pkg.add("Metal")
16+
end
17+
if USE_OPENCL
18+
using Pkg
19+
Pkg.add("OpenCL")
20+
Pkg.add("pocl_jll")
21+
end
22+
23+
@everywhere begin
24+
if $USE_CUDA
25+
using CUDA
26+
elseif !$IN_CI
27+
try using CUDA
28+
catch end
29+
end
30+
31+
if $USE_ROCM
32+
using AMDGPU
33+
elseif !$IN_CI
34+
try using AMDGPU
35+
catch end
36+
end
37+
38+
if $USE_ONEAPI
39+
using oneAPI
40+
elseif !$IN_CI
41+
try using oneAPI
42+
catch end
43+
end
44+
45+
if $USE_METAL
46+
using Metal
47+
elseif !$IN_CI
48+
try using Metal
49+
catch end
50+
end
51+
52+
if $USE_OPENCL
53+
using pocl_jll, OpenCL
54+
elseif !$IN_CI
55+
try using pocl_jll, OpenCL
56+
catch end
57+
end
58+
end
59+
60+
if USE_CUDA
61+
push!(GPU_SCOPES, :CUDA => Dagger.scope(;worker=1, cuda_gpu=1))
62+
if length(CUDA.devices()) > 1
63+
push!(GPU_SCOPES, :CUDA => Dagger.scope(;worker=1, cuda_gpu=2))
64+
end
65+
end
66+
if USE_ROCM
67+
push!(GPU_SCOPES, :ROCm => Dagger.scope(;worker=1, rocm_gpu=1))
68+
if length(AMDGPU.devices()) > 1
69+
push!(GPU_SCOPES, :ROCm => Dagger.scope(;worker=1, rocm_gpu=2))
70+
end
71+
end
72+
if USE_ONEAPI
73+
push!(GPU_SCOPES, :oneAPI => Dagger.scope(;worker=1, intel_gpu=1))
74+
if length(oneAPI.devices()) > 1
75+
push!(GPU_SCOPES, :oneAPI => Dagger.scope(;worker=1, intel_gpu=2))
76+
end
77+
end
78+
if USE_METAL
79+
push!(GPU_SCOPES, :Metal => Dagger.scope(;worker=1, metal_gpu=1))
80+
if length(Metal.devices()) > 1
81+
push!(GPU_SCOPES, :Metal => Dagger.scope(;worker=1, metal_gpu=2))
82+
end
83+
end
84+
if USE_OPENCL
85+
push!(GPU_SCOPES, :OpenCL => Dagger.scope(;worker=1, cl_device=1))
86+
if length(cl.devices(cl.default_platform())) > 1
87+
push!(GPU_SCOPES, :OpenCL => Dagger.scope(;worker=1, cl_device=2))
88+
end
89+
end

0 commit comments

Comments
 (0)