Skip to content

Commit

Permalink
Add tests for gpu_backend!
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Jun 7, 2024
1 parent 3106ab7 commit 8c2c3ae
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,26 @@ end
@test get_device(x) isa LuxCPUDevice
@test get_device(x_view) isa LuxCPUDevice
end

@testset "loaded and functional" begin
@test LuxDeviceUtils.loaded(LuxCPUDevice)
@test LuxDeviceUtils.functional(LuxCPUDevice)
end

@testset "writing to preferences" begin
@test_logs (:info,
"Deleted the local preference for `gpu_backend`. Restart Julia to use the new backend.") gpu_backend!()

for backend in (:CUDA, :AMDGPU, :oneAPI, :Metal, LuxAMDGPUDevice(),
LuxCUDADevice(), LuxMetalDevice(), LuxoneAPIDevice())
backend_name = backend isa Symbol ? string(backend) :
LuxDeviceUtils._get_device_name(backend)
@test_logs (:info,
"GPU backend has been set to $(backend_name). Restart Julia to use the new backend.") gpu_backend!(backend)
end

gpu_backend!(:CUDA)
@test_logs (:info, "GPU backend is already set to CUDA. No action is required.") gpu_backend!(:CUDA)

@test_throws ArgumentError gpu_backend!("my_backend")
end

0 comments on commit 8c2c3ae

Please sign in to comment.