分布式算法课件5.ppt
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《分布式算法课件5.ppt》由会员分享,可在线阅读,更多相关《分布式算法课件5.ppt(70页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、分布式算法课件5Leader election in general asynchronous networksUndirected graphs.Can get asynchronous version of synchronous FloodMax algorithm:Simulate rounds with counters.Need to know diameter for termination.FloodMax algorithm:Every round:Send max UID seen to all neighbors.Stop after diam rounds.Elect
2、self iff own UID is max seen.2AsynchSpanning tree,Process i6Asynchronous spanning tree7Asynchronous spanning treeS8Asynchronous spanning treeS9Asynchronous spanning treeS10Asynchronous spanning treeSS11Asynchronous spanning treeS12Asynchronous spanning treeSSS13Asynchronous spanning tree14AsynchSpan
3、ning treeComplexityMessages:O(|E|)Time:diam(l+d)+lAnomaly:Paths may be longer than diameter!Messages may travel faster along longer paths,in asynchronous networks.15Application of AsynchSpanning treeSimilar to synchronous BFSMessage broadcast:Piggyback on search message.Child pointers:Add responses
4、to search messages,easy because of bidirectional communication.Use precomputed tree for bcast/convergecastNow the timing anomaly arisesO(h(l+d)time complexity.O(|E|)message complexity.h=height of tree;may be n16Applications of BFSGlobal computation:Sum,max,or any kind of data aggregation:Convergecas
5、t on BFS tree.Complexity:Time O(diameter);Messages O(n)Leader election(without knowing diameter):Everyone starts BFS,determines max UID.Complexity:Time O(diam);Messages O(n|E|)(actually,O(diam|E|).Compute diameter:All do BFS.Convergecast to find height of each BFS tree.Convergecast again to find max
6、 of all heights.17More applicationsAsynchronous broadcast/convergecast:Can also construct spanning tree while using it to broadcast message and also to collect responses.E.g.,to tell the root when the bcast is done,or to collect aggregated data.Complexity:O(|E|)message complexity.O(n(l+d)time comple
7、xity,timing anomaly.Elect leader when nodes have no info about the network(no knowledge of n,diam,etc.;no root,no spanning tree)18Breadth-first spanning treeAssume(same as above):Undirected,connected graph(i.e.,bidirectional communication).Root i0.Size and diameter unknown.UIDs,with comparisons.Requ
8、ire:Each process should output its parent in a breadth-first spanning tree.19Breadth-first spanning treeIn asynchronous networks,modified SynchBFSdoes not guarantee that the spanning tree constructed is breadth-first.Long paths may be traversed faster than short ones.Can modify each process to keep
9、track of distance,change parent when it hears of shorter path.Relaxation algorithm(like Bellman-Ford).Must inform neighbors of changes.Eventually,tree stabilizes to a breadth-first spanning tree.20AsynchBFS21AsynchBFS022AsynchBFS0023AsynchBFS00024AsynchBFS10025AsynchBFS101126AsynchBFS101321127Asynch
10、BFS1041321128AsynchBFS104132114429AsynchBFS10213214430AsynchBFS102513214231AsynchBFS610231321132AsynchBFS610221321133AsynchBFS210221321034AsynchBFS11022132135AsynchBFSComplexity:Messages:O(n|E|)May send O(n)messages on each link(one for each distance estimate).Time:O(diam n(l+d)(taking pileups into
11、account).Can reduce complexity if know bound D on diameter:Allow only distance estimates D.Messages:O(D|E|);Time:O(diamD(l+d)36AsynchBFSTermination:No one knows when this is done,so cant produce parent outputs.Can augment with acks for search messages,convergecast back to i0.i0 learns when the tree
12、has stabilized,tells everyone else.A bit tricky:Tree grows and shrinks.Some processes may participate many times,as they learn improvements.Bookkeeping needed.Complexity?37Layered BFSAsynchrony leads to many corrections,which lead to lots of communication.Idea:Slow down communication,grow the tree i
13、n synchronized phases.In phase k,incorporate all nodes at distance k from i0.i0 synchronizes between incorporating nodes at distance k and k+1.Phase 1:i0 sends search messages to neighbors.Neighbors set dist:=1,send acks to i0.38Layered BFSPhase k+1:Assume phases 1,k are completed:each node at dista
14、nce k knows its parent,and each node at distance k-1 also knows its children.i0 broadcasts newphase message along tree edges,to distance k processes.Each of these sends search message to all nbrs except its parent.When any non-i0 process receives first search message,sets parent:=sender and sends a
15、positive ack;sends nacks for subsequent search msgs.When distance k process receives acks/nacks for all its search messages,designates nodes that sent postive acks as its children.Then distance k processes convergecast back to i0 along depth k tree to say that theyre done;include a bit saying whethe
16、r new nodes were found.39Layered BFSTerminates:When i0 learns,in some phase,that no new nodes were found.Obviously produces BFS tree.Complexity:Messages:O(|E|+n diam)Time:Use simplified analysis:Neglecting local computation time l Assuming that every message in a channel is delivered in time d(ignor
17、ing congestion delays).O(diam2 d)Each edge explored at most once in each direction by search/ack.Each tree edge traversed at most once in each phase by newphase/convergecast.40Layered BFS vs AsynchBFSMessage complexity:AsynchBFS:O(diam|E|),assuming diam is known,O(n|E|)if notLayeredBFS:O(|E|+n diam)
18、Time complexity:AsynchBFS:O(diamd)LayeredBFS:O(diam2d)Can also define“hybrid”algorithm Add m layers in each phase.Within each phase,layers constructed asynchronously.Intermediate performance.41Shortest PathsAssumptions:Same as for BFS,plus edge weights.weight(i,j),nonnegative real,same in both direc
19、tions.Require:Output shortest distance and parent in shortest-paths tree.Use Bellman-Ford asynchronouslyUsed to establish routes in ARPANET 1969-1980.Can augment with convergecast as for BFS,for termination.But worst-case complexity is very bad42AsynchBellmanFord43AsynchBellmanFordTermination:Use co
20、nvergecast(as for AsynchBFS).Complexity:O(n!)simple paths from i0 to any other node,which is O(nn).So the number of messages sent on any channel is O(nn).So message complexity=O(nn|E|),time complexity=O(nnn(l+d).44AsynchBellmanFordComplexity:Q:Are the message and time complexity really exponential i
21、n n?A:Yes:In some execution of network below,iksends 2kmessages to ik+1,so message complexity is(2n/2)and time complexity is(2n/2d).45Exponential time/message complexityPossible distance estimates for ik are 2k1,2k2,0.Moreover,ik can take on all these estimates in sequence:First,messages traverse up
22、per links,2k1.Then last lower message arrives at ik,2k2.Then lower message ik-2 ik-1 arrives,reduces ik-1s estimate by 2,message ik-1 ik arrives on upper links,2k3.Etc.Count down in binary.If this happens quickly,get pileup of 2k search messages in Ck,k+1.46Shortest PathsMoral:Unrestrained asynchron
23、y can cause problems.Return to this problem after we have better synchronization methods.Now,another good illustration of the problems introduced by asynchrony:47Minimum spanning treeAssumptions:G=(V,E)connected,undirected.Weighted edges,weights known to endpoint processes,weights distinct.UIDsProce
24、sses dont know n,diam.Can identify in-and out-edges to same neighbor.Input:wakeup actions,occurring at any time at one or more nodes.Process wakes up when it first receives either a wakeupinput or a protocol message.48Minimum spanning treeAssumptions:Requires:Produce MST,where each process knows whi
25、ch of its incident edges belong to the tree.Guaranteed to be unique,because of unique weights.Gallager-Humblet-Spira algorithm 49Recall synchronous algorithmProceeds in phases(levels).After each phase,we have a spanning forest,in which each component tree has a leader.In each phase,each component fi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 分布式 算法 课件
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内