Skip to content

Commit

Permalink
fix testing to not include all backends automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Dale-Black committed Sep 10, 2024
1 parent 979efc6 commit e8bb4c9
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
using DistanceTransforms
using Test

using KernelAbstractions
using CUDA, AMDGPU, Metal
using oneAPI
using Random
AVAILABLE_GPU_BACKENDS = ["CUDA", "AMDGPU", "Metal", "oneAPI"]
TEST_BACKENDS = filter(x->x in [AVAILABLE_GPU_BACKENDS; "CPU"], ARGS)

if isempty(TEST_BACKENDS)
using Preferences
TEST_BACKENDS = [load_preference(KomaMRICore, "test_backend", "CPU")]
@info "Using [preferences.KomaMRICore]." backend=first(TEST_BACKENDS)
else
@info "Using test_args" backend=first(TEST_BACKENDS)
end

USE_GPU = any(AVAILABLE_GPU_BACKENDS .∈ Ref(TEST_BACKENDS))

if CUDA.functional()
@info "Using CUDA"
if "CUDA" in TEST_BACKENDS
using CUDA
CUDA.versioninfo()
backend = CUDABackend()
dev = CuArray
elseif AMDGPU.functional()
@info "Using AMD"
elseif "AMDGPU" in TEST_BACKENDS
using AMDGPU
AMDGPU.versioninfo()
backend = ROCBackend()
dev = ROCArray
elseif oneAPI.functional() ## not well supported
@info "Using oneAPI"
oneAPI.versioninfo()
backend = oneBackend()
dev = oneArray
elseif Metal.functional()
@info "Using Metal"
elseif "Metal" in TEST_BACKENDS
using Metal
Metal.versioninfo()
backend = MetalBackend()
dev = MtlArray
elseif "oneAPI" in TEST_BACKENDS
using oneAPI
oneAPI.versioninfo()
backend = oneBackend()
dev = oneArray
else
@info "No GPU is available. Using CPU."
@info "CPU using $(Threads.nthreads()) thread(s)" maxlog=1
backend = CPU()
dev = Array
end

using KernelAbstractions
using Random

include("transform.jl")
include("utils.jl")

0 comments on commit e8bb4c9

Please sign in to comment.