[理工] 106 清大计系 FGMT

楼主: b10007034 (Warren)   2018-12-30 18:44:57
这题拿来复习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隐藏起来,而这个优点原本课本不清晰的解说,这题可以很清楚表
达出来。
作者: wacheck (94不爱喝水)   2018-12-30 19:49:00
想请问一下,thread在IF阶段就有了吗?拍谢一直想到os的部份,但一直连接不上来然后d小题我觉得是11个@@ 因为ex阶段到wb阶段有8+2+1个th要移除,但不确定是不是我想法太简陋 ORZ第b小题只有4个[email protected]@ 而且分支也要考虑?个人认为因为没forward所以decode阶段到wb阶段都要停 所以两个thread若再考虑branch的话就3+2=5 总共五个
作者: jojoboy0115 (jojo)   2018-12-31 22:06:00
好猛,感谢大大的解说!
作者: wacheck (94不爱喝水)   2017-01-01 09:39:00
感谢回复

Links booklink

Contact Us: admin [ a t ] ucptt.com