Skip to content

Commit

Permalink
extend device selection unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
omlins committed Dec 1, 2023
1 parent 57a82a2 commit 04e85b4
Showing 1 changed file with 49 additions and 12 deletions.
61 changes: 49 additions & 12 deletions test/test_select_device.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04e85b4

Please sign in to comment.