当前位置:网站首页>1.14 - 流水线
1.14 - 流水线
2022-07-05 05:44:00 【是李黏黏鸭】
目录
一、流水线的概念
- 所谓流水线,是指程序在执行时, 多条指令重叠进行操作的一种准并行处理实现技术。
二、流水线工作流程
- 一条指令在执行的时候,通常可以分为多个阶段进行,每个阶段由不同的部件来实现;
- 以分为3个阶段为例: 取指、分析、执行;
三、未使用流水线执行指令

1、执行过程
- 没有使用流水线时,当第一条指令的取指部件进行取指时,分析部件和执行部件是空闲的;
- 当取指部件取指完成后,分析部件开始分析指令,这时取指部件和执行部件是空闲的;
- 当分析部件执行完成后,执行部件开始编译后执行指令,此时取指部件和分析部件又是空闲的;
2、结论
- 由此可知,不使用流水线执行指令时,取指部件,分析部件,执行部件的利用率并不高;
四、使用流水线执行指令

1、执行过程
- 当第一条指令开始执行时,取指部件开始工作,分析部件和执行部件空闲;
- 当第一条指令取指完成后,分析部件开始工作;此时取指部件就空闲出来了,此时就可以去取第二条指令了;
- 当第一条指令分析完成后,执行部件开始工作;此时分析部件就空闲出来了,此时就可以对刚取的第二条指令进行分析了;并且由于此时第二条指令取指完成了,所以此时取指部件又空闲出来了,所以此时可以去取第三条指令了;
2、结论
- 由此可见,使用流水线执行指令,能有效提高部件的使用率,也就有效的提高了指令的执行效率;
五、流水线周期
- 在指令中各个阶段, 执行时间最长的这一阶段的时间,就是流水线的周期;
解析:(1)例如流水线上的工人,三个人合作完成一件物品;第一个人需要2秒,第二个人需要4秒,第三个人需要1秒;(2)如果此时将完成这件物品的周期定为1秒,那么第一、第二个人就无法完成自己的工作;(3)只有将周期定为4秒的时候,这三个人才都能完成自己的工作;(4)所以我们一般将 完成一件物品 执行所需时间最长的阶段的时间,定为周期,例子中的周期是4秒;
六、流水线计算公式

- 单条指令所需时间+(n-1)*(流水线周期)
(1)由图可知,执行第一条指令时,需要3个阶段;(2)执行完第一条指令时,第二条指令zh已经执行完分析阶段了,只需要有一个执行阶段就可完成第二条指令的执行;(3)当第二条指令执行完成时,第三条指令已经执行完分析阶段了,也只需要一个执行阶段就可以完成第三条指令的执行;(4)所以执行n条指令时,只需要用单条指令的时间(第一条指令的三个阶段的时间的和)+(n-1)条指令执行所需要的时间;
- 注意:n表示指令的数量;
七、流水线的吞吐率

八、考法1:流水线的相关计算

边栏推荐
- Daily question - Search two-dimensional matrix PS two-dimensional array search
- Csp-j-2020-excellent split multiple solutions
- Bit mask of bit operation
- Codeforces Round #715 (Div. 2) D. Binary Literature
- 剑指 Offer 05. 替换空格
- 2020ccpc Qinhuangdao J - Kingdom's power
- Gbase database helps the development of digital finance in the Bay Area
- Time complexity and space complexity
- Annotation and reflection
- SAP-修改系统表数据的方法
猜你喜欢
全排列的代码 (递归写法)
A new micro ORM open source framework
API related to TCP connection
2017 USP Try-outs C. Coprimes
F - Two Exam(AtCoder Beginner Contest 238)
Personal developed penetration testing tool Satania v1.2 update
Introduction et expérience de wazuh open source host Security Solution
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Gbase database helps the development of digital finance in the Bay Area
SAP method of modifying system table data
随机推荐
Web APIs DOM node
[practical skills] how to do a good job in technical training?
注解与反射
SSH password free login settings and use scripts to SSH login and execute instructions
Bit mask of bit operation
Convolution neural network -- convolution layer
Codeforces Round #732 (Div. 2) D. AquaMoon and Chess
卷积神经网络简介
中职网络安全技能竞赛——广西区赛中间件渗透测试教程文章
Wazuh开源主机安全解决方案的简介与使用体验
A misunderstanding about the console window
Sword finger offer 35 Replication of complex linked list
Pointnet++ learning
How to adjust bugs in general projects ----- take you through the whole process by hand
kubeadm系列-02-kubelet的配置和启动
用STM32点个灯
Software test -- 0 sequence
CCPC Weihai 2021m eight hundred and ten thousand nine hundred and seventy-five
网络工程师考核的一些常见的问题:WLAN、BGP、交换机
R语言【数据集的导入导出】