要示範關聯式cache中一個區塊的放置,讓我們假設我們有一個區塊大小為4 bits。 ![image](https://hackmd.io/_uploads/SJIotmqnp.png) ## Possible Associativity Structures ![image](https://hackmd.io/_uploads/HJXZqQqhT.png) ## Associativity Example 根據提供的資訊,比較Direct mapped, 2-way set associative, fully associative這三種結構。 Block access sequence: 0, 8, 0, 6, 8 ⧫ Direct mapped ![image](https://hackmd.io/_uploads/H1gR9om9np.png) ⧫ 2-way set associative ![image](https://hackmd.io/_uploads/r1baom92p.png) ⧫ Fully associative ![image](https://hackmd.io/_uploads/Hkqy2Xq26.png) 在cache的增加associative會降低cache misses這一點上是正確的。當cache的associative增加時,相同的memory 區塊就有更多的擺放位置,減少了發生置換的機會,因此cache misses通常會下降。但是,隨著associative的增加,這種效益會遭遇遞減的情況。換句話說,當associative達到一定程度時,再進一步增加associative對cache misses的改善效果會變得越來越小。 以下是模擬結果,分別是不同associative下的cache misses: 1-way set associative: 10.3% 2-way set associative: 8.6% 4-way set associative: 8.3% 8-way set associative: 8.1% 隨著associative增加,cache misses逐步降低。從1-way set associative到8-way set associative,cache misses逐步下降。然而,從2路到4路和從4路到8路,cache misses的改善效果變得越來越小。這就是所謂的「遞減效應」,顯示了增加associative對cache misses改善的效果會有所遞減。