【大学课件】计算机系统结构Computer Architecture.ppt

上传人:本田雅阁 文档编号:3037552 上传时间:2019-06-28 格式:PPT 页数:62 大小:747.01KB
返回 下载 相关 举报
【大学课件】计算机系统结构Computer Architecture.ppt_第1页
第1页 / 共62页
【大学课件】计算机系统结构Computer Architecture.ppt_第2页
第2页 / 共62页
【大学课件】计算机系统结构Computer Architecture.ppt_第3页
第3页 / 共62页
【大学课件】计算机系统结构Computer Architecture.ppt_第4页
第4页 / 共62页
【大学课件】计算机系统结构Computer Architecture.ppt_第5页
第5页 / 共62页
点击查看更多>>
资源描述

《【大学课件】计算机系统结构Computer Architecture.ppt》由会员分享,可在线阅读,更多相关《【大学课件】计算机系统结构Computer Architecture.ppt(62页珍藏版)》请在三一文库上搜索。

1、计算机系统结构 Computer Architecture,http:/ Main Contents 课程主要内容,Chapter 12 CPU Structure and Function CPU结构和功能 Chapter 13 Reduced Instruction Set Computers 精简指令集计算机 Chapter 14 Instruction-Level Parallelism & Superscalar Processors 指令集并行性和超标量处理器 Chapter 18 Parallel Processing 并行处理,William Stallings Compute

2、r Organization and Architecture 7th Edition,Chapter 13 Reduced Instruction Set Computers,http:/ Advances in Computers 计算机的主要改进 Instruction Execution Characteristics 指令执行的特点 Use of Large Register File 使用大的寄存器 Compiler-Based Register Optimization 基于编译器的寄存器优化 Reduced Instruction Set Architecture 精简指令集体

3、系结构 RISC Pipelining RISC流水线 RISC vs. CISC Controversy RISC和CISC 的比较,5,Major Advances in Computers(1),The family concept 系列概念 IBM System/360 1964 DEC PDP-8 Separates architecture from implementation 将体系结构和它的实现分开 Microporgrammed control unit 微程序控制器 Idea by Wilkes 1951 Produced by IBM S/360 1964 Cache

4、memory Cache存储器 IBM S/360 model 85 1969,6,Major Advances in Computers(2),Solid State RAM 固态存储器 (See memory notes) Microprocessors 微处理器 Intel 4004 1971 Pipelining 流水线 Introduces parallelism into fetch execute cycle Multiple processors 多处理器,7,The Next Step - RISC,RISC-Reduced Instruction Set Computer

5、RISC精简指令集计算机 Key features Large number of general purpose registers, or use of compiler technology to optimize register use 大量通用寄存器,使用编译技术优化寄存器的使用 Limited and simple instruction set 一个有限简单的指令集 Emphasis on optimising the instruction pipeline 强调指令流水的优化,8,Comparison of processors,9,Driving force for CI

6、SC(1),CISC-Complex Instruction Set Computer CISC复杂指令集计算机 Why CISC? Software costs far exceed hardware costs 软件成本高于硬件成本 Increasingly complex high level languages 越来越复杂的高级语言 Semantic gap : Difference between operations provided in HLLs and those provided in computer architecture 语义间隙问题: HLLs提供的操作和计算机体

7、系结构提供的操作不同,10,Driving force for CISC(2),to close the gap Leads to: Large instruction sets 指令集非常大 More addressing modes 更多的寻址方式 Hardware implementations of HLL statements e.g. CASE (switch) on VAX HLL描述的硬件的实现,11,Intention of CISC 复杂指令集体系结构的目的,Ease compiler writing 使编译器的编写更容易 Improve execution efficie

8、ncy 提高执行效率 Complex operations in microcode 因为复杂操作能以微代码实现 Support more complex HLLs 提供更复杂的HLL支持 A totally different approach:Simpler architecture 简化体系结构,12,精简指令计算机RISC设计思路的提出,A number of studies have been done to determine the characteristics and patterns of execution of machine instructions generate

9、d from HLL programs 已经进行的很多研究,目的是确定高级语言程序生成的机器指令执行的特征和模式 The results of these studies inspired some researchers to look for a different approach 促使设计人员寻找一种与复杂指令系统截然不同的方法 A totally different approach: Simpler architecture 简化体系结构,13,Execution Characteristics执行特征,Developments of RISCs were based on the

10、 study of instruction execution characteristics RISC的开发是基于指令的执行特性 Operations performed 完成的操作 determine functions to be performed and interaction with memory 决定了CPU所要完成的功能及其与存储器的相互作用 Operands used (types and frequencies) 使用的操作数及其类型和频率 determine memory organization and addressing modes 决定了存储器如何组织存储它们和

11、访问它们用的寻址方式 Execution sequencing 执行顺序 determines the control and pipeline organization 决定了控制和流水线的组织结构,14,Execution Characteristics执行特征,Dynamic measurements & Static measurements 动态测量和静态测量 Dynamic measurements are measured during the execution of the program. 程序的执行中进行的动态测量。 Static measurements merely

12、perform these counts on the source text of a program. 静态测量只是在源程序文本上进行统计,这不能给出很有用的性能信息。,15,Relative Dynamic Frequency,Dynamic Machine Instruction Memory Reference Occurrence (Weighted) (Weighted) Pascal C Pascal C Pascal C Assign 45 38 13 13 14 15 Loop 5 3 42 32 33 26 Call 15 12 31 33 44 45 If 29 43

13、11 21 7 13 GoTo - 3 - - - - Other 6 1 3 1 2 1,16,Operations操作,Assignment statements predominate 赋值语句占统治地位 Movement of data is of high importance 数据的移动重要性 Preponderance of Conditional statements (IF, LOOP)条件语句占优势地位 Sequence control is important 指令集的顺序控制,17,Operations操作,Procedure call-return is very t

14、ime consuming 程序的调用花费大量时间 Some HLL instruction lead to many machine code operations 一些HLL指令导致执行大量机器代码,18,Operands,Mainly local scalar variables 主要是局部标量变量 Optimisation should concentrate on accessing local variables 优化也应该集中在局部变量的访问 Pascal C Average Integer constant 16 23 20 Scalar variable 58 53 55 A

15、rray/structure 26 24 25,19,Procedure Calls过程调用,Very time consuming 过程调用是编译后的HLL程序中最耗时的操作 To implement efficiently, two aspects are significant: Depends on number of parameters passed 依赖于传递的参数的数量 Depends on level of nesting 依赖于嵌套深度 Most programs do not do a lot of calls followed by lots of returns 程序

16、一般不作大量的调用之后跟着大量的返回 Most variables are local 大部分变量是局部的,20,Implications结论,Making instruction set architecture close to HLL 使指令集与HLL相近 not most effective 不是最有效的 Best support is given by optimising most used and most time consuming features 通过优化最经常使用的和最花费时间的,是最好的方案。,21,Implications,Generalizing from the

17、 work of a number of researchers, three elements emerge that, by and large, characterize RISC architectures. Large number of registers 大量寄存器 Operand referencing optimization + locality of references memory references reduced 减少存储器访问 Careful design of pipelines 精心设计流水线 Conditional branch and procedur

18、e call 条件分支和过程调用 Simplified (reduced) instruction set 精简指令集,22,Use of Large Register File,From the analysis Large number of assignment statements Most accesses to local scalars 主要访问本地标量 Heavy reliance on register storage 依赖于寄存器存储 Minimizing memory access 最小化内存访问,23,Approaches,Software solution to ma

19、ximize register usage软件方法 Require compiler to allocate registers to those most used variables in a given time 依赖于编译器,把寄存器分配给那些一定时间内使用最多的变量 Requires sophisticated program analysis 需要复杂的程序分析 Hardware solution硬件方法 Have more registers 大量寄存器 Thus more variables will be in registers 寄存器中存放大量变量,24,Register

20、s for Local Variables,Store local scalar variables in registers 在寄存器中存放本地标量变量 Reduces memory access 减少存储器访问 Some problems Every procedure (function) call changes locality 每一次过程调用都会改变局部性 On every call, local variables must be saved to memory 每次调用变量必须被存储到存储器 Parameters must be passed 必须传递参数 On return,

21、 results must be returned and variables from calling programs must be restored 必须返回结果并且恢复调用程序的变量,25,Register Windows,Solution: Register windows Organization of registers to realize the goal 为了实现解决前述问题的目标,而对寄存器采用的组织结构 From the analysis Only few parameters and local variables 少量参数和本地变量 Limited range o

22、f depth of call 有限的调用深度 Use multiple small sets of registers 使用多个小的寄存器组 Calls switch to a different set of registers 过程调用时自动地切换来使用不同的寄存器组 Returns switch back to a previously used set of registers 返回时切换回以前使用的寄存器组,26,Overlapping Register Windows,Three areas within a register set 窗口分为3个域: Parameter reg

23、isters 参数寄存器域 Local registers 局部寄存器域 Temporary registers 临时寄存器域,27,Register Windows cont.,Temporary registers from one set overlap parameter registers from the next 临时寄存器用于当前过程与下一级过程(被当前过程调用的过程)交换参数和结果 Temporary registers at one level are physically the same as the parameter registers at the next lo

24、wer level. 当前层的临时寄存器域和下一层的参数寄存器域物理上是同一个域。 This allows parameter passing without moving data 这种重叠准许不用实际移动数据就能传递参数,28,Circular Buffer diagram,The actual organization of the register file is as a circular buffer of overlapping windows. 寄存器集的实际组织结构是一个由重叠窗口组成的环形缓冲器。,29,Operation of Circular Buffer,When a

25、 call is made, a current window pointer (CWP) is moved to show the currently active register window 当一个调用发生时,当前窗口指针移动到当前活动寄存器窗口 If all windows are in use, an interrupt is generated and the oldest window (the one furthest back in the call nesting) is saved to memory (only .in and .loc need to be save

26、d) 当所有窗口都在使用就会产生中断,最老的窗口会保存到内存(只保存参数、局部窗口的数据) A saved window pointer indicates where the next saved windows should restore to 保存窗口指针表明下一个保存窗口应该恢复的地方,30,Operation of Circular Buffer (2),Studies show: 8 windows are enough to handle up to of call/return without save/restore 8个窗口足够处理99%的调用和返回 E.g., Berk

27、eley RISC uses 8 windows of 16 registers each,31,Global Variables - 2 Options,Allocated by the compiler to memory 由编译器为全局变量指定存储器位置 Straightforward 直截了当 Inefficient for frequently accessed variables 对经常访问的全局变量效率低下 Have a set of registers for global variables CPU中有一组全局寄存器 e.g., registers 0 - 7: global

28、 8 - 31: local to current window Increased hardware burden 硬件负担增加 Compiler must decide which global variables should be designed to registers 编译器也必须裁定什么样的全局变量应指派到寄存器。,32,Registers v Cache,Large Register File Cache All local scalars Recently used local scalars 所有局部变量 最近使用的局部标量 Individual variables Bl

29、ocks of memory 个别变量 存储器块 Compiler assigned global variables Recently used global variables 编译器指派全局变量 最近使用的全局变量 Save/restore based on Save/restore based on caching procedure nesting algorithm 保存/恢复基于过程的嵌套深度 保存/恢复基于cache替换算法 Register addressing Memory addressing 寄存器寻址 存储器寻址,33,Registers v Cache,大寄存器 保

30、留了所有的局部标量变量 空间利用率低(窗口大,参数少) 寄存器与存储器之间的数据传送不太频繁 Cache 有选择地保留局部标量变量 可以有效地利用空间(动态更新) 同时也存在空间利用率低的问题(成块传送,包含无用数据) 寄存器与存储器之间的数据传送可能较频繁(组关联映像),34,Registers v Cache,寄存器优于Cache表现在: 为访问基于窗口寄存器集中的一个局部标量,使用一个窗口号和一个“虚拟的”寄存器号。这些通过一个相对简单的译码器来选择某一个具体的寄存器。 为访问cache存储器中的一个位置,必须生成全宽度的地址。这种操作的复杂性取决于寻址方式。在一个组关联的cache中,

31、地址的一部分用于读取等同于组长度的几个字和标记(tag),地址的另一部分用于与标记进行比较,以选择所读的一个字。 这一点应是很清楚的,尽管cache能与寄存器集一样地快,但cache的存取时间肯定要长。于是,从性能观点看,基于窗口的寄存器集对于局部标量是优选的。通过加入只由指令使用的cache,能进一步改善性能。,35,Referencing a Scalar - Window Based Register File,“virtual” register number,window number,快,36,Referencing a Scalar - Cache,慢,37,Compiler B

32、ased Register Optimization,Assume small number of registers (16-32) 假设只有少量寄存器可用 优化寄存器的使用就是编译器的责任 HLL programs have no explicit references to registers 用高级语言写的程序没有对寄存器的显式引用 The objective of the compiler is to keep the operands for as many computations as possible in registers rather than main memory,

33、 and to minimize load-and-store operations.编译器的目标就是,尽可能地在寄存器中而不是在主存中为多数计算保持操作数,并且减少与内存的装入和存储操作。,38,Compiler Based Register Optimization cont.,Each quantity is assigned to a symbolic or virtual register 准备驻留在寄存器中的每个程序量先被指派到一个符号的或虚拟的寄存器中 Map (unlimited) symbolic registers to real registers 然后编译器再将这些末限

34、定数目的符号寄存器映射到固定数目的实寄存器上 Symbolic registers that do not overlap can share real registers 那些使用不重叠的符号寄存器能共享同一实寄存器 If you run out of real registers, some variables use memory 若在程序具体运行期间,需要打交道的量多于实寄存器数目、则某些量要被指派到存储器位置上,39,Optimization,The essence of the optimization task is to decide which quantities are

35、to be assigned to registers 优化任务的本质: 是判定程序中什么样的量应指派到寄存器中 The technique is known as graph coloring 图着色技术 Used in RISC compiler 用在RISC编译器 Borrowed from the discipline of topology 这是由拓扑学借用过来的技术,40,Graph Coloring,Given a graph of nodes and edges 对于一个由结点和边组成的给定图 Assign a color to each node 为每个结点指定颜色 Adja

36、cent nodes have different colors 使相邻节点不同色 Use minimum number of colors 要使用颜色的数目最少 Nodes are symbolic registers 结点是符号寄存器,41,Graph Coloring cont.,Two registers that are live in the same program fragment are joined by an edge 若两个符号寄存器同时“存活”于同一程序段,则相应的两个结点用一条边连接起来以指出它们相关。 Try to color the graph with n c

37、olors, where n is the number of real registers 尝试用n种颜色给图上色,n为实寄存器的数目 Nodes that can not be colored are placed in memory 这些不能上色的结点必须放入存储器中,42,Graph Coloring Approach,Assume a program with six symbolic registers to be compiled into three actual registers Part a: 符号寄存器使用的时间顺序 Part b: 寄存器干涉图,43,A Trade-

38、Off,A trade-off between large registers and register optimization 在使用大量的寄存器和寄存器优化之间有一个权衡考虑问题 With even simple register optimization, there is little benefit to the use of more than 64 registers 若只有相当简单的寄存器优化,那么使用多于64个寄存器只带来很少的好处 With reasonably sophisticated register optimization techniques, there i

39、s only marginal performance improvement with more than 32 registers 使用相当精致的寄存器优化技术,使用多于32个的寄存器仅有临界性能改善 Studies show 64 registers are enough with simple register optimization 32 registers are enough with sophisticated register optimization,44,Reduced Instruction Set Architecture Why CISC (1)?,Why CIS

40、C? Ease compiler writing 使编译器的编写更容易 Improve execution efficiency 提高执行效率 Compiler simplification? Disputed争论 Complex machine instructions harder to exploit 难以使用,编译器必须找到严格满足限制的情况 Optimization more difficult E.g. Minimize code size, enhance pipelining 减小代码、提高流水都很难实现,45,Why CISC (2)?,Smaller programs? P

41、rogram takes up less memory 程序占用内存少 But memory is now cheap 但是内存非常便宜 Fewer instructions to be fetched, reducing page faults. 取更少的指令,减少缺页 May not occupy less bits in symbolic machine language 符号形式的机器语言,所占据的存储器位数却不见得小 More instructions require longer op-codes CISC指令多,需要的操作码就长 RISC tend to emphasize re

42、gister, and register references require fewer bits RISC指令使用的寄存器访问要求较少位数,46,Why CISC (1)?,Code Size Relative to RISC I 11 C Programs RISC I 1.0 VAX-11/780 0.8 M68000 0.9 Z8002 1.2 PDP-11/70 0.9 CISC比RISC节省很少甚至没有节省 VAX比PDP-11减少很少,但VAX指令复杂的多,更复杂CISC,CISC,47,Why CISC (3)?,Faster programs? More complex c

43、ontrol unit 更复杂的控制单元 Microprogram control store larger 微程序控制存储更大 thus simple instructions take longer to execute 增加了简单指令的执行时间 It is far from clear that CISC is the appropriate solution CISC是否是较合适的解决方法还远不是那么清楚,48,RISC Characteristics,One instruction per cycle 每周期一条指令 Register to register operations 寄

44、存器到寄存器操作 Few, simple addressing modes 简单寻址方式 Few, simple instruction formats 简单指令格式,49,One Instruction Per Machine Cycle,In a machine cycle 在一个机器周期 fetch two operands from registers 从寄存器取两个操作数 Perform an ALU operation 完成一个ALU操作 Store the result in a register 结果存寄存器 There is little or not need for mi

45、crocode 很少或没有需要微代码 Machine instructions can be hardwired 机器指令可以用硬布线的方式实现 Such instructions should execute faster than comparable machine instructions on other machines.,50,Register-to-Register Operations,Most operations is register-to-register 大多数操作应是寄存器到寄存器的 Only LOAD and STORE accessing memory 只有简

46、单的LOAD和STORE操作访问存储器 Simplify instruction set and control unit 简化指令集和控制器 RISC include only 1 or 2 ADD instructions VAX has 25 different ADD instructions Encourages the optimization of register use 更适合于寄存器的优化使用 Frequently accessed operands remain in high-speed storage频繁存取的操作数保留在高速存储装置,51,Simple Addres

47、sing Modes,Almost all RISC instructions use simple register addressing 几乎全部RISC指令都使用寄存器寻址方式 May include several additional modes Displacement and PC-relative 可能包括几种其它寻址方式,如偏移和相对 Simplify instruction set and control unit 简化指令集和控制器,52,Simple Instruction Formats,Only one or a few formats are used 仅使用一种

48、或少数几种格式 Instruction length is fixed and aligned on word boundaries 指令长度固定并且在字边界上对齐 A single instruction does not cross page boundaries 单一指令不会跨越内存分页的边界 Field locations, especially the opcode, are fixed 字段位置,特别是操作码字段位置是固定的 Opcode decoding and register operand accessing can occur simultaneously 操作码的译码和寄存器操作数的访问能同时出现 Simplify control unit 简化控制器,53,CISC v RISC,Typical of a RISC A single instruction size (typically 4 bytes) 单一指令长度(典型4个字节) A small number of data addressing modes (typically less than five) 较少的寻址方式(典型小于5种

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1