[理工] 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