Skip to content

Commit df3247a

Browse files
Redo ArrayInterface to use extension packages
* ArrayInterfaceCore -> ArrayInterface * ArrayInterface -> ArrayInterfaceStaticExt * All lib packages are extensions
1 parent 1c78e7c commit df3247a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1788
-2178
lines changed

.buildkite/pipeline.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ steps:
44
- JuliaCI/julia#v1:
55
version: "1"
66
- JuliaCI/julia-test#v1:
7-
- JuliaCI/julia-coverage#v1:
8-
codecov: true
7+
coverage: false # 1000x slowdown
98
agents:
109
queue: "juliagpu"
1110
cuda: "*"
1211
timeout_in_minutes: 60
12+
# Don't run Buildkite if the commit message includes the text [skip tests]
13+
if: build.message !~ /\[skip tests\]/
1314

1415
env:
16+
GROUP: GPU
1517
JULIA_PKG_SERVER: "" # it often struggles with our large artifacts
16-
SECRET_CODECOV_TOKEN: "b3VnbGgFLwQ5JLdP+RtluFzff8Iq7OdCr1mQiXIcrRz6w1gH1ZBO74lh5/G8G0DCZ8FcDPExcAU15Bgg1fnuKBUD+pM5+lh75Omd8sIQwy04KuFjya8LYRYTg9Jpi9LiUVFke/EpXnii84WkWGfvNMpLQedLvuM8FUzInFnuXicMgrbcIQQO0M7va/Efwn7yRiBLmgGv8jI5hphHsjF7joU1tnNeJEPTZ/oKzubxta0DlLW4DYaaRZc9RmsXGH2bg1el+ujouf8YZ4ncO7okvsgjSXzKxdGqN74WqlgzLZRtvtDkDRT8jTlugDq9C+oeUDnCfc6VJcSaNw1Kmk5OyQ==;U2FsdGVkX1+l463STh4TdVc8OUkIO2uf1pWXUtVHDZHgxILX1+40v9kVYUGznEE/flndA4dOk6PrND8KnISGsA=="
18+
# SECRET_CODECOV_TOKEN: "..."

.ci/test.jl

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
group:
17-
- ArrayInterface
18-
- ArrayInterfaceCore
19-
- ArrayInterfaceBandedMatrices
20-
- ArrayInterfaceBlockBandedMatrices
21-
- ArrayInterfaceOffsetArrays
22-
- ArrayInterfaceStaticArrays
23-
- ArrayInterfaceStaticArraysCore
24-
- ArrayInterfaceTracker
17+
- Core
2518
version:
2619
- '1'
2720
- '1.6'

Project.toml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,56 @@ uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
33
version = "6.0.25"
44

55
[deps]
6-
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"
76
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
8-
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
97
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
108
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
11-
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
9+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
10+
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
1211

1312
[compat]
14-
ArrayInterfaceCore = "0.1.3"
15-
Compat = "3, 4"
16-
IfElse = "0.1"
13+
Compat = "4"
1714
SnoopPrecompile = "1"
18-
Static = "0.8"
1915
julia = "1.6"
2016

17+
[extensions]
18+
ArrayInterfaceBandedMatricesExt = "BandedMatrices"
19+
ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices"
20+
ArrayInterfaceCUDAExt = "CUDA"
21+
ArrayInterfaceGPUArraysExt = "GPUArraysCore"
22+
ArrayInterfaceOffsetArraysExt = "OffsetArrays"
23+
ArrayInterfaceStaticArraysExt = "StaticArrays"
24+
ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore"
25+
ArrayInterfaceStaticExt = "Static"
26+
ArrayInterfaceTrackerExt = "Tracker"
27+
2128
[extras]
2229
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
30+
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
31+
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
32+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
33+
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
34+
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
35+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
36+
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
37+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
38+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
39+
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
40+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
41+
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
42+
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
43+
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
2344
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2445

2546
[targets]
26-
test = ["Pkg", "Test"]
47+
test = ["Pkg", "Test", "Aqua", "IfElse", "Random", "SparseArrays", "SuiteSparse", "Static", "BandedMatrices"]
48+
49+
[weakdeps]
50+
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
51+
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
52+
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
53+
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
54+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
55+
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
56+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
57+
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
58+
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
module ArrayInterfaceBandedMatrices
1+
module ArrayInterfaceBandedMatricesExt
22

3-
using ArrayInterfaceCore
3+
using ArrayInterface
44
using BandedMatrices
55

6-
struct BandedMatrixIndex <: ArrayInterfaceCore.MatrixIndex
6+
struct BandedMatrixIndex <: ArrayInterface.MatrixIndex
77
count::Int
88
rowsize::Int
99
colsize::Int
@@ -50,22 +50,22 @@ function BandedMatrixIndex(rowsize, colsize, lowerbandwidth, upperbandwidth, isr
5050
BandedMatrixIndex(sum(bandsizes), rowsize, colsize, bandinds, bandsizes, isrow)
5151
end
5252

53-
function ArrayInterfaceCore.findstructralnz(x::BandedMatrices.BandedMatrix)
53+
function ArrayInterface.findstructralnz(x::BandedMatrices.BandedMatrix)
5454
l, u = BandedMatrices.bandwidths(x)
5555
rowsize, colsize = Base.size(x)
5656
rowind = BandedMatrixIndex(rowsize, colsize, l, u, true)
5757
colind = BandedMatrixIndex(rowsize, colsize, l, u, false)
5858
return (rowind, colind)
5959
end
6060

61-
ArrayInterfaceCore.has_sparsestruct(::Type{<:BandedMatrices.BandedMatrix}) = true
62-
ArrayInterfaceCore.isstructured(::Type{<:BandedMatrices.BandedMatrix}) = true
63-
ArrayInterfaceCore.fast_matrix_colors(::Type{<:BandedMatrices.BandedMatrix}) = true
61+
ArrayInterface.has_sparsestruct(::Type{<:BandedMatrices.BandedMatrix}) = true
62+
ArrayInterface.isstructured(::Type{<:BandedMatrices.BandedMatrix}) = true
63+
ArrayInterface.fast_matrix_colors(::Type{<:BandedMatrices.BandedMatrix}) = true
6464

65-
function ArrayInterfaceCore.matrix_colors(A::BandedMatrices.BandedMatrix)
65+
function ArrayInterface.matrix_colors(A::BandedMatrices.BandedMatrix)
6666
l, u = BandedMatrices.bandwidths(A)
6767
width = u + l + 1
68-
return ArrayInterfaceCore._cycle(1:width, Base.size(A, 2))
68+
return ArrayInterface._cycle(1:width, Base.size(A, 2))
6969
end
7070

7171
end # module
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module ArrayInterfaceBlockBandedMatrices
1+
module ArrayInterfaceBlockBandedMatricesExt
22

3-
using ArrayInterfaceCore
3+
using ArrayInterface
44
using ArrayInterfaceBandedMatrices
5-
using BlockArrays
65
using BlockBandedMatrices
6+
using BlockBandedMatrices.BlockArrays
77

8-
struct BlockBandedMatrixIndex <: ArrayInterfaceCore.MatrixIndex
8+
struct BlockBandedMatrixIndex <: ArrayInterface.MatrixIndex
99
count::Int
1010
refinds::Array{Int,1}
1111
refcoords::Array{Int,1}# storing col or row inds at ref points
@@ -81,7 +81,7 @@ Base.@propagate_inbounds function Base.getindex(ind::BlockBandedMatrixIndex, i::
8181
end
8282
end
8383

84-
function ArrayInterfaceCore.findstructralnz(x::BlockBandedMatrices.BlockBandedMatrix)
84+
function ArrayInterface.findstructralnz(x::BlockBandedMatrices.BlockBandedMatrix)
8585
l, u = BlockBandedMatrices.blockbandwidths(x)
8686
nrowblock = BlockBandedMatrices.blocksize(x, 1)
8787
ncolblock = BlockBandedMatrices.blocksize(x, 2)
@@ -96,7 +96,7 @@ function ArrayInterfaceCore.findstructralnz(x::BlockBandedMatrices.BlockBandedMa
9696
u,
9797
)
9898
end
99-
struct BandedBlockBandedMatrixIndex <: ArrayInterfaceCore.MatrixIndex
99+
struct BandedBlockBandedMatrixIndex <: ArrayInterface.MatrixIndex
100100
count::Int
101101
refinds::Array{Int,1}
102102
refcoords::Array{Int,1}# storing col or row inds at ref points
@@ -178,7 +178,7 @@ function BandedBlockBandedMatrixIndex(
178178
rowindobj, colindobj
179179
end
180180

181-
function ArrayInterfaceCore.findstructralnz(x::BlockBandedMatrices.BandedBlockBandedMatrix)
181+
function ArrayInterface.findstructralnz(x::BlockBandedMatrices.BandedBlockBandedMatrix)
182182
l, u = BlockBandedMatrices.blockbandwidths(x)
183183
lambda, mu = BlockBandedMatrices.subblockbandwidths(x)
184184
nrowblock = BlockBandedMatrices.blocksize(x, 1)
@@ -197,19 +197,19 @@ function ArrayInterfaceCore.findstructralnz(x::BlockBandedMatrices.BandedBlockBa
197197
)
198198
end
199199

200-
ArrayInterfaceCore.has_sparsestruct(::Type{<:BlockBandedMatrices.BlockBandedMatrix}) = true
201-
ArrayInterfaceCore.has_sparsestruct(::Type{<:BlockBandedMatrices.BandedBlockBandedMatrix}) = true
202-
ArrayInterfaceCore.isstructured(::Type{<:BlockBandedMatrices.BlockBandedMatrix}) = true
203-
ArrayInterfaceCore.isstructured(::Type{<:BlockBandedMatrices.BandedBlockBandedMatrix}) = true
204-
ArrayInterfaceCore.fast_matrix_colors(::Type{<:BlockBandedMatrices.BlockBandedMatrix}) = true
205-
ArrayInterfaceCore.fast_matrix_colors(::Type{<:BlockBandedMatrices.BandedBlockBandedMatrix}) = true
200+
ArrayInterface.has_sparsestruct(::Type{<:BlockBandedMatrices.BlockBandedMatrix}) = true
201+
ArrayInterface.has_sparsestruct(::Type{<:BlockBandedMatrices.BandedBlockBandedMatrix}) = true
202+
ArrayInterface.isstructured(::Type{<:BlockBandedMatrices.BlockBandedMatrix}) = true
203+
ArrayInterface.isstructured(::Type{<:BlockBandedMatrices.BandedBlockBandedMatrix}) = true
204+
ArrayInterface.fast_matrix_colors(::Type{<:BlockBandedMatrices.BlockBandedMatrix}) = true
205+
ArrayInterface.fast_matrix_colors(::Type{<:BlockBandedMatrices.BandedBlockBandedMatrix}) = true
206206

207-
function ArrayInterfaceCore.matrix_colors(A::BlockBandedMatrices.BlockBandedMatrix)
207+
function ArrayInterface.matrix_colors(A::BlockBandedMatrices.BlockBandedMatrix)
208208
l, u = BlockBandedMatrices.blockbandwidths(A)
209209
blockwidth = l + u + 1
210210
nblock = BlockBandedMatrices.blocksize(A, 2)
211211
cols = BlockArrays.blocklengths(axes(A, 2))
212-
blockcolors = ArrayInterfaceCore._cycle(1:blockwidth, nblock)
212+
blockcolors = ArrayInterface._cycle(1:blockwidth, nblock)
213213
# the reserved number of colors of a block is the maximum length of columns of blocks with the same block color
214214
ncolors = [maximum(cols[i:blockwidth:nblock]) for i = 1:blockwidth]
215215
endinds = cumsum(ncolors)
@@ -221,14 +221,14 @@ function ArrayInterfaceCore.matrix_colors(A::BlockBandedMatrices.BlockBandedMatr
221221
return reduce(vcat, colors)
222222
end
223223

224-
function ArrayInterfaceCore.matrix_colors(A::BlockBandedMatrices.BandedBlockBandedMatrix)
224+
function ArrayInterface.matrix_colors(A::BlockBandedMatrices.BandedBlockBandedMatrix)
225225
l, u = BlockBandedMatrices.blockbandwidths(A)
226226
lambda, mu = BlockBandedMatrices.subblockbandwidths(A)
227227
blockwidth = l + u + 1
228228
subblockwidth = lambda + mu + 1
229229
nblock = BlockBandedMatrices.blocksize(A, 2)
230230
cols = BlockArrays.blocklengths(axes(A, 2))
231-
blockcolors = ArrayInterfaceCore._cycle(1:blockwidth, nblock)
231+
blockcolors = ArrayInterface._cycle(1:blockwidth, nblock)
232232
# the reserved number of colors of a block is the min of subblockwidth and the largest length of columns of blocks with the same block color
233233
ncolors = [
234234
min(subblockwidth, maximum(cols[i:blockwidth:nblock]))
@@ -237,7 +237,7 @@ function ArrayInterfaceCore.matrix_colors(A::BlockBandedMatrices.BandedBlockBand
237237
endinds = cumsum(ncolors)
238238
startinds = [endinds[i] - ncolors[i] + 1 for i = 1:min(blockwidth, nblock)]
239239
colors = [
240-
ArrayInterfaceCore._cycle(startinds[blockcolors[i]]:endinds[blockcolors[i]], cols[i])
240+
ArrayInterface._cycle(startinds[blockcolors[i]]:endinds[blockcolors[i]], cols[i])
241241
for i = 1:nblock
242242
]
243243
return reduce(vcat, colors)

lib/ArrayInterfaceCUDA/src/ArrayInterfaceCUDA.jl renamed to ext/ArrayInterfaceCUDA.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module ArrayInterfaceCUDA
1+
module ArrayInterfaceCUDAExt
22

33
using Adapt
4-
using ArrayInterface, ArrayInterfaceGPUArrays
4+
using ArrayInterface
55
using CUDA
66
using CUDA.CUSOLVER
77

ext/ArrayInterfaceGPUArrays.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module ArrayInterfaceGPUArraysExt
2+
3+
using Adapt
4+
using ArrayInterface
5+
using GPUArraysCore
6+
using LinearAlgebra: lu
7+
8+
ArrayInterface.fast_scalar_indexing(::Type{<:GPUArraysCore.AbstractGPUArray}) = false
9+
@inline ArrayInterface.allowed_getindex(x::GPUArraysCore.AbstractGPUArray, i...) = GPUArraysCore.@allowscalar(x[i...])
10+
@inline ArrayInterface.allowed_setindex!(x::GPUArraysCore.AbstractGPUArray, v, i...) = (GPUArraysCore.@allowscalar(x[i...] = v))
11+
12+
function Base.setindex(x::GPUArraysCore.AbstractGPUArray, v, i::Int)
13+
_x = copy(x)
14+
ArrayInterface.allowed_setindex!(_x, v, i)
15+
return _x
16+
end
17+
18+
function ArrayInterface.restructure(x::GPUArraysCore.AbstractGPUArray, y)
19+
reshape(Adapt.adapt(ArrayInterface.parameterless_type(x), y), Base.size(x)...)
20+
end
21+
22+
function ArrayInterface.lu_instance(A::GPUArraysCore.AbstractGPUMatrix{T}) where {T}
23+
lu(Adapt.adapt(ArrayInterface.parameterless_type(A), ones(T, 0, 0)))
24+
end
25+
26+
# Doesn't do much, but makes a gigantic change to the dependency chain.
27+
# ArrayInterface.device(::Type{<:GPUArraysCore.AbstractGPUArray}) = ArrayInterface.GPU()
28+
29+
end

lib/ArrayInterfaceOffsetArrays/src/ArrayInterfaceOffsetArrays.jl renamed to ext/ArrayInterfaceOffsetArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module ArrayInterfaceOffsetArrays
1+
module ArrayInterfaceOffsetArraysExt
22

33
using ArrayInterface
44
using OffsetArrays

lib/ArrayInterfaceStaticArrays/src/ArrayInterfaceStaticArrays.jl renamed to ext/ArrayInterfaceStaticArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module ArrayInterfaceStaticArrays
1+
module ArrayInterfaceStaticArraysExt
22

33
using Adapt
44
using ArrayInterface

0 commit comments

Comments
 (0)