作者b10007034 (Warren)
看板Grad-ProbAsk
标题[理工] 106 清大计系 FGMT
时间Sun Dec 30 18:44:57 2018
这题拿来复习FGMT很棒,有一些FGMT和thread的观念就可以了
回顾thread组成,有自己的
1.PC
2.stack
3.reg.
4.thread ID,...
回顾一下FGMT特性
1.类似RR
2.CPU必须在每个Cycle替换另一个thread
由上面两点得到一优点一缺点
pros:thread够多,可以隐藏stall
cons:平均turnaround time上升(对於Hard Real time OS可能是不适用的)
a.考虑thread1执行到branch, th1=thread1 stl=stall
IF │ID │EX │MEM│WB
cycle1 th1│
cycle2 stl│th1│
cycle3 stl│stl│th1
cycle4 th1│stl│stl│th1
此图表示只有一个thread时遇到branch的情形
cycle1 th1
cycle2 th2 th1
cycle3 th3 th2 th1
cycle4 th1 th3 th2 th1
th2 th1 th3 th2 th1
正常来说,th1会有control hazard,但因为这题的设计,IF只要遇到branch就会stall,
所以stall刚好被th2,th3盖住了。
每一个pipeline stage都是满的,故最少需要3个
b.
考虑th1有以下instruction
add $1,$2,$3
or $2,$1,$3
发生RAW
IF │ ID│ EX│MEM│WB
cycle1 th1
cycle2 th1 th1
cycle3 th1 stl th1
cycle4 th1 stl stl th1
cycle5 th1 stl stl stl th1
此图表示只有一个thread遇到data hazard的时候,会一直stall到把结果写回
register为止(instruction走到WB)
cycle1 th1
cycle2 th2 th1
cycle3 th3 th2 th1
cycle4 th4 th3 th2 th1
cycle5 th1 th4 th3 th2 th1
正常来说,在IF&ID时会检查(与hazard detection设计不同)到同一个thread的reg而产生
stall,直到写回去为止,
顺带一提的是,这边的reg.没有先写後读,因此同上需要总共四个thread保证
no flow dependence。
c.Yes, 与(a)解释一样
d.No
IF │ ID │EX0~EX7│MEM0~MEM1│WB
th1 stl0 stl 1~8 stl 9~10 th1
th1 th2 th3~10 th11~12 th1
需要共12个thread保证 no flow dependence。
结论:由单一时脉图(详看张凡课本图示)可以看到,原本由其中一个thread造成的stall
,可以切换另一个thread隐藏起来,而这个优点原本课本不清晰的解说,这题可以很清楚表
达出来。
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.161.164.94
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Grad-ProbAsk/M.1546166700.A.4C0.html
1F:推 wacheck: 想请问一下,thread在IF阶段就有了吗?拍谢一直想到os的部12/30 19:49
thread也会翻译成instruction
2F:→ wacheck: 份,但一直连接不上来12/30 19:49
3F:→ wacheck: 然後d小题我觉得是11个@@ 因为ex阶段到wb阶段有8+2+1个th12/30 19:52
图应该很明显了
4F:→ wacheck: 要移除,但不确定是不是我想法太简陋 ORZ12/30 19:52
5F:推 wacheck: 第b小题只有4个stage@@ 而且分支也要考虑?个人认为因为没12/30 19:57
a小题已经说明3thread可以保证不会有control hazard了,所以b的4可以包含a
6F:→ wacheck: forward所以decode阶段到wb阶段都要停 所以两个thread12/30 19:58
7F:→ wacheck: 若再考虑branch的话就3+2=5 总共五个12/30 19:58
※ 编辑: b10007034 (1.161.164.94), 12/30/2018 20:26:45
※ 编辑: b10007034 (223.140.232.129), 12/31/2018 10:24:22
※ 编辑: b10007034 (223.140.232.129), 12/31/2018 10:43:23
※ 编辑: b10007034 (1.161.165.108), 12/31/2018 10:49:18
※ 编辑: b10007034 (1.161.165.108), 12/31/2018 10:51:18
8F:推 jojoboy0115: 好猛,感谢大大的解说! 12/31 22:06
9F:推 wacheck: 感谢回覆 01/01 09:39
10F:推 dumpling1234: 推 01/25 14:35
11F:推 Kanaheipapa: 谢谢大大!! 02/08 12:34
12F:推 ff00662299: 受益匪浅,谢谢! 11/20 17:22
13F:推 j12345453: 请问C小题 12/21 14:56
14F:→ j12345453: 因为有明讲了Ex stage是占8个Stage 12/21 14:56
15F:→ j12345453: 大家怎麽会直接认定Machine2也是在第三Stage就做完Br 12/21 14:56
16F:→ j12345453: anch? 12/21 14:56
17F:→ j12345453: 我一开始就误以为是要整个Ex阶段结束8个Stage Branch 12/21 14:56
18F:→ j12345453: 才完成? 12/21 14:56
19F:→ j12345453: 有人跟我想法一样吗 12/21 14:56