From 7c10d8d0be4090e4eefe2fa37b64fe4adbaa3c1e Mon Sep 17 00:00:00 2001 From: KristofferC Date: Mon, 6 Mar 2023 12:27:40 +0100 Subject: [PATCH 1/4] correct Requires usage to fix issues with PackageCompiler sysimages --- ext/ArrayInterfaceBandedMatricesExt.jl | 14 +++++++++++--- ext/ArrayInterfaceBlockBandedMatricesExt.jl | 9 ++++++--- ext/ArrayInterfaceCUDAExt.jl | 8 ++++---- ext/ArrayInterfaceGPUArraysCoreExt.jl | 16 ++++++++++++---- ext/ArrayInterfaceStaticArraysCoreExt.jl | 12 +++++++++--- ext/ArrayInterfaceTrackerExt.jl | 9 +++++++-- 6 files changed, 49 insertions(+), 19 deletions(-) diff --git a/ext/ArrayInterfaceBandedMatricesExt.jl b/ext/ArrayInterfaceBandedMatricesExt.jl index 0514f591f..358434f15 100644 --- a/ext/ArrayInterfaceBandedMatricesExt.jl +++ b/ext/ArrayInterfaceBandedMatricesExt.jl @@ -1,8 +1,16 @@ module ArrayInterfaceBandedMatricesExt -using ArrayInterface -using ArrayInterface: BandedMatrixIndex -isdefined(Base, :get_extension) ? (using BandedMatrices) : (using ..BandedMatrices) + +if isdefined(Base, :get_extension) + using ArrayInterface + using ArrayInterface: BandedMatrixIndex + using BandedMatrices +else + using ..ArrayInterface + using ..ArrayInterface: BandedMatrixIndex + using ..BandedMatrices +end + Base.firstindex(i::BandedMatrixIndex) = 1 Base.lastindex(i::BandedMatrixIndex) = i.count diff --git a/ext/ArrayInterfaceBlockBandedMatricesExt.jl b/ext/ArrayInterfaceBlockBandedMatricesExt.jl index f5fc743d7..f66362130 100644 --- a/ext/ArrayInterfaceBlockBandedMatricesExt.jl +++ b/ext/ArrayInterfaceBlockBandedMatricesExt.jl @@ -1,12 +1,15 @@ module ArrayInterfaceBlockBandedMatricesExt -using ArrayInterface -using ArrayInterface: BandedMatrixIndex -if isdefined(Base, :get_extension) + +if isdefined(Base, :get_extension) + using ArrayInterface + using ArrayInterface: BandedMatrixIndex using BlockBandedMatrices using BlockBandedMatrices.BlockArrays else + using ..ArrayInterface + using ..ArrayInterface: BandedMatrixIndex using ..BlockBandedMatrices using ..BlockBandedMatrices.BlockArrays end diff --git a/ext/ArrayInterfaceCUDAExt.jl b/ext/ArrayInterfaceCUDAExt.jl index 08dbde81f..f5d2a9507 100644 --- a/ext/ArrayInterfaceCUDAExt.jl +++ b/ext/ArrayInterfaceCUDAExt.jl @@ -2,16 +2,16 @@ module ArrayInterfaceCUDAExt using ArrayInterface -if isdefined(Base, :get_extension) +if isdefined(Base, :get_extension) using CUDA using CUDA.CUSOLVER -else + using LinearAlgebra +else using ..CUDA using ..CUDA.CUSOLVER + using ..LinearAlgebra end -using LinearAlgebra - function ArrayInterface.lu_instance(A::CuMatrix{T}) where {T} if VERSION >= v"1.8-" ipiv = cu(Vector{Int32}(undef, 0)) diff --git a/ext/ArrayInterfaceGPUArraysCoreExt.jl b/ext/ArrayInterfaceGPUArraysCoreExt.jl index 0c97695d3..a551df9c7 100644 --- a/ext/ArrayInterfaceGPUArraysCoreExt.jl +++ b/ext/ArrayInterfaceGPUArraysCoreExt.jl @@ -1,9 +1,17 @@ module ArrayInterfaceGPUArraysCoreExt -using Adapt -using ArrayInterface -using LinearAlgebra: lu -isdefined(Base, :get_extension) ? (import GPUArraysCore) : (import ..GPUArraysCore) + +if isdefined(Base, :get_extension) + using Adapt + using ArrayInterface + using LinearAlgebra: lu + import GPUArraysCore +else + using ..Adapt + using ..ArrayInterface + using ..LinearAlgebra: lu + import ..GPUArraysCore +end ArrayInterface.fast_scalar_indexing(::Type{<:GPUArraysCore.AbstractGPUArray}) = false @inline ArrayInterface.allowed_getindex(x::GPUArraysCore.AbstractGPUArray, i...) = GPUArraysCore.@allowscalar(x[i...]) diff --git a/ext/ArrayInterfaceStaticArraysCoreExt.jl b/ext/ArrayInterfaceStaticArraysCoreExt.jl index e29797247..bf5a11006 100644 --- a/ext/ArrayInterfaceStaticArraysCoreExt.jl +++ b/ext/ArrayInterfaceStaticArraysCoreExt.jl @@ -1,8 +1,14 @@ module ArrayInterfaceStaticArraysCoreExt -import ArrayInterface -using LinearAlgebra -isdefined(Base, :get_extension) ? (import StaticArraysCore) : (import ..StaticArraysCore) +if isdefined(Base, :get_extension) + import ArrayInterface + using LinearAlgebra + import StaticArraysCore +else + import ..ArrayInterface + using ..LinearAlgebra + import ..StaticArraysCore +end function ArrayInterface.undefmatrix(::StaticArraysCore.MArray{S, T, N, L}) where {S, T, N, L} return StaticArraysCore.MMatrix{L, L, T, L*L}(undef) diff --git a/ext/ArrayInterfaceTrackerExt.jl b/ext/ArrayInterfaceTrackerExt.jl index d63a4516f..4bb10c39c 100644 --- a/ext/ArrayInterfaceTrackerExt.jl +++ b/ext/ArrayInterfaceTrackerExt.jl @@ -1,7 +1,12 @@ module ArrayInterfaceTrackerExt -using ArrayInterface -isdefined(Base, :get_extension) ? (import Tracker) : (import ..Tracker) +if isdefined(Base, :get_extension) + using ArrayInterface + import Tracker +else + using ..ArrayInterface + import ..Tracker +end ArrayInterface.ismutable(::Type{<:Tracker.TrackedArray}) = false ArrayInterface.ismutable(T::Type{<:Tracker.TrackedReal}) = false From 204db3eb9a3bfb242cc7c9609ebcc28f7320d152 Mon Sep 17 00:00:00 2001 From: KristofferC Date: Mon, 6 Mar 2023 16:00:01 +0100 Subject: [PATCH 2/4] load Adapt from environment even though it will cause relocatability issues --- ext/ArrayInterfaceGPUArraysCoreExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ArrayInterfaceGPUArraysCoreExt.jl b/ext/ArrayInterfaceGPUArraysCoreExt.jl index a551df9c7..40d0fc1ac 100644 --- a/ext/ArrayInterfaceGPUArraysCoreExt.jl +++ b/ext/ArrayInterfaceGPUArraysCoreExt.jl @@ -7,7 +7,7 @@ if isdefined(Base, :get_extension) using LinearAlgebra: lu import GPUArraysCore else - using ..Adapt + using Adapt # Will cause problems for relocatability. using ..ArrayInterface using ..LinearAlgebra: lu import ..GPUArraysCore From 60aa0c242c44fa591f0003bc62aa6fd018b41ac1 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 6 Mar 2023 10:07:07 -0500 Subject: [PATCH 3/4] Update ArrayInterfaceGPUArraysCoreExt.jl --- ext/ArrayInterfaceGPUArraysCoreExt.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/ArrayInterfaceGPUArraysCoreExt.jl b/ext/ArrayInterfaceGPUArraysCoreExt.jl index 40d0fc1ac..ba81d1964 100644 --- a/ext/ArrayInterfaceGPUArraysCoreExt.jl +++ b/ext/ArrayInterfaceGPUArraysCoreExt.jl @@ -2,7 +2,6 @@ module ArrayInterfaceGPUArraysCoreExt if isdefined(Base, :get_extension) - using Adapt using ArrayInterface using LinearAlgebra: lu import GPUArraysCore From 9bbde835297e2131e155dd42feb95e7b2485f918 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Mon, 6 Mar 2023 10:27:07 -0500 Subject: [PATCH 4/4] Update ArrayInterfaceGPUArraysCoreExt.jl --- ext/ArrayInterfaceGPUArraysCoreExt.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/ArrayInterfaceGPUArraysCoreExt.jl b/ext/ArrayInterfaceGPUArraysCoreExt.jl index ba81d1964..40d0fc1ac 100644 --- a/ext/ArrayInterfaceGPUArraysCoreExt.jl +++ b/ext/ArrayInterfaceGPUArraysCoreExt.jl @@ -2,6 +2,7 @@ module ArrayInterfaceGPUArraysCoreExt if isdefined(Base, :get_extension) + using Adapt using ArrayInterface using LinearAlgebra: lu import GPUArraysCore