清华云计算课件-分布式计算.ppt
《清华云计算课件-分布式计算.ppt》由会员分享,可在线阅读,更多相关《清华云计算课件-分布式计算.ppt(69页珍藏版)》请在三一办公上搜索。
1、Lecture 1 Introduction to Distributed Computing,Mass Data Processing Technology on Large Scale ClustersSummer,2007,Tsinghua University,All course material(slides,labs,etc)is licensed under the Creative Commons Attribution 2.5 License.Many thanks to Aaron Kimball&Sierra Michels-Slettvet for their ori
2、ginal version,1,Outline,2,Introduction to Distributed Systems,3,Computer Speedup,4,Moores Law:“The density of transistors on a chip doubles every 18 months,for the same cost”(1965),Image:Toms Hardware,Why slow down here?,Then,How to improve the performance?,Scope of Problems,5,Distributed Problems,R
3、endering multiple frames of high-quality animation,6,Image:DreamWorks Animation,Distributed Problems,Simulating several hundred or thousand characters,7,Happy Feet Kingdom Feature Productions;Lord of the Rings New Line Cinema,Distributed Problems,Indexing the web(Google)Simulating an Internet-sized
4、network for networking experiments(PlanetLab)Speeding up content delivery(Akamai),8,What is the key attribute that all these examples have in common?,PlanetLab,9,PlanetLab is a global research network that supports the development of new network services.,PlanetLab currently consists of 809 nodes at
5、 401 sites.,CDN-Akamai,10,Parallel vs.Distributed,Parallel computing can mean:Vector processing of data(SIMD)Multiple CPUs in a single computer(MIMD)Distributed computing is multiple CPUs across many computers(MIMD),11,A Brief History 1975-85,Parallel computing was favored in the early yearsPrimaril
6、y vector-based at firstGradually more thread-based parallelism was introduced,12,Cray 2 supercomputer(Wikipedia),A Brief History 1985-95,“Massively parallel architectures”start rising in prominenceMessage Passing Interface(MPI)and other libraries developedBandwidth was a big problem,13,A Brief Histo
7、ry 1995-Today,Cluster/grid architecture increasingly dominantSpecial node machines eschewed in favor of COTS technologiesWeb-wide cluster softwareCompanies like Google take this to the extreme(10,000 node clusters),14,Top 500,Architecture,15,Parallelization&Synchronization,16,Parallelization Idea,Pa
8、rallelization is“easy”if processing can be cleanly split into n units:,17,Parallelization Idea(2),18,In a parallel computation,we would like to have as many threads as we have processors.e.g.,a four-processor computer would be able to run four threads at the same time.,Parallelization Idea(3),19,Par
9、allelization Idea(4),20,Parallelization Pitfalls,But this model is too simple!How do we assign work units to worker threads?What if we have more work units than threads?How do we aggregate the results at the end?How do we know all the workers have finished?What if the work cannot be divided into com
10、pletely separate tasks?,21,What is the common theme of all of these problems?,Parallelization Pitfalls(2),Each of these problems represents a point at which multiple threads must communicate with one another,or access a shared resource.Golden rule:Any memory that can be used by multiple threads must
11、 have an associated synchronization system!,22,Whats Wrong With This?,23,Thread 1:void foo()x+;y=x;,Thread 2:void bar()y+;x+;,If the initial state is y=0,x=6,what happens after these threads finish running?,Multithreaded=Unpredictability,24,When we run a multithreaded program,we dont know what order
12、 threads run in,nor do we know when they will interrupt one another.,Thread 1:void foo()eax=memx;inc eax;memx=eax;ebx=memx;memy=ebx;,Thread 2:void bar()eax=memy;inc eax;memy=eax;eax=memx;inc eax;memx=eax;,Many things that look like“one step”operations actually take several steps under the hood:,Mult
13、ithreaded=Unpredictability,This applies to more than just integers:Pulling work units from a queueReporting work back to master unitTelling another thread that it can begin the“next phase”of processing All require synchronization!,25,Synchronization Primitives,A synchronization primitive is a specia
14、l shared variable that guarantees that it can only be accessed atomically.Hardware support guarantees that operations on synchronization primitives only ever take one step,26,Semaphores,A semaphore is a flag that can be raised or lowered in one stepSemaphores were flags that railroad engineers would
15、 use when entering a shared track,27,Only one side of the semaphore can ever be red!(Can both be green?),Semaphores,set()and reset()can be thought of as lock()and unlock()Calls to lock()when the semaphore is already locked cause the thread to block.Pitfalls:Must“bind”semaphores to particular objects
16、;must remember to unlock correctly,28,The“corrected”example,29,Thread 1:void foo()sem.lock();x+;y=x;sem.unlock();,Thread 2:void bar()sem.lock();y+;x+;sem.unlock();,Global var“Semaphore sem=new Semaphore();”guards access to x&y,Condition Variables,A condition variable notifies threads that a particul
17、ar condition has been met Inform another thread that a queue now contains elements to pull from(or that its empty request more elements!)Pitfall:What if nobodys listening?,30,The Final Example,31,Thread 1:void foo()sem.lock();x+;y=x;fooDone=true;sem.unlock();fooFinishedCV.notify();,Thread 2:void bar
18、()sem.lock();if(!fooDone)fooFinishedCV.wait(sem);y+;x+;sem.unlock();,Global vars:Semaphore sem=new Semaphore();ConditionVar fooFinishedCV=new ConditionVar();boolean fooDone=false;,Barriers,A barrier knows in advance how many threads it should wait for.Threads“register”with the barrier when they reac
19、h it,and fall asleep.Barrier wakes up all registered threads when total count is correctPitfall:What happens if a thread takes a long time?,32,Too Much Synchronization?Deadlock,33,Synchronization becomes even more complicated when multiple locks can be usedCan cause entire system to“get stuck”,Threa
20、d A:semaphore1.lock();semaphore2.lock();/*use data guarded by semaphores*/semaphore1.unlock();semaphore2.unlock();,Thread B:semaphore2.lock();semaphore1.lock();/*use data guarded by semaphores*/semaphore1.unlock();semaphore2.unlock();,(Image:RPI CSCI.4210 Operating Systems notes),The Moral:Be Carefu
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 清华 计算 课件 分布式
链接地址:https://www.31ppt.com/p-6425367.html