Skip to content

Instantly share code, notes, and snippets.

@bholt
Last active August 29, 2015 14:03
Show Gist options
  • Save bholt/0d8d9f5602b9eba623e2 to your computer and use it in GitHub Desktop.
Save bholt/0d8d9f5602b9eba623e2 to your computer and use it in GitHub Desktop.
Lata code snippet
GlobalAddress<Graph> g;
///////////////////////////////////////////////
// GraphLab synchronous engine: scatter phase
// loop over all vertices in graph
forall(g, [=](Vertex& v){
// only scatter from vertices that have been signaled to do scatter
if (v->active_minor_step) {
v->active_minor_step = false;
// copy the VertexProgram state to allow it to be captured and used in the delegate
auto prog_copy = prog(v);
// loop over the adjacency list for 'v'
forall<async>(adj(g,v), [=](Edge& e){
auto e_id = e.id;
auto e_data = e.data;
// atomically visit remote vertex
// executes atomically
delegate<async>(e.ga, [=](Vertex& ve){
auto local_e_data = e_data;
Edge e = { e_id, g->vs+e_id, local_e_data };
auto gather_delta = prog_copy.scatter(e, ve);
prog(ve).post_delta(gather_delta);
});
// synchronizes with the outermost loop
});
}
});
// all scatters completed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment