作者sitos (麥子)
站內hardware
標題Re: [關公] 關公面前耍大刀!淺談1995~1998電腦界變化.
時間Wed May 2 15:19:53 2007
※ 引述《sitos (麥子)》之銘言:
: 標題: Re: [關公] 關公面前耍大刀!淺談1995~1998電腦界變化.
: 時間: Mon Apr 30 15:25:39 2007
: Instruction Cache 的定址方式和 Data Cache 一樣,都是用 mapping 的。
: 把後段的位址取出來作 hash ,前段當作 tag 。
:
: Trace Cache 是將一段時間之內執行過的程式碼整份存起來,
: 包括有重覆執行的 loop 或 branch 也會存好幾份起來。
:
: 前者主要是靠著一次帶進一個 block 的 instructions ,
: 來減少存取其它 instruction 時的 miss (讀前一個,後一個也一起讀進來)。
: 因此遇到 branch 時破壞 spatial locality 會導致 hit rate 下降。
:
: 後者則是可以適應程式本身的行為,只要同一段程式的 control path 改變不大,
: Trace cache 的 hit rate 會非常高,通常會把一段常執行的程式整個存進去。
:
: 減少 penalty 的部份是因為,就算 prediction taken ,拿不到下一個 instruction ,
: 也是白搭。因為沒有 locality 因此 instruction 可能不在 I-cache 裡,
: 因此 trace cache 可以有效處理這樣的問題。
:
: 現在的 processor 的 cache 架構都非常複雜,因為 miss penality 太高,
: 一般而言會有 L1 I/D-cache,
: L2 U-cache,
: Trace cache,
: Victim Cache,
: Write buffer
:
: 反正只要能提高 hit rate 的手段幾乎都會用上去。
: 不過我也不知道 code cache 是什麼。
:
: --
:
: --
: ※ 發信站: 批踢踢實業坊(ptt.cc)
: ◆ From: 140.112.31.132
: 推 GreatShot:所以說CPU會先去TraceCache找後才去Inst. Cache找囉? 04/30 17:31
: → GreatShot:還是說他們作用的地方不同呢? 04/30 17:33
: → GreatShot:感謝解釋~~ 04/30 17:33
: 推 leav:TraceCache是預測branch用的,跟InstructionCache用途不同 04/30 23:51
Trace cache 與 branch predictor 是分開的, Trace cache 不是作 predictor 用的。
Trace cache 是用來彌補 branch taken 時因為 data spatial locality 不足,
以致於 Instruction cache hit rate 不夠高與 fetch 不夠快的問題而提出的。
: 推 dolphinus:"執行過的程式碼整份存起來"... 我的天啊... 05/01 00:59
: → dolphinus:沒看過有人這樣解釋 trace cache 的... 05/01 01:00
你沒看過,那也許我就是第一個讓你看到的人。
如果我說的不對請盡量指正,畢竟有可能是我學藝不精,誤導大家。
在
"Trace Cache: a Low Latency Approach to High Bandwidth Instruction Fetching"
(Tech Report 1310, CS DEpt., Univ. of Wisc. -Madison Apr 1996)
一文
setcion 1.1 當中這樣寫
We propose a special instruction cache which captures
dynamic instruction sequences. This structure is called a
trace cache because each line stores a snapshot, or trace,
of the dynamic instruction stream, as shown in Figure 2. A
trace is a sequence of at most n instructions and at most m
basic blocks starting at any point in the dynamic instruction
stream. The limit n is the trace cache line size, and m is
the branch predictor throughput. A trace is fully specified
by a starting address and a sequence of up to m-1 branch
outcomes which describe the path followed. The first time a
trace is encountered, it is allocated a line in the trace cache.
The line is filled as instructions are fetched from the instruction
cache. If the same trace is encountered again in the
course of executing the program, i.e. the same starting address
and predicted branch outcomes, it will be available in
the trace cache and is fed directly to the decoder. Otherwise,
fetching proceeds normally from the instruction cache.
我沒有整篇看完,畢竟是 '96 的老東西了。我之前回文是照印象回的,
因為在看別的 paper 時有提到,因為有人質疑特別去翻舊 paper 出來看。
依照這一段的講法
The limit n is the trace cache line size, and m is
the branch predictor throughput.
可以看出來即使有 trace cache 一樣需要有 branch predictor ,
因此 trace cache 應該不是用來作 branch prediction ,
而只是在有 m prediction throughput 時讓 instruction fetching 夠快的方法。
另外
The first time a
trace is encountered, it is allocated a line in the trace cache.
The line is filled as instructions are fetched from the instruction
cache. If the same trace is encountered again in the
course of executing the program, i.e. the same starting address
and predicted branch outcomes, it will be available in
the trace cache and is fed directly to the decoder. Otherwise,
fetching proceeds normally from the instruction cache.
第一次碰到 trace 的時候,會將 instruction 從 instruction cache 存到
Trace cache 當中。當同一個 trace 再被遇到的時候,就會直接從 Trace cache
直接把 instruction 拿給 processor 來 decode 。
其它不再 trace cache 當中的 instruction 則還是從 instruction cache 當中拿。
事實上這就是把一段執行過的程式碼存起來,等又碰到的時候再拿出來用。
當然也有可能是因為我英文太爛看錯了,如果講得不對麻煩幫忙指出來。
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.31.132
推 pizzwwc:uh...原PO是資工的 05/02 15:36
推 dolphinus:總算遇到有唸點書的,有點感動.. 05/02 19:12