计算机组成原理 第一章 概论 -...

73
计算机组成原理 第一章 概论 李曦 [email protected]

Transcript of 计算机组成原理 第一章 概论 -...

Page 2: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算机系统设计:313模型(LLXX)

计算机的功能:算逻运算(狭义),信息计算(广义),实时控制

科学基础:“信息”是什么?什么是“计算” ?什么问题能用计算机计算?

计算机组成原理:什么是计算机?——计算机“硬件”的“ABC”

Page 3: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

本章教学内容

• 计算机组成原理的科学基础

• 计算机系统概述

– 计算机软硬件

– 计算机系统的层次结构

– 计算机组成 VS. 计算机体系结构

• 计算机的基本组成

– Von Neumann机的特征

– 计算机的硬件构成

– 计算机的工作过程

• 计算机硬件的性能指标

• 数电基础知识回顾

Page 4: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

信息?信息的载体?

• 信息、意思、语言、文字,编码系统? – the Voyager spacecraft,USA,1977

• Meaning,Messages,Information?

– the central dogma of information theory(?)

• Information is independent of the meaning that it expresses, and of the language used to express it.

• All that is needed to transfer information from one language to another is a coding system.

– Language,word,编码

• The story of the drum language:Each Kele(刚果语)word is spoken by the drums as a sequence of low and high beats.

• 文字:中文/英语(表音 or 表意)

• 图形,0/1编码

– 《The Information: A History, a Theory, a Flood》

• 2011年出版,10少李帅2015年推荐

Page 5: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

象形文字(pictograph):表音?表意?

• 距今5000多年,古埃及

• 纳西族的东巴文(上)和水族的水书(下)仍在使用。

Page 6: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Coding system:传递的啥? 摩尔斯电码的演变

Page 7: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

信息“消失”?

• 84年,霍金(Hawking)黑洞信息悖论

– “黑洞使被其吸入的物体的信息消失!”

• xx年,萨斯坎德(弦论创始人,Stanford大学)

– “否,成为全息映像”

– “全息”:在黑洞中无所不在!

• 如:向水盆中滴入两滴红药水,初始它们聚集在一起。一段时间后,整个水盆变红了。

• 看起来“两滴红药水的信息消失了”,但“两滴红药水的信息并没有消失——可以在分子级发现”!

– “两滴”呢?

• 04年,霍金承认自己错了!

– 信息守恒?

Page 8: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

信息论

• 诺伯特·维纳(Norbert Wiener) ,1948 – 《控制论》:“信息就是信息,既不是物质,也不是能量”

• 香农(Claude Shannon),“通信的数学理论”,1948

– “信息是用来消除随机不定性的东西”

– “信息的最小单位是比特(二值符号)”

• 任何复杂信息都可以根据其结构和内容,按照一定的编码规则进行分割,最终成为一组二值数据。——没语言啥事?

– 度量信息量:一本五十万字的书有多少信息量?

• 任何信息都存在冗余

– 冗余量与信息中各符号(数字、字母或单词)出现概率有关

• 信息熵:信息中排除了冗余后的平均信息量

– 单位:比特

– 熵大=复杂(中文9.65比特,英文4.03比特)

Page 9: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

两个二进制串的信息量

• 对象的描述:某对象的精确且无歧义的特征 – 可以据此特征重建该对象!

• 对象的信息量:某对象的最小表示,或描述的大小 – “最短描述长度”

• 可压缩串

Page 10: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算的极限(信息处理极限?)

• 布莱曼极限(Bremermann’s Limit,1962)

– “不可能存在一个数据处理系统(生命的或人造的)能够每秒每克质量可以处理超过2X1047比特的信息量”——最大计算速度

– 以整个地球为能量的计算机,自地球诞生时起,至今所完成的计算量小于1093比特

– 40城市的货郎问题(遍历所有城市)已经超出了布莱曼极限。

Page 11: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Joseph Sifakis(2007图灵奖),2011

• Information is an entity distinct from matter and energy.

• It is a resource that can be stored, transformed, transmitted

and consumed.

• It is immaterial but needs media for its representation by using

languages characterized by their syntax and semantics.

• It should not be confused with physical information measured

as entropy in Information Theory and Physics.

– 信息作为一种区别于物质和能量的客观存在,可以被存储、转换、传递和使用。

– 信息是无形的,但可以通过语言进行表达。

– 不应将其与在信息论和物理学中采用熵进行度量的物理信息混淆。——?

• 质能守恒:E=MC2,“I”?三者守恒?

• llxx:信息是意识的表现和物化

Page 12: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算机科学与计算机工程

• 与CE相关的三个经典问题

– 巴贝奇(Charles Babbage)问题,1833

• 自动计算的实现:程序控制

• 建造“分析机”:三角函数、级数相乘、伯努利函数

• Ada,第一位程序员,Ada语言1981

– 图灵问题:智能的机械化

– 布什(Vannevar Bush,)问题,1945

• “As We May Think”:信息的广义互连?

• 计算机研究的两条路线

– 计算机理论:图灵

• Turing Machine,1936,可计算性,存储程序

– 计算机工程:冯·诺依曼

• von Neuman Machine,1945,存储程序

Page 13: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

能行计算理论(computability theory)

• 计算:是对运算过程的一种高度抽象

• 算法

– 对计算的步骤或状态的一种刻画,是计算方法的一种实现方式

– 将计算抽象为输入到输出的函数映射,是一个封闭的计算过程

• 算法可计算性:判断一类数学问题是否机械可解

• 计算模型(MoC)

– 刻画“计算”概念的抽象的形式化系统或数学系统。

• λ演算(串行)、递归、π演算(分布)等

– 状态迁移系统

• 具有状态转换特征,能够对所处理的对象的数据或信息进行表示、加工、变换、输出的数学机器。

– 图灵机

Page 14: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

MoC:图灵机(Turing Machine,1936)

• 自动计算机结构 – 一条两端可以无限延伸的纸带

– 一个读写头(符号包括0、1、b)

– 一个控制器(执行控制读写头工作的命令) • 五元组:(状态、读符号)→(写符号、移动、状态)

• 状态集:开始状态,中间状态,结束状态

– 六个操作:读、写、左、右、改变状态、停止 • 基本操作(primitives)是读写纸带?

0 0 0 1 1 1 0 1 1 1 1 1 0 0

控制器

q101Rq1

q110Rq1

q1bbRq2

q2bbLq3

q200Hq1

q211Hq1

当进入结束状态时,停机(H),纸带上的内容为输出结果

控制命令示例:

Page 15: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

关于MoC的两个重要原理

– 计算复杂性是否与计算模型有关?

– 不同计算模型解决同一类问题所需资源是否相同?

• 相似性原理

– 相似性原理:所有计算模型的计算能力等同

• 所有合理的、功能足够强大的计算模型可以相互模拟计算,且使用的本质相同的并行计算时间、串行计算时间和空间

• Turing完备性

– 丘奇-图灵论题:可计算性等价于图灵机的可计算性

• 对偶性原理

– 在并行计算模型上,计算的时间与空间可以互换

Page 16: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

机械式计算机=>自动计算机

• 1642年,法国哲学家和数学家帕斯卡(Blaise Pascal) – 第一台加减法计算机

• 1833年,英国科学家巴贝奇(Charles Babbage) – 提出制造“自动化计算机”的设想和程序控制概念,但未实现

• 1944年,艾肯(Howard Aiken,IBM) – 第一台数字式自动计算机Mark I(继电器计算机)

– 实现了巴贝奇设想,并提出哈佛结构(Harvard architecture)

Page 17: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

第一台现代电子计算机,真空管,1946

• ENIAC( Electronic Numerical Integrator and Computer),1946年宾夕法尼亚大学 – 运算速度 5000次/秒,功耗150kw/h,占地170m2 ,造价100万美元。用于测定氢弹可靠性。

• 不具备“存储程序”能力——不可编程,且程序无法共享 – 程序要通过外接电路板输入(wired)。对于不同类型的计算,需要设计相应的外接插板。

– 十进制并行计算机(同时处理10个数)。

Page 18: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

EDVAC计算机,1944~1952

• Electronic Discrete Variable Automatic Computer – 1MHz,二进制,字长32位,串行

– 存储程序(Stored Program)

Page 19: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

第一台存储程序式计算机EDSAC

• Electronic Delay Storage Automatic Calculator – 参考EDVAC机,1946~1949年Wilkes在剑桥实现

•采用水银延迟线为存储器,可存储34b字长的512字。

•加法时间1.5ms,乘法时间4ms。

•串行计算机(数据传输和运算按位逐一进行)

•微程序,子程序,Cache,…

Maurice Vincent Wilkes,第二届图灵奖,1967

Page 20: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算机的分代

分代 器件 体系结构技术 软件技术 典型机器

第一代

(1945-1954) 电子管和继电器,水银线

存储程序计算机、程序控制I/O

机器语言和汇编语言

普林斯顿ISA、ENIAC

IBM701

第二代

(1955-1964) 晶体管、磁芯、印刷电路

浮点数据表示、寻址技术、中断、I/O处理机

高级语言和编译、批处理监控系统

Univac LARC

CDC1604

IBM7030

第三代

(1965-1974)

SSI和MSI、多

层印刷电路、微程序

流水线、Cache

、先行处理、系列计算机

多道程序和分时操作系统

IBM360/370CD

C6600/7600、DEC PDP-8

第四代

(1974-1990)

LSI和VLSI、半导体存储器

向量处理、分布式存储器

并行与分布处理

Cray-1、IBM

3090、DEC

VAX9000、Convax-1

第五代

(1991-) 高性能微处理器、大规模高密度电路

指令级并行、SMP、MP、MPP、网络

可扩展并行与分布处理

SGI Cray T3E

IBM xServer

Sun E10000

Page 21: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

2030:ISCA 2016

• 技术(工艺),应用(领域专用)

Page 22: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

von Neuman Machine

• 参与研究ENIAC和EDVAC计算机

• 提出“存储程序(Stored Program)”,1945

– 《First Draft of a Report on the EDVAC》

• 被称为von Neumann体系结构。

• 图灵设计ACE时也提出同样的构想

– “offers general purpose computing”

• 专用:dedicated hardware

– Need reconfigure or rewire hardware

• programmed machines:通用图灵机

Page 23: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Von Neumann Machine Architecture

• 由五大部件构成 – 运算器、控制器、存储器、输入设备、输出设备

• 指令和数据存储方式 – “以同等地位”存放于存储器内,分别按地址访问

• 指令和数据表示形式 – 均用二进制码表示

• 指令构成 – 由操作码和地址码构成

• 程序控制 – 存储程序式计算机:指令按顺序存放,顺序执行

• 数据传输 – 机器以运算器为中心

Page 24: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Von Neumann机的组织结构

存储器

运算器

控制器

输入设备 输出设备

虚线:控制流

实线:数据流

串行,存储与计算分离——亦称普林斯顿结构

C语言计算机?

Page 25: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

现代计算机的组织结构特征

• 以存储器为中心

– 哈佛结构(数据与指令相分离)

– 层次化存储系统

• 互连总线

• 并行

Page 26: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

CPU

• Generic Block Diagram of a Typical CPU

Page 27: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Processor Internals

• Generic Block Diagram

Page 28: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

28

8086处理器结构

内部暂存器

IP

ES

SS

DS

CS

输入/输出控制电路

外部总线

执行部分控制电路

1 2 3 4 5 6

ALU

标志寄存器

AH AL

BH BL

CH CL

DH DL

SP

BP

SI

DI

通用寄存器

地址加法器

指令队列缓冲器

执行部件 (EU) 总线接口部件 (BIU)

16位

20位

16位

8位

Page 29: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

CPU功能与指令的执行过程(ABC)

• 算术逻辑运算

• 指令译码、执行,异常处理

• 数据暂存

• 与MEM、I/O交换数据

• 提供整个系统的定时和控制

• 响应中断请求

• 取指 – 根据PC访存读取当前要执行的指令;PC+1

• 译码 – 识别指令字中的操作类型,产生相应的控制信号

• 停机指令?

• 取操作数 – 根据指令字的地址域访存

• 执行

• 写回

Page 30: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

存储器的组织

• 存储单元按字节或字寻址

• 程序和数据顺序存放 – 数据段

– 代码段

• 读写操作以数据总线宽度为单位

0000

0001

0010

1110

1111

低端

高端

1KB存储器

地址 存储内容

0 10011010

1 01101011

1023 10100111

CPU

地址

数据

读写控制

Page 31: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

示例:ax2+bx+c,C语言程序如何执行的?

• (ax+b)x+c

– x->ACC

– x*a->ACC

– ax+b->ACC

– x*(ax+b)->ACC

– (ax+b)x+c->ACC

Page 32: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

• 计算机体系结构(Computer architecture)

– “程序员可见的机器属性”

• G. M. Amdahl,1964

• 特指机器语言程序员

• 属性:包含结构特征和功能特征

– 对物理机器的抽象

• 计算机组成(Computer org & impl)

– 也称microarchitecture

– 计算机体系结构的逻辑实现

• 包括实际机器的数据流和控制流的组成和逻辑设计等。

• 着眼于物理机器内部各事件的排序方式与控制方式,各部件的功能,以及各部件的联系。

计算机组成 vs. 计算机体系结构

Page 33: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算机系统的层次结构

Microarchitecture:also called computer organization,is

the way a given instruction set architecture (ISA) is

implemented in a particular processor.

Page 34: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算机组成 vs. 计算机体系结构

• 例一:对于IBM PC与RS6000两种机器

–高级语言程序员:可以看成是同一属性的机器。

–汇编语言程序员:是截然不同的两种机器 • 因为其指令集、数据类型、寻址技术等都完全不同。

–因此,这两种机器的体系结构是各不相同的。

• 例二:一台机器是否具备乘法指令的功能,这是一个计算机体系结构的问题。但是,实现这个乘法指令采用什么方式来实现,比如,用专门的乘法电路或连续相加的加法电路来实现,这属于计算机组成的问题。

Page 35: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

体系结构的8种属性

• 数据表示

– 硬件能直接辨识和操作的数据类型和格式

• 寻址方式

– 最小可寻址单位、寻址方式的种类、地址运算

• 寄存器组织

– 操作寄存器、变址寄存器、控制寄存器及专用寄存器的定义、数量和使用规则

• 指令系统

– 机器指令的操作类型、格式、指令间排序和控制机构

• 存储系统

– 最小编址单位、编址方式、主存容量、最大可编址空间

• 输入输出结构

– 输入输出的连接方式、处理机/存储器与输入输出设备间的数据交换方式、数据交换过程的控制

• 中断机构

– 中断类型、中断级别,以及中断响应方式等

• 信息保护

– 信息保护方式、硬件信息保护机制

Page 36: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算机体系结构分类

• 按指令集特征

– 复杂指令集(CISC)

– 精简指令集(RISC)

• 超标量(Superscalar)

• 超流水线(Superpipeline)

• 超长指令字(VLIW)

• 按并行执行特征

– 单指令流单数据流(SISD):Von Neumann machine

– 单指令流多数据流(SIMD):向量机,GPU

– 多指令流单数据流(MISD):容错

– 多指令流多数据流(MIMD):多处理器

Page 37: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算机系统的虚拟机:C语言计算机?

Page 38: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Architecture & Interfaces • Architecture: formal specification of a system’s interface

and the logical behavior of its visible resources.

API – application programming interface

ABI – application binary interface

ISA – instruction set architecture

Page 39: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Layers and Views of a Computer System

“计算机在干啥”?

Page 40: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

应用需求:高性能计算机

Page 41: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Predicts: 2X Transistors / chip every 2 years

Gordon Moore

Intel Cofounder

B.S. Cal 1950!

# o

f tr

an

sis

tors

on

an

in

teg

rate

d c

irc

uit

(IC

)

Year

Moore’s Law,1975

Page 42: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

42

Microprocessor Performance

50% improvement every year!!

What contributes to this improvement?

Source: COD5

Page 43: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Power Wall: Power Consumption Trends

• dynamic power = a activity x capacitance x voltage2 x frequency – Voltage and frequency are somewhat constant now, while

capacitance per transistor is decreasing and number of transistors (activity) is increasing

• Leakage power is also rising (function of #trans and voltage)

Source: COD5

Page 44: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

SOC Era——多核有用吗?

ITRS2008: 在今后15年内,MPSOC的计算性能将每年提升65%,到2010年达到每秒1万亿次操作。片上处理器数量将每年上升30%,到2015年将会有数千个处理器。

Page 45: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

2/21/2020 45

并行加速比:Amdahl’s Law,1967

Gene Amdahl

Computer Pioneer

对偶性原理

x↑ ,加速比↓

N ↑,加速比↑

但多核无用!?

并行的前提?

Page 46: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

古斯塔夫森定律:1988

• 多处理器/多核Speedup

= (s+p*N)/(s+p) = s+p*N = N+(1-N)*s

– “加速比随着核的数目而线性增长”

John Gustafson

AMD GPU首席架构师

Page 47: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

计算机硬件性能指标(ABC)

• 机器字长

– CPU一次能处理数据的位数

• 寄存器、ALU、总线、存储器等

– 字长:数的表示范围和精度

• 4位、8位、16位、32位、64位

• 存储容量

– 存储器可存储的二进制数据总数

• 容量=存储单元个数×存储字长

• MAR=16位,则有64K个存储单元;

• MDR=32位,则共可存储64K×32=2Mb

• 运算速度

0000

0001

0010

1110

1111

低端

高端

半字节

字节

双字

03

0347

07

078F

8F

1 01 71 81 F

Page 48: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

运算速度

• 依赖于机器的主频、操作类型、存储器访问时间等

• 主频:时钟频率(Hz),微处理器的运行速度 –主频极限?

– 2001年Intel推出P4,主频是I486的15倍,性能才提高5倍

• MIPS:每秒能执行多少百万条指令 –比较加法指令的运算速度

• FLOPS:每秒钟浮点运算次数

Page 49: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

运算速度度量单位

Computer Performance

Name FLOPS

yottaFLOPS 1024

zettaFLOPS 1021

exaFLOPS 1018

petaFLOPS 1015

teraFLOPS 1012

gigaFLOPS 109

megaFLOPS 106

kiloFLOPS 103

Page 50: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

例1:一微处理器,主频为20MHz ,请计算其主振时钟周期。若一个机器周期由2个时钟周期组成,平均每条指令用3个机器周期的时间(即“指令执行时间”),请计算该处理器的平均运行速度MIPS。

[解]

MIPS

S

S

MHz

33.361005.0

1

1

1005.0

20

11

6

6

指令执行时间平均速度

时钟频率时钟周期

Page 51: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

Measuring performance(Sys view)

• 执行时间(CPU时间、Elapsed Time)

• 峰值速度(Peak Performance)

• 负载(load)

• 开销 (Overhead)

• 利用率(Utilization Ratio)

• 饱和性能(Saturate Performance)

• 带宽(Bandwidth)

• 延迟(Latency)

• 吞吐率(Throughput)

• 加速比(Speedup)

• 效率(Efficiency)

Page 52: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

性能评测的常用方法

• 等效指令速度(吉普森(Gibson)混合法)

– 以程序中各种指令的比例为权重,加权平均

• 数据处理速率PDR(processing data rate)法

– 每条指令平均位数、每个操作数的平均位数、每条指令平均运算速度

• 基准程序法(benchmark)

– 考虑CPU、I/O结构、操作系统、编译器效率等

– 评价计算机的实际工作能力

Page 53: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

基准测试套(Benchmark)

• Dhrystone – 整数测试程序

– 一个综合性的基准测试程序

– 适于比较同一家族的机器

• Linpack – 测试向量性能和高速缓存性能

• Whetstone – 一个综合性测试程序

– 测试浮点操作、整数计算和功能调用等性能

• SPEC – System Performance Evaluation Cooperative

• TPC(Transaction Processing Council) – 计算机(服务器)事务处理性能

Page 54: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

测试执行程序

• SPEC2000系列

• Lmbench:操作系统性能 ,SGI开发

– 空系统调用时间,进程切换时间,pipe、UDP、TCP、RPC的延迟和带宽,内存、Cache、TLB的读写性能,存储映射的性能

• Webstone:Web服务性能,SGI在1995年开发

– 吞吐量(MB/s)、延迟(完成一个页面请求的时间)、每分钟传送的页面数、平均连接率、失效率

• Netperf:网络性能 – 也可用来评测DLPI(Data Link Provider Interface),Unix Domain

Socket的性能

– TCP、UDP的带宽和请求应答数

• SPECsfs97: NFS文件服务器的吞吐量和响应时间

• SPECjvm98: JAVA虚拟机的性能

• SPLASH:共享存储系统性能

Page 55: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

PC系统活动与性能分析

• Window性能分析器

• pcw2008_v186.exe:PC

• CPU_Z

• Intel Battery Life Analyzer

– 测量CPU利用率

– 识别高CPU利用率软件部件

– 测量CPU的C态驻留

– BLA的USB分析器

• Sysinternals Process Monitor

– Filemon+Regmon

– I/O(硬盘、网络)

• Intel VTune Barroso and Holzle,“The case for energy-proportional computing”. Computer,2007

Page 56: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

嵌入式实时系统RTES

• CE+CE+SE+EE

• 关键约束:响应时间可预测

Page 57: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

第一台实时计算机BINAC,1949

• BINAC (BINary Automatic Computer)

• 机载

– 未实用

• 容错

John V. Mauchly (left)

& J. Presper Eckert

Page 58: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

逻辑电路设计惯例:COD3/5附录

• Block diagram

– syntax & semantics

• Timing Diagram

– syntax & semantics

• 常用逻辑单元

• Clocking methordology

– edge-triggered

– level-triggered

• State Machine:FSM

– syntax & semantics

Page 59: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

block diagram’s semantics

• Connections between blocks represent interactions between components in a design, but

• what type of interaction? – Is it an asynchronous message (like sending a letter)?

– Is it a rendezvous communication (like making a phone call)?

– Is it a clocked update of data (as in a synchronous digital circuit)?

• Does time play a role in the interaction? – Is the interaction discrete or continuous?

Page 60: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

常用逻辑单元

• 门电路:与非、或非、非

• 锁存器Latch

• 触发器FF

• 多路选择器MUX

• 寄存器Reg

• 移位寄存器SR

• 译码器Decoder

• 计数器Counter

• 累加器ACC

• 加法器Adder

• 比较器Comparator

1 & ≥1

Page 61: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

DFF,移位,寄存

Page 62: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

n-bit Parallel Adder with Accumulator

• 累加:X=X+Y – to store one number in a register (called an

accumulator) and add a second number to it, leaving the result stored in the register.

Page 63: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

63

Combinational & Sequential Circuits

• Until now, circuits were combinational – when inputs change, the

outputs change after a while (time = logic delay thru circuit)

Combinational

Circuit Inputs Outputs

• We want the clock to act like a start and stop signal – a “latch” is

a storage device that separates these circuits – it ensures that

the inputs to the circuit do not change during a clock cycle

Combinational

Circuit

Outputs

Combinational

Circuit

Combinational

Circuit

Latch Latch

Inputs

Clock Clock

Page 64: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

timing methodology • Complex Timing Diagram

• clocking methodology – edge-triggered:简单,不一定最好

• instantaneous

– level-triggered:complex • noninstantaneous:data races can easily occur!

– use two-phase clocking scheme:用两个不重叠的时钟化解

Page 65: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

同步、异步、工作时钟频率

Page 66: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

离散事件系统的行为:Automata/Machines

• Automata:事件-动作模型 – 将系统的时态行为表示为状态及其转换

• 状态:“系统在特定时间点的condition”(“标识”?)

– 5元组:<Q, ∑, δ: Q×∑→Q, q0, F> • 接收状态/非接收状态

• 一个输入字:字符串(trace)。字母表∑,所有字的集合∑*

• 一种语言:某些字的集合, 为∑* 的一个子集

– 确定:转换(活动状态唯一?),初态唯一? • For a given word w the DFA has a unique run.

• A run accepting if last state qn ∈ F .

– 有限:状态数、语言长度 • FSM: Finite State Machine

• Buchi机:语言长度有限

– 等价:接收相同的输入串

• 自动机组合:多个FA独立运行时的系统行为 – 笛卡尔积

Page 67: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

DFA(确定有限自动机):State Machine

• 强调“Sequential Machines” – 多steps(多时钟周期)

• FSM:6元组,带输出 – Mealy型(George Mealy,1955)

• <S, I, O, f: S×I→S, h: S×I→O,q0>

– Moore型(Edward Moore,1956) • <S, I, O, f: S×I→S, h: S→O ,q0 >

• 完全因果:“one-step delay”

Page 68: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

FSM的实现结构:同步状态机实现

Page 69: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

State Machine的应用与扩展

• UML State diagram

– A state is a description of the status of a system that

is waiting to execute a transition.

– A transition is a set of actions to be executed when a

condition is fulfilled or when an event is received.

• Communicating finite-state machine

– a model of concurrent processes

• Communicating Hierarchical State Machine

– the coexistence of hierarchy and concurrency

• Turing Machine的FSM?

Page 70: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

State diagram for a turnstile

• representations

– computation

– communication • synchronous model

Page 71: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

小结

• 计算机系统由软件和硬件组成

• 计算机系统存在层次化结构

• 计算机组成 vs. 计算机体系结构

• Von Neumann机

– 计算机硬件系统由五大部件组成

– 信息以二进制表示

– 指令由op和addr构成

– “存储程序控制顺序执行”

• 指令的执行过程

• 硬件系统技术指标

– 主频与计算性能的关系

Page 72: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

作业

• 作业 – COD4:1.14,1.16

– 简答题(选一)

• 冯机架构中指令和数据都存储于存储器中,系统执行时如何区分?

• “计算机组成”与“计算机系统结构”的关系?

• 比较Amdahl’s Law和古斯塔夫森定律

• 推荐文献 – Peter Naur, Turing Lecture: Computing Versus Human

Thinking, Comm. ACM, vol. 50, no. 1, pp. 85-94, Jan 2005.

– CCC,Arch2030: A Vision of Computer Architecture

Research over the Next 15 Years,ISCA2016

Page 73: 计算机组成原理 第一章 概论 - USTCstaff.ustc.edu.cn/~llxx/cod/courseware/01_generality.pdf · 2020-02-21 · •Meaning,Messages,Information? –the central dogma

[email protected] 73/94