Skip to content

Commit 435dfcf

Browse files
committed
Update PR
1 parent fd10439 commit 435dfcf

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-27
lines changed

ext/SparseArraysExt.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SparseArraysExt
22

3-
using DistributedArrays: DArray, localpart
3+
using DistributedArrays: DArray, SubDArray, SubOrDArray, localpart
44
using DistributedArrays.Distributed: remotecall_fetch
55
using SparseArrays: SparseArrays, nnz
66

@@ -11,4 +11,21 @@ function SparseArrays.nnz(A::DArray)
1111
return reduce(+, B)
1212
end
1313

14+
# Fix method ambiguities
15+
# TODO: Improve efficiency?
16+
Base.copyto!(dest::SubOrDArray{<:Any,2}, src::SparseArrays.AbstractSparseMatrixCSC) = copyto!(dest, Matrix(src))
17+
@static if isdefined(SparseArrays, :CHOLMOD)
18+
Base.copyto!(dest::SubOrDArray, src::SparseArrays.CHOLMOD.Dense) = copyto!(dest, Array(src))
19+
Base.copyto!(dest::SubOrDArray{T}, src::SparseArrays.CHOLMOD.Dense{T}) where {T<:Union{Float32,Float64,ComplexF32,ComplexF64}} = copyto!(dest, Array(src))
20+
Base.copyto!(dest::SubOrDArray{T,2}, src::SparseArrays.CHOLMOD.Dense{T}) where {T<:Union{Float32,Float64,ComplexF32,ComplexF64}} = copyto!(dest, Array(src))
21+
end
22+
23+
# Fix method ambiguities
24+
for T in (:DArray, :SubDArray)
25+
@eval begin
26+
Base.:(==)(d1::$T{<:Any,1}, d2::SparseArrays.ReadOnly) = d1 == parent(d2)
27+
Base.:(==)(d1::SparseArrays.ReadOnly, d2::$T{<:Any,1}) = parent(d1) == d2
28+
end
29+
end
30+
1431
end

src/DistributedArrays.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ using Serialization: Serialization, AbstractSerializer, deserialize, serialize
1010

1111
using Primes: factor
1212

13-
import SparseArrays
14-
1513
# DArray exports
1614
export DArray, SubDArray, SubOrDArray, @DArray
1715
export dzeros, dones, dfill, drand, drandn, distribute, localpart, localindices, ppeval

src/darray.jl

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ end
369369

370370
# shortcut to set/get localparts of a distributed object
371371
Base.getindex(d::DArray, s::Symbol) = _getindex(d, s)
372-
Base.getindex(d::DistributedArrays.DArray{<:Any, 1}, s::Symbol) = _getindex(d, s)
372+
Base.getindex(d::DArray{<:Any, 1}, s::Symbol) = _getindex(d, s)
373373
function _getindex(d::DArray, s::Symbol)
374374
@assert s in [:L, :l, :LP, :lp]
375375
return localpart(d)
@@ -440,14 +440,6 @@ function Base.:(==)(d1::SubDArray, d2::SubDArray)
440440
return t
441441
end
442442

443-
# Fix method ambiguities
444-
for T in (:DArray, :SubDArray)
445-
@eval begin
446-
Base.:(==)(d1::$T{<:Any,1}, d2::SparseArrays.ReadOnly) = d1 == parent(d2)
447-
Base.:(==)(d1::SparseArrays.ReadOnly, d2::$T{<:Any,1}) = parent(d1) == d2
448-
end
449-
end
450-
451443
"""
452444
locate(d::DArray, I::Int...)
453445
@@ -664,9 +656,6 @@ function Base.getindex(d::DArray{<:Any,N}, i::Vararg{Int,N}) where {N}
664656
_scalarindexingallowed()
665657
return getindex_tuple(d, i)
666658
end
667-
function Base.getindex(d::DArray{<:Any,N}, I::Vararg{Any,N}) where {N}
668-
return view(d, I...)
669-
end
670659
Base.getindex(d::DArray) = d[1]
671660
Base.getindex(d::SubDArray, I::Int...) = invoke(getindex, Tuple{SubArray{<:Any,N},Vararg{Int,N}} where N, d, I...)
672661
Base.getindex(d::SubOrDArray, I::Union{Int,UnitRange{Int},Colon,Vector{Int},StepRange{Int,Int}}...) = view(d, I...)
@@ -697,15 +686,6 @@ function Base.copyto!(dest::SubOrDArray, src::AbstractArray)
697686
return dest
698687
end
699688

700-
# Fix method ambiguities
701-
# TODO: Improve efficiency?
702-
Base.copyto!(dest::SubOrDArray{<:Any,2}, src::SparseArrays.AbstractSparseMatrixCSC) = copyto!(dest, Matrix(src))
703-
@static if isdefined(SparseArrays, :CHOLMOD)
704-
Base.copyto!(dest::SubOrDArray, src::SparseArrays.CHOLMOD.Dense) = copyto!(dest, Array(src))
705-
Base.copyto!(dest::SubOrDArray{T}, src::SparseArrays.CHOLMOD.Dense{T}) where {T<:Union{Float32,Float64,ComplexF32,ComplexF64}} = copyto!(dest, Array(src))
706-
Base.copyto!(dest::SubOrDArray{T,2}, src::SparseArrays.CHOLMOD.Dense{T}) where {T<:Union{Float32,Float64,ComplexF32,ComplexF64}} = copyto!(dest, Array(src))
707-
end
708-
709689
function Base.deepcopy(src::DArray)
710690
dest = similar(src)
711691
@sync for p in procs(src)

src/spmd.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct WorkerChannelDict
4343
end
4444
const WORKERCHANNELS = WorkerChannelDict()
4545

46-
Base.get!(f, x::WorkerChannelDict, id::Int) = @lock x.lock get!(f, x.data, id)
46+
Base.get!(f::Function, x::WorkerChannelDict, id::Int) = @lock x.lock get!(f, x.data, id)
4747

4848
# mapping between a context id and context object
4949
struct SPMDContextDict
@@ -54,7 +54,7 @@ end
5454
const CONTEXTS = SPMDContextDict()
5555

5656
Base.delete!(x::SPMDContextDict, id::Tuple{Int,Int}) = @lock x.lock delete!(x.data, id)
57-
Base.get!(f, x::SPMDContextDict, id::Tuple{Int,Int}) = @lock x.lock get!(f, x.data, id)
57+
Base.get!(f::Function, x::SPMDContextDict, id::Tuple{Int,Int}) = @lock x.lock get!(f, x.data, id)
5858

5959
function context_local_storage()
6060
ctxt = get_ctxt_from_id(task_local_storage(:SPMD_CTXT))

test/aqua.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ using DistributedArrays, Test
22
import Aqua
33

44
@testset "Aqua" begin
5-
Aqua.test_all(DistributedArrays)
5+
Aqua.test_all(DistributedArrays; ambiguities = (; broken = true))
66
end

0 commit comments

Comments
 (0)