当前位置:网站首页>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:流水线的相关计算

边栏推荐
- Alu logic operation unit
- Simply sort out the types of sockets
- 1996. number of weak characters in the game
- Configuration and startup of kubedm series-02-kubelet
- In this indifferent world, light crying
- Personal developed penetration testing tool Satania v1.2 update
- 【Jailhouse 文章】Jailhouse Hypervisor
- 用STM32点个灯
- [practical skills] technical management of managers with non-technical background
- Implement a fixed capacity stack
猜你喜欢

SAP method of modifying system table data

【Jailhouse 文章】Look Mum, no VM Exits

Web APIs DOM node

剑指 Offer 09. 用两个栈实现队列

【云原生】微服务之Feign自定义配置的记录

Solution to the palindrome string (Luogu p5041 haoi2009)

Typical use cases for knapsacks, queues, and stacks

shared_ Repeated release heap object of PTR hidden danger

Fried chicken nuggets and fifa22

游戏商城毕业设计
随机推荐
7. Processing the input of multidimensional features
SAP-修改系统表数据的方法
Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
Maximum number of "balloons"
Daily question 1688 Number of matches in the competition
kubeadm系列-02-kubelet的配置和启动
Analysis of backdoor vulnerability in remote code execution penetration test / / phpstudy of national game title of national secondary vocational network security B module
R language [import and export of dataset]
Wazuh开源主机安全解决方案的简介与使用体验
【Jailhouse 文章】Jailhouse Hypervisor
Use of room database
浅谈JVM(面试常考)
Daily question - longest substring without repeated characters
Fried chicken nuggets and fifa22
Transform optimization problems into decision-making problems
Wazuh開源主機安全解决方案的簡介與使用體驗
[practical skills] technical management of managers with non-technical background
Smart construction site "hydropower energy consumption online monitoring system"
[cloud native] record of feign custom configuration of microservices
卷积神经网络——卷积层