ImageVerifierCode 换一换
格式:PPT , 页数:65 ,大小:584KB ,
资源ID:389478      下载积分:2000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
注意:如需开发票,请勿充值!
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-389478.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Supercomputingin Plain English Distributed Multiprocessing.ppt)为本站会员(花仙子)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

Supercomputingin Plain English Distributed Multiprocessing.ppt

1、Supercomputing in Plain English Distributed Multiprocessing,Henry Neeman Director OU Supercomputing Center for Education & Research November 19 2004,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,2,Outline,The Desert Islands Analogy Distribute

2、d Parallelism MPI,The Desert Islands Analogy,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,4,An Island Hut,Imagine youre on a desert island in a little hut. Inside the hut is a desk and a chair. On the desk is:a phone; a pencil; a calculator;

3、 a piece of paper with instructions; a piece of paper with numbers.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,5,Instructions,The instructions are split into two kinds: Arithmetic/Logical: e.g., Add the 27th number to the 239th number Comp

4、are the 96th number to the 118th number to see whether they are equal Communication: e.g.,dial 555-0127 and leave a voicemail containing the 962nd number call your voicemail box and collect a voicemail from 555-0063 and put that number in the 715th slot,Supercomputing in Plain English: Distributed P

5、arallel OU Supercomputing Center for Education & Research,6,Is There Anybody Out There?,If youre in a hut on an island, you arent specifically aware of anyone else. Especially, you dont know whether anyone else is working on the same problem as you are, and you dont know whos at the other end of the

6、 phone line. All you know is what to do with the voicemails you get, and what phone numbers to send voicemails to.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,7,Someone Might Be Out There,Now suppose that Julie is on another island somewher

7、e, in the same kind of hut, with the same kind of equipment. Suppose that she has the same list of instructions as you, but a different set of numbers (both data and phone numbers). Like you, she doesnt know whether theres anyone else working on her problem.,Supercomputing in Plain English: Distribu

8、ted Parallel OU Supercomputing Center for Education & Research,8,Even More People Out There,Now suppose that Lloyd and Jerry are also in huts on islands. Suppose that each of the four has the exact same list of instructions, but different lists of numbers. And suppose that the phone numbers that peo

9、ple call are each others. That is, your instructions have you call Julie, Lloyd and Jerry, Julies has her call Lloyd, Jerry and you, and so on. Then you might all be working together on the same problem, even though youre not aware of it.,Supercomputing in Plain English: Distributed Parallel OU Supe

10、rcomputing Center for Education & Research,9,All Data Are Private,Notice that you cant see Julies or Lloyds or Jerrys numbers, nor can they see yours or each others. Thus, everyones numbers are private: theres no way for anyone to share numbers, except by leaving them in voicemails.,Supercomputing i

11、n Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,10,Long Distance Calls: 2 Costs,When you make a long distance phone call, you typically have to pay two costs: Connection charge: the fixed cost of connecting your phone to someone elses, even if youre only conne

12、cted for a second Per-minute charge: the cost per minute of talking, once youre connected If the connection charge is large, then you want to make as few calls as possible.,Distributed Parallelism,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research

13、,12,Like Desert Islands,Distributed parallelism is very much like the Desert Islands analogy: processes are independent of each other. All data are private. Processes communicate by passing messages (like voicemails). The cost of passing a message is split into: latency (connection time) bandwidth (

14、time per byte),Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,13,Parallelism,Less fish ,More fish!,Parallelism means doing multiple things at the same time: you can get more work done in the same amount of time.,Supercomputing in Plain English

15、: Distributed Parallel OU Supercomputing Center for Education & Research,14,What Is Parallelism?,Parallelism is the use of multiple processing units either processors or parts of an individual processor to solve a problem, and in particular the use of multiple processing units operating concurrently

16、 on different parts of a problem. The different parts could be different tasks, or the same task on different pieces of the problems data.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,15,Kinds of Parallelism,Shared Memory Multithreading (our

17、 topic last time) Distributed Memory Multiprocessing (today) Hybrid Shared/Distributed,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,16,Why Parallelism Is Good,The Trees: We like parallelism because, as the number of processing units working

18、on a problem grows, we can solve the same problem in less time. The Forest: We like parallelism because, as the number of processing units working on a problem grows, we can solve bigger problems.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research

19、,17,Parallelism Jargon,Threads: execution sequences that share a single memory area (“address space”) Processes: execution sequences with their own independent, private memory areas and thus: Multithreading: parallelism via multiple threads Multiprocessing: parallelism via multiple processes As a ge

20、neral rule, Shared Memory Parallelism is concerned with threads, and Distributed Parallelism is concerned with processes.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,18,Jargon Alert,In principle: “shared memory parallelism” “multithreading”

21、 “distributed parallelism” “multiprocessing” In practice, these terms are often used interchangeably: Parallelism Concurrency (not as popular these days) Multithreading Multiprocessing Typically, you have to figure out what is meant based on the context.,Supercomputing in Plain English: Distributed

22、Parallel OU Supercomputing Center for Education & Research,19,Load Balancing,Suppose you have a distributed parallel code, but one process does 90% of the work, and all the other processes share 10% of the work. Is it a big win to run on 1000 processes?Now, suppose that each process gets exactly 1/N

23、p of the work, where Np is the number of processes. Now is it a big win to run on 1000 processes?,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,20,Load Balancing,Load balancing means giving everyone roughly the same amount of work to do.,Supe

24、rcomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,21,Load Balancing,Load balancing can be easy, if the problem splits up into chunks of roughly equal size, with one chunk per process. Or load balancing can be very hard.,Supercomputing in Plain Englis

25、h: Distributed Parallel OU Supercomputing Center for Education & Research,22,Load Balancing Is Good,When every process gets the same amount of work, the job is load balanced. We like load balancing, because it means that our speedup can potentially be linear: if we run on Np processes, it takes 1/Np

26、 as much time as on one. For some codes, figuring out how to balance the load is trivial (e.g., breaking a big unchanging array into sub-arrays). For others, load balancing is very tricky (e.g., a dynamically evolving collection of arbitrarily many blocks of arbitrary size).,Supercomputing in Plain

27、English: Distributed Parallel OU Supercomputing Center for Education & Research,23,Parallel Strategies,Client-Server: One worker (the server) decides what tasks the other workers (clients) will do; e.g., Hello World, Monte Carlo. Data Parallelism: Each worker does exactly the same tasks on its uniqu

28、e subset of the data; e.g., distributed meshes (weather etc). Task Parallelism: Each worker does different tasks on exactly the same set of data (each process holds exactly the same data as the others); e.g., N-body. Pipeline: Each worker does its tasks, then passes its set of data along to the next

29、 worker and receives the next set of data from the previous worker.,MPI: The Message-Passing Interface,Most of this discussion is from 1 and 2.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,25,What Is MPI?,The Message-Passing Interface (MPI)

30、is a standard for expressing distributed parallelism via message passing. MPI consists of a header file, a library of routines and a runtime environment. When you compile a program that has MPI calls in it, your compiler links to a local implementation of MPI, and then you get parallelism; if the MP

31、I library isnt available, then the compile will fail. MPI can be used in Fortran, C and C+.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,26,MPI Calls,MPI calls in Fortran look like this:CALL MPI_Funcname(, errcode) In C, MPI calls look like:

32、errcode = MPI_Funcname() In C+, MPI calls look like:errcode = MPI:Funcname() Notice that errcode is returned by the MPI routine MPI_Funcname, with a value of MPI_SUCCESS indicating that MPI_Funcname has worked correctly.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center

33、for Education & Research,27,MPI is an API,MPI is actually just an Application Programming Interface (API). An API specifies what a call to each routine should look like, and how each routine should behave. An API does not specify how each routine should be implemented, and sometimes is intentionally

34、 vague about certain aspects of a routines behavior. Each platform has its own MPI implementation.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,28,Example MPI Routines,MPI_Init starts up the MPI runtime environment at the beginning of a run.

35、 MPI_Finalize shuts down the MPI runtime environment at the end of a run. MPI_Comm_size gets the number of processes in a run, Np (typically called just after MPI_Init). MPI_Comm_rank gets the process ID that the current process uses, which is between 0 and Np-1 inclusive (typically called just afte

36、r MPI_Init).,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,29,More Example MPI Routines,MPI_Send sends a message from the current process to some other process (the destination). MPI_Recv receives a message on the current process from some ot

37、her process (the source). MPI_Bcast broadcasts a message from one process to all of the others. MPI_Reduce performs a reduction (e.g., sum, maximum) of a variable on all processes, sending the result to a single process.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center

38、for Education & Research,30,MPI Program Structure (F90),PROGRAM my_mpi_programIMPLICIT NONEINCLUDE “mpif.h“other includesINTEGER : my_rank, num_procs, mpi_error_codeother declarationsCALL MPI_Init(mpi_error_code) ! Start up MPICALL MPI_Comm_Rank(my_rank, mpi_error_code)CALL MPI_Comm_size(num_procs,

39、mpi_error_code)actual work goes hereCALL MPI_Finalize(mpi_error_code) ! Shut down MPI END PROGRAM my_mpi_program Note that MPI uses the term “rank” to indicate process identifier.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,31,MPI Program S

40、tructure (in C),#include #include “mpi.h“other includesint main (int argc, char* argv) /* main */int my_rank, num_procs, mpi_error;other declarationsmpi_error = MPI_Init( /* Shut down MPI */ /* main */,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Res

41、earch,32,Example: Hello World,Start the MPI system. Get the rank and number of processes. If youre not the server process: Create a “hello world” string. Send it to the server process. If you are the server process: For each of the client processes: Receive its “hello world” string. Print its “hello

42、 world” string. Shut down the MPI system.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,33,hello_world_mpi.c,#include #include #include “mpi.h“int main (int argc, char* argv) /* main */const int maximum_message_length = 100;const int server_r

43、ank = 0;char messagemaximum_message_length+1;MPI_Status status; /* Info about receive status */int my_rank; /* This process ID */int num_procs; /* Number of processes in run */int source; /* Process ID to receive from */int destination; /* Process ID to send to */int tag = 0; /* Message ID */int mpi

44、_error; /* Error code for MPI calls */work goes here /* main */,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,34,Hello World Startup/Shut Down,header file includes int main (int argc, char* argv) /* main */declarationsmpi_error = MPI_Init( /*

45、 main */,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,35,Hello World Clients Work,header file includes int main (int argc, char* argv) /* main */declarationsMPI startup (MPI_Init etc)if (my_rank != server_rank) sprintf(message, “Greetings fr

46、om process #%d!“,my_rank);destination = server_rank;mpi_error = MPI_Send(message, strlen(message) + 1, MPI_CHAR,destination, tag, MPI_COMM_WORLD); /* if (my_rank != server_rank) */else work of server process /* if (my_rank != server_rank)else */mpi_error = MPI_Finalize(); /* main */,Supercomputing i

47、n Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,36,Hello World Servers Work,header file includes int main (int argc, char* argv) /* main */declarations, MPI startupif (my_rank != server_rank) work of each client process /* if (my_rank != server_rank) */else fo

48、r (source = 0; source num_procs; source+) if (source != server_rank) mpi_error =MPI_Recv(message, maximum_message_length + 1,MPI_CHAR, source, tag, MPI_COMM_WORLD, /* main */,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,37,How an MPI Run Wor

49、ks,Every process gets a copy of the executable: Single Program, Multiple Data (SPMD). They all start executing it. Each looks at its own rank to determine which part of the problem to work on. Each process works completely independently of the other processes, except when communicating.,Supercomputing in Plain English: Distributed Parallel OU Supercomputing Center for Education & Research,

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1