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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

Supercomputingin Plain EnglishInstruction Level Parallelism.ppt

1、Supercomputing in Plain English Instruction Level Parallelism,Henry Neeman Director OU Supercomputing Center for Education & Research October 1 2004,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,2,Outline,What is Instruction-Level Parallelism? Scalar Operatio

2、n Loops Pipelining Loop Performance Superpipelining Vectors A Real Example,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,3,Parallelism,Less fish ,More fish!,Parallelism means doing multiple things at the same time: you can get more work done in the same time.

3、,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,4,What Is ILP?,Instruction-Level Parallelism (ILP) is a set of techniques for executing multiple instructions at the same time within the same CPU. The problem: the CPU has lots of circuitry, and at any given tim

4、e, most of it is idle. The solution: have different parts of the CPU work on different operations at the same time if the CPU has the ability to work on 10 operations at a time, then the program can run as much as 10 times as fast (although in practice, not quite so much).,Supercomputing in Plain En

5、glish: ILP OU Supercomputing Center for Education & Research,5,Kinds of ILP,Superscalar: perform multiple operations at the same time (e.g., simultaneously perform an add, a multiply and a load) Pipeline: start performing an operation on one piece of data while finishing the same operation on anothe

6、r piece of data perform different stages of the same operation on different sets of operands at the same time (like an assembly line) Superpipeline: combination of superscalar and pipelining perform multiple pipelined operations at the same time Vector: load multiple pieces of data into special regi

7、sters and perform the same operation on all of them at the same time,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,6,Whats an Instruction?,Memory: e.g., load a value from a specific address in main memory into a specific register, or store a value from a spec

8、ific register into a specific address in main memory Arithmetic: e.g., add two specific registers together and put their sum in a specific register or subtract, multiply, divide, square root, etc Logical: e.g., determine whether two registers both contain nonzero values (“AND”) Branch: jump from one

9、 sequence of instructions to another and so on,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,7,Whats a Cycle?,Youve heard people talk about having a 2 GHz processor or a 3 GHz processor or whatever. (For example, Henrys laptop has a 1.5 GHz Pentium4.) Inside

10、every CPU is a little clock that ticks with a fixed frequency. We call each tick of the CPU clock a clock cycle or a cycle. So a 2 GHz processor has 2 billion clock cycles per second. Typically, a primitive operation (e.g., add, multiply, divide) takes a fixed number of cycles to execute (assuming n

11、o pipelining).,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,8,Whats the Relevance of Cycles?,Typically, a primitive operation (e.g., add, multiply, divide) takes a fixed number of cycles to execute (assuming no pipelining). IBM POWER4 1 Multiply or add: 6 cy

12、cles (64 bit floating point) Load: 4 cycles from L1 cache14 cycles from L2 cache Intel Pentium4 2 Multiply: 7 cycles (64 bit floating point) Add, subtract: 5 cycles (64 bit floating point) Divide, square root: 38 cycles (64 bit floating point) Tangent: 225-250 cycles (64 bit floating point),Scalar O

13、peration,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,10,DONT PANIC!,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,11,Scalar Operation,Load a into register R0 Load b into R1 Multiply R2 = R0 * R1 Load c into R3 Load d

14、 into R4 Multiply R5 = R3 * R4 Add R6 = R2 + R5 Store R6 into z,z = a * b + c * d;,How would this statement be executed?,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,12,Does Order Matter?,Load a into R0 Load b into R1 Multiply R2 = R0 * R1 Load c into R3 Loa

15、d d into R4 Multiply R5 = R3 * R4 Add R6 = R2 + R5 Store R6 into z,z = a * b + c * d;,In the cases where order doesnt matter, we say that the operations are independent of one another.,Load d into R0 Load c into R1 Multiply R2 = R0 * R1 Load b into R3 Load a into R4 Multiply R5 = R3 * R4 Add R6 = R2

16、 + R5 Store R6 into z,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,13,Superscalar Operation,Load a into R0 AND load b into R1 Multiply R2 = R0 * R1 AND load c into R3 AND load d into R4 Multiply R5 = R3 * R4 Add R6 = R2 + R5 Store R6 into z,z = a * b + c * d

17、;,So, we go from 8 operations down to 5. (Note: there are lots of simplifying assumptions here.),Loops,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,15,Loops Are Good,Most compilers are very good at optimizing loops, and not very good at optimizing other cons

18、tructs.,DO index = 1, lengthdst(index) = src1(index) + src2(index) END DO,Why?,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,16,Why Loops Are Good,Loops are very common in many programs. Also, its easier to optimize loops than more arbitrary sequences of inst

19、ructions: when a program does the same thing over and over, its easier to predict whats likely to happen next. So, hardware vendors have designed their products to be able to execute loops quickly.,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,17,DONT PANIC!,

20、Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,18,Superscalar Loops,DO i = 1, nz(i) = a(i)*b(i) + c(i)*d(i) END DO,Each of the iterations is completely independent of all of the other iterations; e.g.,z(1) = a(1)*b(1) + c(1)*d(1) has nothing to do withz(2) = a

21、(2)*b(2) + c(2)*d(2) Operations that are independent of each other can be performed in parallel.,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,19,Superscalar Loops,for (i = 0; i n; i+) zi = ai * bi + ci * di; ,Load ai into R0 AND load bi into R1 Multiply R2 =

22、 R0 * R1 AND load ci into R3 AND load di into R4 Multiply R5 = R3 * R4 AND load ai+1 into R0 AND load bi+1 into R1 Add R6 = R2 + R5 AND load ci+1 into R3 AND load di+1 into R4 Store R6 into zi AND multiply R2 = R0 * R1 etc etc etc Once this loop is “in flight,” each iteration adds only 2 operations

23、to the total, not 8.,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,20,Example: IBM POWER4,8-way Superscalar: can execute up to 8 operations at the same time1 2 integer arithmetic or logical operations, and 2 floating point arithmetic operations, and 2 memory

24、access (load or store) operations, and 1 branch operation, and 1 conditional operation,Pipelining,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,22,Pipelining,Pipelining is like an assembly line or a bucket brigade. An operation consists of multiple stages. Af

25、ter a particular set of operandsz(i)=a(i)*b(i)+c(i)*d(i)completes a particular stage, they move into the next stage. Then, another set of operandsz(i+1)=a(i+1)*b(i+1)+c(i+1)*d(i+1)can move into the stage that was just abandoned by the previous set.,Supercomputing in Plain English: ILP OU Supercomput

26、ing Center for Education & Research,23,DONT PANIC!,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,24,Pipelining Example,i = 1,i = 2,i = 3,i = 4,Computation time,If each stage takes, say, one CPU cycle, then once the loop gets going, each iteration of the loop

27、increases the total time by only one cycle. So a loop of length 1000 takes only 1004 cycles. 3,t = 0,t = 1,t = 2,t = 3,t = 4,t = 5,t = 6,t = 7,DONT PANIC!,DONT PANIC!,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,25,Pipelines: Example,IBM POWER4: pipeline len

28、gth 15 stages 1,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,26,Some Simple Loops,DO index = 1, lengthdst(index) = src1(index) + src2(index) END DO ! index = 1, lengthDO index = 1, lengthdst(index) = src1(index) - src2(index) END DO ! index = 1, lengthDO ind

29、ex = 1, lengthdst(index) = src1(index) * src2(index) END DO ! index = 1, lengthDO index = 1, lengthdst(index) = src1(index) / src2(index) END DO ! index = 1, lengthDO index = 1, lengthsum = sum + src(index) END DO ! index = 1, length,Reduction: convert array to scalar,Supercomputing in Plain English

30、: ILP OU Supercomputing Center for Education & Research,27,Slightly Less Simple Loops,DO index = 1, lengthdst(index) = src1(index) * src2(index) END DO ! index = 1, lengthDO index = 1, lengthdst(index) = MOD(src1(index), src2(index) END DO ! index = 1, lengthDO index = 1, lengthdst(index) = SQRT(src

31、(index) END DO ! index = 1, lengthDO index = 1, lengthdst(index) = COS(src(index) END DO ! index = 1, lengthDO index = 1, lengthdst(index) = EXP(src(index) END DO ! index = 1, lengthDO index = 1, lengthdst(index) = LOG(src(index) END DO ! index = 1, length,Loop Performance,Supercomputing in Plain En

32、glish: ILP OU Supercomputing Center for Education & Research,29,Performance Characteristics,Different operations take different amounts of time. Different processors types have different performance characteristics, but there are some characteristics that many platforms have in common. Different com

33、pilers, even on the same hardware, perform differently. On some processors, floating point and integer speeds are similar, while on others they differ.,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,30,Arithmetic Operation Speeds,Supercomputing in Plain Englis

34、h: ILP OU Supercomputing Center for Education & Research,31,Fast and Slow Operations,Fast: sum, add, subtract, multiply Medium: divide, mod (i.e., remainder) Slow: transcendental functions (sqrt, sin, exp) Incredibly slow: power xy for real x and y On most platforms, divide, mod and transcendental f

35、unctions are not pipelined, so a code will run faster if most of it is just adds, subtracts and multiplies (e.g., solving systems of linear equations by LU decomposition).,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,32,What Can Prevent Pipelining?,Certain e

36、vents make it very hard (maybe even impossible) for compilers to pipeline a loop, such as: array elements accessed in random order loop body too complicated if statements inside the loop (on some platforms) premature loop exits function/subroutine calls I/O,Supercomputing in Plain English: ILP OU Su

37、percomputing Center for Education & Research,33,How Do They Kill Pipelining?,Random access order: ordered array access is common, so pipelining hardware and compilers tend to be designed under the assumption that most loops will be ordered. Also, the pipeline will constantly stall because data will

38、come from main memory, not cache. Complicated loop body: the compiler gets too overwhelmed and cant figure out how to schedule the instructions.,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,34,How Do They Kill Pipelining?,if statements in the loop: on some p

39、latforms (but not all), the pipelines need to perform exactly the same operations over and over; if statements make that impossible. However, many CPUs can now perform speculative execution: both branches of the if statement are executed while the condition is being evaluated, but only one of the re

40、sults is retained (the one associated with the conditions value). Also, many CPUs can now perform branch prediction to head down the most likely compute path.,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,35,How Do They Kill Pipelining?,Function/subroutine ca

41、lls interrupt the flow of the program even more than if statements. They can take execution to a completely different part of the program, and pipelines arent set up to handle that. Loop exits are similar. Most compilers cant pipeline loops with premature or unpredictable exits. I/O: typically, I/O

42、is handled in subroutines (above). Also, I/O instructions can take control of the program away from the CPU (they can give control to I/O devices).,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,36,What If No Pipelining?,SLOW!(on most platforms),Supercomputing

43、 in Plain English: ILP OU Supercomputing Center for Education & Research,37,Randomly Permuted Loops,Superpipelining,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,39,Superpipelining,Superpipelining is a combination of superscalar and pipelining. So, a superpip

44、eline is a collection of multiple pipelines that can operate simultaneously. In other words, several different operations can execute simultaneously, and each of these operations can be broken into stages, each of which is filled all the time. So you can get multiple operations per CPU cycle. For ex

45、ample, a IBM Power4 can have over 200 different operations “in flight” at the same time.1,Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,40,More Operations At a Time,If you put more operations into the code for a loop, youll get better performance: more operat

46、ions can execute at a time (use more pipelines), and you get better register/cache reuse. On most platforms, theres a limit to how many operations you can put in a loop to increase performance, but that limit varies among platforms, and can be quite large.,Supercomputing in Plain English: ILP OU Sup

47、ercomputing Center for Education & Research,41,Some Complicated Loops,DO index = 1, lengthdst(index) = src1(index) + 5.0 * src2(index) END DO ! index = 1, lengthdot = 0 DO index = 1, lengthdot = dot + src1(index) * src2(index) END DO ! index = 1, lengthDO index = 1, lengthdst(index) = src1(index) *

48、src2(index) + & src3(index) * src4(index) END DO ! index = 1, lengthDO index = 1, lengthdiff12 = src1(index) - src2(index)diff34 = src3(index) - src4(index)dst(index) = SQRT(diff12 * diff12 + diff34 * diff34) END DO ! index = 1, length,madd (or FMA): mult then add (2 ops),Euclidean distance (6 ops),

49、dot product (2 ops),from our example (3 ops),Supercomputing in Plain English: ILP OU Supercomputing Center for Education & Research,42,A Very Complicated Loop,lot = 0.0 DO index = 1, lengthlot = lot + & src1(index) * src2(index) + & src3(index) * src4(index) + & (src1(index) + src2(index) * & (src3(index) + src4(index) * & (src1(index) - src2(index) * & (src3(index) - src4(index) * & (src1(index) - src3(index) + & src2(index) - src4(index) * & (src1(index) + src3(index) - & src2(index) + src4(index) + & (src1(index) * src3(index) + & (src2(index) * src4(index) END DO ! index = 1, length,

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