Skip to content

Commit

Permalink
Merge pull request #58 from fredrikekre/fe/map_parts
Browse files Browse the repository at this point in the history
Add docstring to map_parts.
  • Loading branch information
fverdugo authored Jan 31, 2022
2 parents b3eaa2a + 00ce98a commit d5224f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/Interfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ Base.iterate(a::AbstractPData,state) = @abstractmethod

get_part_ids(a::AbstractPData) = get_part_ids(get_backend(a),size(a))

"""
map_parts(f, xs::AbstractPData...) -> AbstractPData
Call function `f` on the data `xs` owned by the current process.
Internally this unwraps the arguments `xs`, calls `f` with the underlying data,
and rewraps the result as `AbstractPData` of the same type.
# Example
In this example (using the `MPIBackend`):
- `A`, `B`, `X`, and `Y` are `::MPIData`,
- `a`, `b`, `x`, and `y` are `::Vector` (the underlying data of the `MPIData`)
```julia
X, Y = map_parts(A, B) do a, b
x = a + 2 * b
y = a - 5 * b
return x, y
end
```
"""
map_parts(task,a::AbstractPData...) = @abstractmethod

i_am_main(::AbstractPData) = @abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions src/MPIBackend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ end

function Base.iterate(a::MPIData)
next = iterate(a.part)
if next == nothing
if next === nothing
return next
end
item, state = next
Expand All @@ -83,7 +83,7 @@ end

function Base.iterate(a::MPIData,state)
next = iterate(a.part,state)
if next == nothing
if next === nothing
return next
end
item, state = next
Expand Down

0 comments on commit d5224f7

Please sign in to comment.