Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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...) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an FYI: this and the next two are just for getting rid of the splatting penalty. For a SharedArray, there's sufficient overhead for creation that this is probably negligible, so these probably aren't really necessary. However, neither do they hurt anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original intention was to make ShareArray have the same interface as Array, since I am writing a library using both with type parameters. My fix is kind of naive. And Kevin Squire said in the user group that there could be deeper and cleaner than falling back to SharedArray(T, x), maybe someone could improve later.

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