From 312f3c38471513dae458835111d6c3334bf6292e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Mon, 24 Nov 2025 21:30:42 +0000 Subject: [PATCH] Make package loadable on systems without oneAPI At the moment it's impossible to load this package in an environment with `oneAPI.jl`, if oneAPI isn't actually available (e.g. on aarch64 machines), which breaks lots of downstream workflows. --- Project.toml | 2 +- ext/KrylovPreconditionersOneAPIExt.jl | 30 +++++++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Project.toml b/Project.toml index fc4e3a8..fc62375 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "KrylovPreconditioners" uuid = "45d422c2-293f-44ce-8315-2cb988662dec" authors = ["Alexis Montoison "] -version = "0.3.6" +version = "0.3.7" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/ext/KrylovPreconditionersOneAPIExt.jl b/ext/KrylovPreconditionersOneAPIExt.jl index 452ae10..cdd055e 100644 --- a/ext/KrylovPreconditionersOneAPIExt.jl +++ b/ext/KrylovPreconditionersOneAPIExt.jl @@ -1,19 +1,23 @@ module KrylovPreconditionersOneAPIExt -using LinearAlgebra -using SparseArrays using oneAPI -using oneAPI: global_queue, sycl_queue, context, device -using oneAPI.oneMKL -using LinearAlgebra: checksquare, BlasReal, BlasFloat -import LinearAlgebra: ldiv!, mul! -import Base: size, eltype, unsafe_convert -using KrylovPreconditioners -const KP = KrylovPreconditioners -using KernelAbstractions -const KA = KernelAbstractions +# Don't do anything if oneAPI isn't actually available. +if oneAPI.oneL0.NEO_jll.is_available() && oneAPI.oneL0.functional[] + using oneAPI: global_queue, sycl_queue, context, device + using LinearAlgebra + using SparseArrays + using oneAPI.oneMKL + using LinearAlgebra: checksquare, BlasReal, BlasFloat + import LinearAlgebra: ldiv!, mul! + import Base: size, eltype, unsafe_convert -include("oneAPI/block_jacobi.jl") -include("oneAPI/operators.jl") + using KrylovPreconditioners + const KP = KrylovPreconditioners + using KernelAbstractions + const KA = KernelAbstractions + + include("oneAPI/block_jacobi.jl") + include("oneAPI/operators.jl") +end end