Skip to content

Commit

Permalink
Rename emit -> mutlicast
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Jan 10, 2024
1 parent 5f9bc5a commit 4cc4619
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
6 changes: 3 additions & 3 deletions docs/src/reference/primitives.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ allocate_scatter
## Emit

```@docs
emit
emit!
allocate_emit
multicast
multicast!
allocate_multicast
```

## Scan
Expand Down
6 changes: 3 additions & 3 deletions src/PartitionedArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export allocate_gather
export scatter
export scatter!
export allocate_scatter
export emit
export emit!
export allocate_emit
export multicast
export multicast!
export allocate_multicast
export scan
export scan!
export reduction
Expand Down
8 changes: 4 additions & 4 deletions src/debug_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ function scatter_impl!(
scatter_impl!(rcv.items,snd.items,source,T)
end

function emit_impl!(
function multicast_impl!(
rcv::DebugArray,snd::DebugArray,
source,::Type{T}) where T
emit_impl!(rcv.items,snd.items,source,T)
multicast_impl!(rcv.items,snd.items,source,T)
end

function emit_impl!(
function multicast_impl!(
rcv::DebugArray,snd::DebugArray,
source,::Type{T}) where T<:AbstractVector
emit_impl!(rcv.items,snd.items,source,T)
multicast_impl!(rcv.items,snd.items,source,T)
end

Base.reduce(op,a::DebugArray;kwargs...) = reduce(op,a.items;kwargs...)
Expand Down
10 changes: 5 additions & 5 deletions src/mpi_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function scatter_impl!(
rcv
end

function emit_impl!(
function multicast_impl!(
rcv::MPIArray,snd::MPIArray,
source,::Type{T}) where T
@assert rcv.comm === snd.comm
Expand All @@ -377,7 +377,7 @@ function emit_impl!(
MPI.Bcast!(rcv.item_ref,root,comm)
end

function emit_impl!(
function multicast_impl!(
rcv::MPIArray,snd::MPIArray,
source,::Type{T}) where T<:AbstractVector
@assert rcv.comm === snd.comm
Expand Down Expand Up @@ -585,7 +585,7 @@ function find_rcv_ids_ibarrier(snd_ids::MPIArray{<:AbstractVector{T}}) where T
end
rcv_ids=T[]
done=false
barrier_emitted=false
barrier_multicastted=false
all_sends_done=false
barrier_req=nothing
status = Ref(MPI.STATUS_ZERO)
Expand All @@ -602,13 +602,13 @@ function find_rcv_ids_ibarrier(snd_ids::MPIArray{<:AbstractVector{T}}) where T
@boundscheck @assert tag_rcv == tag "Inconsistent tag in ExchangeGraph_impl()!"
end

if (barrier_emitted)
if (barrier_multicastted)
done=MPI.Test(barrier_req)
else
all_sends_done = MPI.Testall(requests)
if (all_sends_done)
barrier_req=MPI.Ibarrier(comm)
barrier_emitted=true
barrier_multicastted=true
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/p_range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ The argument `global_to_color` is the usual output of such tools.
"""
function partition_from_color(ranks,global_to_color;multicast=false,source=MAIN)
if multicast == true
global_to_owner = getany(emit(global_to_color;source))
global_to_owner = getany(multicast(global_to_color;source))
else
global_to_owner = global_to_color
end
Expand Down
40 changes: 20 additions & 20 deletions src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ function scatter_impl!(rcv,snd,source,::Type{T}) where T
end

"""
emit(snd;source=MAIN)
multicast(snd;source=MAIN)
Copy `snd[source]` into a new array of the same size and type as `snd`.
Expand All @@ -355,64 +355,64 @@ julia> a = [0,0,2,0]
2
0
julia> emit(a,source=3)
julia> multicast(a,source=3)
4-element Vector{Int64}:
2
2
2
2
```
"""
function emit(snd;source=MAIN)
function multicast(snd;source=MAIN)
T = eltype(snd)
emit_impl(snd,source,T)
multicast_impl(snd,source,T)
end

function emit_impl(snd,source,::Type{T}) where T
function multicast_impl(snd,source,::Type{T}) where T
@assert source !== :all "All to all not implemented"
rcv = allocate_emit(snd;source)
emit!(rcv,snd;source)
rcv = allocate_multicast(snd;source)
multicast!(rcv,snd;source)
rcv
end

"""
allocate_emit(snd;source=1)
allocate_multicast(snd;source=1)
Allocate an array to be used in the first argument of [`emit!`](@ref).
Allocate an array to be used in the first argument of [`multicast!`](@ref).
"""
function allocate_emit(snd;source=1)
function allocate_multicast(snd;source=1)
T = eltype(snd)
allocate_emit_impl(snd,source,T)
allocate_multicast_impl(snd,source,T)
end

function allocate_emit_impl(snd,source,::Type{T}) where T
function allocate_multicast_impl(snd,source,::Type{T}) where T
@assert source !== :all "Scatter all not implemented"
similar(snd)
end

function allocate_emit_impl(snd,source,::Type{T}) where T<:AbstractVector
function allocate_multicast_impl(snd,source,::Type{T}) where T<:AbstractVector
@assert source !== :all "Scatter all not implemented"
n = map(length,snd)
n_all = emit(n;source)
n_all = multicast(n;source)
S = eltype(T)
map(n_all) do n
Vector{S}(undef,n)
end
end

"""
emit!(rcv,snd;source=1)
multicast!(rcv,snd;source=1)
In-place version of [`emit`](@ref). The destination array `rcv`
can be generated with the helper function [`allocate_emit`](@ref).
In-place version of [`multicast`](@ref). The destination array `rcv`
can be generated with the helper function [`allocate_multicast`](@ref).
It returns `rcv`.
"""
function emit!(rcv,snd;source=1)
function multicast!(rcv,snd;source=1)
T = eltype(snd)
emit_impl!(rcv,snd,source,T)
multicast_impl!(rcv,snd,source,T)
end

function emit_impl!(rcv,snd,source,::Type{T}) where T
function multicast_impl!(rcv,snd,source,::Type{T}) where T
@assert source !== :all "Emit all not implemented"
for i in eachindex(rcv)
rcv[i] = snd[source]
Expand Down
2 changes: 1 addition & 1 deletion test/mpi_array/drivers/exception_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function exception_tests(distribute)
0
end
end
p = emit(p_main)
p = multicast(p_main)
map(parts,p) do part,part_fail
@assert part_fail != part
end
Expand Down
4 changes: 2 additions & 2 deletions test/primitives_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ function primitives_tests(distribute)
@test rcv == [[1],[1,2],[1,2,3],[1,2,3,4]]
end

rcv = emit(rank,source=2)
rcv = multicast(rank,source=2)
map(rcv) do rcv
@test rcv == 2
end

rcv = emit(snd,source=2)
rcv = multicast(snd,source=2)
map(rcv) do rcv
@test rcv == [1,2]
end
Expand Down

0 comments on commit 4cc4619

Please sign in to comment.