diff --git a/test/test_select_device.jl b/test/test_select_device.jl index 5f80c63..4a5b37a 100644 --- a/test/test_select_device.jl +++ b/test/test_select_device.jl @@ -16,20 +16,57 @@ nprocs = MPI.Comm_size(MPI.COMM_WORLD); # NOTE: these tests can run with any num @testset "$(basename(@__FILE__)) (processes: $nprocs)" begin @testset "1. select_device" begin - @static if test_cuda - me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="CUDA"); - gpu_id = select_device(); - @test gpu_id < length(CUDA.devices()) - finalize_global_grid(finalize_MPI=false); + @static if test_cuda && !test_amdgpu + @testset "\"CUDA\"" begin + me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="CUDA"); + gpu_id = select_device(); + @test gpu_id < length(CUDA.devices()) + finalize_global_grid(finalize_MPI=false); + end; + @testset "\"auto\"" begin + me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="auto"); + gpu_id = select_device(); + @test gpu_id < length(CUDA.devices()) + finalize_global_grid(finalize_MPI=false); + end; end - @static if test_amdgpu - me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="AMDGPU"); - gpu_id = select_device(); - @test gpu_id < length(AMDGPU.devices()) - finalize_global_grid(finalize_MPI=false); + @static if test_amdgpu && !test_cuda + @testset "\"AMDGPU\"" begin + me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="AMDGPU"); + gpu_id = select_device(); + @test gpu_id < length(AMDGPU.devices()) + finalize_global_grid(finalize_MPI=false); + end; + @testset "\"auto\"" begin + me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="auto"); + gpu_id = select_device(); + @test gpu_id < length(AMDGPU.devices()) + finalize_global_grid(finalize_MPI=false); + end; + end + @static if !(test_cuda || test_amdgpu) || (test_cuda && test_amdgpu) + @testset "\"auto\"" begin + me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="auto"); + @test_throws ErrorException select_device() + finalize_global_grid(finalize_MPI=false); + end; + end + @static if !test_cuda + @testset "\"CUDA\"" begin + me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="CUDA"); + @test_throws ErrorException select_device() + finalize_global_grid(finalize_MPI=false); + end; + end + @static if !test_amdgpu + @testset "\"AMDGPU\"" begin + me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="AMDGPU"); + @test_throws ErrorException select_device() + finalize_global_grid(finalize_MPI=false); + end; end - @static if !(test_cuda || test_amdgpu) - me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false); + @testset "\"none\"" begin + me, = init_global_grid(3, 4, 5; quiet=true, init_MPI=false, device_type="none"); @test_throws ErrorException select_device() finalize_global_grid(finalize_MPI=false); end