Skip to content

Commit

Permalink
Merge pull request #13514 from polarke/fix-sharedarray-constructors
Browse files Browse the repository at this point in the history
Make the constructors of Array and SharedArray consistent
  • Loading branch information
jakebolewski committed Oct 14, 2015
2 parents ecf6005 + 8e98763 commit d35e69c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions base/sharedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ type SharedArray{T,N} <: DenseArray{T,N}
SharedArray(d,p,r,sn) = new(d,p,r,sn)
end

call{T,N}(::Type{SharedArray{T}}, d::NTuple{N,Int}; kwargs...) =
SharedArray(T, d; kwargs...)
call{T}(::Type{SharedArray{T}}, d::Integer...; kwargs...) =
SharedArray(T, d; kwargs...)
call{T}(::Type{SharedArray{T}}, m::Integer; kwargs...) =
SharedArray(T, m; kwargs...)
call{T}(::Type{SharedArray{T}}, m::Integer, n::Integer; kwargs...) =
SharedArray(T, m, n; kwargs...)
call{T}(::Type{SharedArray{T}}, m::Integer, n::Integer, o::Integer; kwargs...) =
SharedArray(T, m, n, o; kwargs...)

function SharedArray(T::Type, dims::NTuple; init=false, pids=Int[])
N = length(dims)

Expand Down
14 changes: 14 additions & 0 deletions test/parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ end

### Utility functions

# construct PR #13514
S = SharedArray{Int}((1,2,3))
@test size(S) == (1,2,3)
@test typeof(S) <: SharedArray{Int}
S = SharedArray{Int}(2)
@test size(S) == (2,)
@test typeof(S) <: SharedArray{Int}
S = SharedArray{Int}(1,2)
@test size(S) == (1,2)
@test typeof(S) <: SharedArray{Int}
S = SharedArray{Int}(1,2,3)
@test size(S) == (1,2,3)
@test typeof(S) <: SharedArray{Int}

# reshape

d = Base.shmem_fill(1.0, (10,10,10))
Expand Down

0 comments on commit d35e69c

Please sign in to comment.