File tree Expand file tree Collapse file tree 4 files changed +38
-9
lines changed Expand file tree Collapse file tree 4 files changed +38
-9
lines changed Original file line number Diff line number Diff line change @@ -410,7 +410,13 @@ appleaccelerate_isavailable() = HAS_APPLE_ACCELERATE[]
410410# Extension availability checking functions
411411useblis () = Base. get_extension (@__MODULE__ , :LinearSolveBLISExt ) != = nothing
412412usecuda () = Base. get_extension (@__MODULE__ , :LinearSolveCUDAExt ) != = nothing
413- usemetal () = Base. get_extension (@__MODULE__ , :LinearSolveMetalExt ) != = nothing
413+
414+ # Metal is only available on Apple platforms
415+ @static if ! Sys. isapple ()
416+ usemetal () = false
417+ else
418+ usemetal () = Base. get_extension (@__MODULE__ , :LinearSolveMetalExt ) != = nothing
419+ end
414420
415421PrecompileTools. @compile_workload begin
416422 A = rand (4 , 4 )
Original file line number Diff line number Diff line change @@ -633,11 +633,19 @@ sol = solve(prob, alg)
633633"""
634634struct MetalLUFactorization <: AbstractFactorization
635635 function MetalLUFactorization (; throwerror = true )
636- ext = Base. get_extension (@__MODULE__ , :LinearSolveMetalExt )
637- if ext === nothing && throwerror
638- error (" MetalLUFactorization requires that Metal.jl is loaded, i.e. `using Metal`" )
636+ @static if ! Sys. isapple ()
637+ if throwerror
638+ error (" MetalLUFactorization is only available on Apple platforms" )
639+ else
640+ return new ()
641+ end
639642 else
640- return new ()
643+ ext = Base. get_extension (@__MODULE__ , :LinearSolveMetalExt )
644+ if ext === nothing && throwerror
645+ error (" MetalLUFactorization requires that Metal.jl is loaded, i.e. `using Metal`" )
646+ else
647+ return new ()
648+ end
641649 end
642650 end
643651end
Original file line number Diff line number Diff line change 6363
6464 # CUDA/Metal factorizations (only test if CUDA/Metal are loaded)
6565 # CudaOffloadFactorization requires CUDA to be loaded, skip if not available
66- if @isdefined (MetalLUFactorization)
66+ # Metal is only available on Apple platforms
67+ if Sys. isapple () && @isdefined (MetalLUFactorization)
6768 JET. @test_opt solve (prob, MetalLUFactorization ()) broken= true
6869 end
6970 if @isdefined (BLISLUFactorization)
Original file line number Diff line number Diff line change 3535 alg2 = LinearSolve. CudaOffloadLUFactorization (throwerror= false )
3636 @test alg2 isa LinearSolve. CudaOffloadLUFactorization
3737
38- alg3 = LinearSolve. MetalLUFactorization (throwerror= false )
39- @test alg3 isa LinearSolve. MetalLUFactorization
38+ # Metal is only available on Apple platforms
39+ if Sys. isapple ()
40+ alg3 = LinearSolve. MetalLUFactorization (throwerror= false )
41+ @test alg3 isa LinearSolve. MetalLUFactorization
42+ else
43+ # On non-Apple platforms, it should still not error with throwerror=false
44+ alg3 = LinearSolve. MetalLUFactorization (throwerror= false )
45+ @test alg3 isa LinearSolve. MetalLUFactorization
46+ end
4047
4148 # These should throw errors with throwerror=true (default)
4249 @test_throws ErrorException LinearSolve. BLISLUFactorization ()
4350 @test_throws ErrorException LinearSolve. CudaOffloadLUFactorization ()
44- @test_throws ErrorException LinearSolve. MetalLUFactorization ()
51+
52+ # Metal error message depends on platform
53+ if Sys. isapple ()
54+ @test_throws ErrorException LinearSolve. MetalLUFactorization ()
55+ else
56+ # On non-Apple platforms, should error with platform message
57+ @test_throws ErrorException LinearSolve. MetalLUFactorization ()
58+ end
4559end
4660
4761# Test that preferences system recognizes the new algorithms
You can’t perform that action at this time.
0 commit comments