Graph ¡Processing ¡& ¡ ¡ Bulk ¡Synchronous ¡Parallel ¡Model ¡
CompSci ¡590.03 ¡ Instructor: ¡Ashwin ¡Machanavajjhala ¡
1 ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡
Graph Processing & Bulk Synchronous Parallel Model - - PowerPoint PPT Presentation
Graph Processing & Bulk Synchronous Parallel Model CompSci 590.03 Instructor: Ashwin Machanavajjhala Lecture 14 : 590.02 Spring 13 1 Recap: Graph
1 ¡ Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 2 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 3 ¡
Lecture ¡13 ¡: ¡590.02 ¡Spring ¡13 ¡ 4 ¡
Lecture ¡13 ¡: ¡590.02 ¡Spring ¡13 ¡ 5 ¡
Lecture ¡13 ¡: ¡590.02 ¡Spring ¡13 ¡ 6 ¡
IniFal ¡ RelaFon ¡ Invariant ¡ RelaFon ¡
n3 n1 n2 n1 n2 n3 M20: R0-split0 M00: L-split0 M10: L-split1 R00: partition 0 R10: partition 1 R20: partition 2 n3 n1 n2 n1 n2 n3 M21: R1-split0 M01: L-split0 M11: L-split1 R01: partition 0 R11: partition 1 R21: partition 2 Unnecessary computation Unnecessary communication Lecture ¡13 ¡: ¡590.02 ¡Spring ¡13 ¡ 7 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 8 ¡
Map 1 Reduce 1
K V
Graph Partition (1)
Map 2 Reduce 2
K V
Graph Partition (2)
Map n Reduce n
K V
Graph Partition (n)
Shuffle
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 9 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 10 ¡
Seven ¡Bridges ¡of ¡ Konigsberg ¡ River ¡Pregel ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 11 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 12 ¡
Active Inactive Vote to halt Message received
3 6 2 1 Superstep 0 6 6 2 6 Superstep 1 6 6 6 6 Superstep 2 6 6 6 6 Superstep 3 Figure 2: Maximum Value Example. Dotted lines are messages. Shaded vertices have voted to halt.
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 13 ¡
template <typename VertexValue, typename EdgeValue, typename MessageValue> class Vertex { public: virtual void Compute(MessageIterator* msgs) = 0; const string& vertex_id() const; int64 superstep() const; const VertexValue& GetValue(); VertexValue* MutableValue(); OutEdgeIterator GetOutEdgeIterator(); void SendMessageTo(const string& dest_vertex, const MessageValue& message); void VoteToHalt(); };
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 14 ¡
User ¡overrides ¡this ¡ compute ¡funcFon ¡ ¡ Vertex ¡value ¡can ¡be ¡ modified ¡ Messages ¡can ¡be ¡sent ¡ to ¡any ¡dest_vertex ¡ (whose ¡id ¡is ¡known) ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 15 ¡
class PageRankVertex : public Vertex<double, void, double> { public: virtual void Compute(MessageIterator* msgs) { if (superstep() >= 1) { double sum = 0; for (; !msgs->Done(); msgs->Next()) sum += msgs->Value(); *MutableValue() = 0.15 / NumVertices() + 0.85 * sum; } if (superstep() < 30) { const int64 n = GetOutEdgeIterator().size(); SendMessageToAllNeighbors(GetValue() / n); } else { VoteToHalt(); } } };
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 16 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 17 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 18 ¡
class ShortestPathVertex : public Vertex<int, int, int> { void Compute(MessageIterator* msgs) { int mindist = IsSource(vertex_id()) ? 0 : INF; for (; !msgs->Done(); msgs->Next()) mindist = min(mindist, msgs->Value()); if (mindist < GetValue()) { *MutableValue() = mindist; OutEdgeIterator iter = GetOutEdgeIterator(); for (; !iter.Done(); iter.Next()) SendMessageTo(iter.Target(), mindist + iter.GetValue()); } VoteToHalt(); } };
class MinIntCombiner : public Combiner<int> { virtual void Combine(MessageIterator* msgs) { int mindist = INF; for (; !msgs->Done(); msgs->Next()) mindist = min(mindist, msgs->Value()); Output("combined_source", mindist); } };
Edge ¡Weight ¡ Distance ¡to ¡source ¡ All ¡VerFces ¡iniFalized ¡to ¡INF ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 19 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 20 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 21 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 22 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 23 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 24 ¡
Lecture ¡14 ¡: ¡590.02 ¡Spring ¡13 ¡ 25 ¡