# Help with data movement and commuication

**URL:** <https://discourse.julialang.org/t/help-with-data-movement-and-commuication/14672>\
**Category:** Julia at Scale\
**Created:** [September 7, 2018, 5:09pm UTC](https://discourse.julialang.org/t/help-with-data-movement-and-commuication/14672 "2018-09-07T17:09:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbrunaud](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bbrunaud/32/1737_2.png) [@bbrunaud](https://discourse.julialang.org/u/bbrunaud)\
**Post date:** [September 7, 2018, 5:09pm UTC](https://discourse.julialang.org/t/help-with-data-movement-and-commuication/14672/1 "2018-09-07T17:09:21Z")

</div>

Hello,

I’ve been struggling for a long time with an apparently simple problem. Given a graph data structure with nodes inside I want to apply a function to each node that shares information across nodes and modifies the node in place.

Here is an example of what I want to achieve

Begin GraphModule.jl

```julia
module GraphModule

export MyGraph, MyNode, nodefunction

mutable struct MyGraph
    nodes
end

mutable struct MyNode
    label
    inbox
    child
    value
end

function nodefunction(n::MyNode)
    val = n.inbox + 1
    push!(n.value, val)
    n.child.inbox = val
    println("I am node $(n.label), from $(myid()), my values are $(n.value)")
end

end

```

Begin simpletest.jl

```julia
push!(LOAD_PATH,".")
addprocs(2)

using GraphModule

g = MyGraph([MyNode("parent", 0, nothing, Float64[]),
             MyNode("child", 0, nothing, Float64[])])

g.nodes[1].child = g.nodes[2]
g.nodes[2].child = g.nodes[1]

for i in 1:5
    for node in g.nodes
        nodefunction(node)
    end
end

```

Here is the list of things I want to achieve

1. Move each node to a different worker
2. Apply `nodefunction` to each node in the worker
3. `nodefunction` does three things:  
3.1. Adds 1 to the value received in the inbox  
3.2. Puts that value in its child inbox  
3.3. Stores the value inside the node in the `value` property

I also want that the operation is performed in the same worker for a given node, because the data inside the node can be extensive and I want to minimize data movement.

Could someone be so kind to help me with this?

Thank you

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [September 8, 2018, 5:37am UTC](https://discourse.julialang.org/t/help-with-data-movement-and-commuication/14672/2 "2018-09-08T05:37:09Z")

</div>

I guess your question involves an efficient algorithm, which I’m not qualified to answer. The practical side of the question can probably be solved with ParallelDataTransfer.jl
