diff --git a/Project.toml b/Project.toml index 0e34ee652..4e7c29ef9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ArrayInterface" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "6.0.0" +version = "5.3.0" [deps] ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2" diff --git a/lib/ArrayInterfaceCUDA/Project.toml b/lib/ArrayInterfaceCUDA/Project.toml index d449f14e2..bf0fcf144 100644 --- a/lib/ArrayInterfaceCUDA/Project.toml +++ b/lib/ArrayInterfaceCUDA/Project.toml @@ -6,11 +6,13 @@ version = "0.1.1" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" +ArrayInterfaceGPUArrays = "6ba088a2-8465-4c0a-af30-387133b534db" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" [compat] Adapt = "3" -ArrayInterface = "5" +ArrayInterface = "5, 6" +ArrayInterfaceGPUArrays = "0.1" CUDA = "3.9" julia = "1.6" diff --git a/lib/ArrayInterfaceCUDA/src/ArrayInterfaceCUDA.jl b/lib/ArrayInterfaceCUDA/src/ArrayInterfaceCUDA.jl index 6aeadda28..face1623b 100644 --- a/lib/ArrayInterfaceCUDA/src/ArrayInterfaceCUDA.jl +++ b/lib/ArrayInterfaceCUDA/src/ArrayInterfaceCUDA.jl @@ -1,27 +1,13 @@ module ArrayInterfaceCUDA using Adapt -using ArrayInterface +using ArrayInterface, ArrayInterfaceGPUArrays using CUDA -ArrayInterface.fast_scalar_indexing(::Type{<:CUDA.CuArray}) = false -@inline ArrayInterface.allowed_getindex(x::CUDA.CuArray, i...) = CUDA.@allowscalar(x[i...]) -@inline ArrayInterface.allowed_setindex!(x::CUDA.CuArray, v, i...) = (CUDA.@allowscalar(x[i...] = v)) - -function Base.setindex(x::CUDA.CuArray, v, i::Int) - _x = copy(x) - ArrayInterface.allowed_setindex!(_x, v, i) - return _x -end - -function ArrayInterface.restructure(x::CUDA.CuArray, y) - reshape(Adapt.adapt(ArrayInterface.parameterless_type(x), y), Base.size(x)...) -end - -ArrayInterface.device(::Type{<:CUDA.CuArray}) = ArrayInterface.GPU() - function ArrayInterface.lu_instance(A::CuMatrix{T}) where {T} CUDA.CUSOLVER.CuQR(similar(A, 0, 0), similar(A, 0)) end +ArrayInterface.device(::Type{<:CUDA.CuArray}) = ArrayInterface.GPU() + end # module diff --git a/lib/ArrayInterfaceGPUArrays/LICENSE b/lib/ArrayInterfaceGPUArrays/LICENSE new file mode 100644 index 000000000..49aa42e08 --- /dev/null +++ b/lib/ArrayInterfaceGPUArrays/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 SciML + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/ArrayInterfaceGPUArrays/Project.toml b/lib/ArrayInterfaceGPUArrays/Project.toml new file mode 100644 index 000000000..ae03c5f55 --- /dev/null +++ b/lib/ArrayInterfaceGPUArrays/Project.toml @@ -0,0 +1,17 @@ +name = "ArrayInterfaceGPUArrays" +uuid = "6ba088a2-8465-4c0a-af30-387133b534db" +authors = ["Zachary P. Christensen "] +version = "0.1.0" + +[deps] +Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" + +[compat] +Adapt = "3" +ArrayInterfaceCore = "0.1.1" +GPUArrays = "8" +julia = "1.6" + diff --git a/lib/ArrayInterfaceGPUArrays/src/ArrayInterfaceGPUArrays.jl b/lib/ArrayInterfaceGPUArrays/src/ArrayInterfaceGPUArrays.jl new file mode 100644 index 000000000..a7dd980f2 --- /dev/null +++ b/lib/ArrayInterfaceGPUArrays/src/ArrayInterfaceGPUArrays.jl @@ -0,0 +1,28 @@ +module ArrayInterfaceGPUArrays + +using Adapt +using ArrayInterface +using GPUArrays + +ArrayInterface.fast_scalar_indexing(::Type{<:GPUArrays.AbstractGPUArray}) = false +@inline ArrayInterface.allowed_getindex(x::GPUArrays.AbstractGPUArray, i...) = CUDA.@allowscalar(x[i...]) +@inline ArrayInterface.allowed_setindex!(x::GPUArrays.AbstractGPUArray, v, i...) = (CUDA.@allowscalar(x[i...] = v)) + +function Base.setindex(x::GPUArrays.AbstractGPUArray, v, i::Int) + _x = copy(x) + ArrayInterface.allowed_setindex!(_x, v, i) + return _x +end + +function ArrayInterface.restructure(x::GPUArrays.AbstractGPUArray, y) + reshape(Adapt.adapt(ArrayInterface.parameterless_type(x), y), Base.size(x)...) +end + +function ArrayInterface.lu_instance(A::GPUArrays.AbstractGPUMatrix{T}) where {T} + qr(similar(A, 1, 1)) +end + +# Doesn't do much, but makes a gigantic change to the dependency chain. +# ArrayInterface.device(::Type{<:GPUArrays.AbstractGPUArray}) = ArrayInterface.GPU() + +end \ No newline at end of file diff --git a/lib/ArrayInterfaceGPUArrays/test/runtests.jl b/lib/ArrayInterfaceGPUArrays/test/runtests.jl new file mode 100644 index 000000000..228811e6b --- /dev/null +++ b/lib/ArrayInterfaceGPUArrays/test/runtests.jl @@ -0,0 +1 @@ +using ArrayInterfaceGPUArrays \ No newline at end of file diff --git a/lib/ArrayInterfaceOffsetArrays/Project.toml b/lib/ArrayInterfaceOffsetArrays/Project.toml index ca0e74747..35a8e508a 100644 --- a/lib/ArrayInterfaceOffsetArrays/Project.toml +++ b/lib/ArrayInterfaceOffsetArrays/Project.toml @@ -8,7 +8,7 @@ OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" [compat] -ArrayInterface = "5" +ArrayInterface = "5, 6" OffsetArrays = "1.11" Static = "0.6" julia = "1.6" diff --git a/test/runtests.jl b/test/runtests.jl index 34a74c79e..e22ac22a6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -21,7 +21,7 @@ end groups = if GROUP == "All" ["ArrayInterfaceCore", "ArrayInterface", "ArrayInterfaceBandedMatrices", "ArrayInterfaceBlockBandedMatrices", - "ArrayInterfaceCUDA", "ArrayInterfaceOffsetArrays", "ArrayInterfaceStaticArrays"] + "ArrayInterfaceOffsetArrays", "ArrayInterfaceStaticArrays",] else [GROUP] end