10 Performance of Cache Memory
10 Performance of Cache Memory
Computer Architecture
Prepared By :
𝑪𝒄𝑺𝒄 + 𝑪𝒎𝑺𝒎
𝑪𝒔 =
𝐒𝐜 + 𝐒𝐦
: حيث ان
Cs: Average cost of system per byte , (main memory plus cache)
H: hit ratio
1
Computer Architecture
M: Miss ratio
Solution)
Ts= HTc + (1-H)Tm
Ts= 0.9 * 100 + (1-0.9)*1000
Ts = 190 ns
Solution)
Ts= HTc + MTm
Ts= HTc + (1-H)Tm
Ts= HTc + Tm - HTm
Ts –Tm = H(Tc –Tm)
𝑻𝒔 − 𝑻𝒎
𝑯=
𝑻𝒄 − 𝑻𝑴
250−1500
𝐻=
150−1500
−1250
𝐻=
−1350
𝑯 = 𝟎. 𝟗𝟐 this computer is perfect
2
Computer Architecture
find Ts?
Solution:
Ts= HTc + (1-H)Tm
Ts= 0.7 * 175*10-9 + (1-0.7)*900
Ts= 392.5 ns
Example(4): Assume Tc=300 sec , Tm=1800 sec and Ts=1450 sec, find Hit
ratio?
Solution)
Ts= HTc + MTm
Ts= HTc + (1-H)Tm
Ts= HTc + Tm – HTm
Ts –Tm = H(Tc – Tm)
𝑻𝒔−𝑻𝒎
𝑯 = 𝑻𝒄−𝑻𝒎
1450 − 1800
𝐻=
300 − 1800
−350
𝐻=
−500
𝑯 = 𝟎. 𝟕 this computer isn’t perfect
) سريعTc( ) انه كلما كان زمن الوصول للمعلومة في الكاش4( ) والمثال2( نالحظ من خالل المثال
قريب من الواحد وكانت فرصة العثور على المعلومة اكبر وكانت الحاسبةHit ratio كلما كان الـ
. perfect مثالية
3
Computer Architecture
Cache Mapping
Mapping Technique
4
Computer Architecture
1-Associative mapping
2-Direct mapping
3-Set-associative mapping
The following diagram illustrates the mapping process:
5
Computer Architecture
NOTES
: بأستخدام القانون التاليmain memory الموجودة في الـblocks يتم حساب عدد الـ
𝒔𝒊𝒛𝒆 𝒐𝒇 𝒎𝒆𝒎𝒐𝒓𝒚 𝑺𝒎
1. No. of block in main memory = = 𝑺𝒃𝒍𝒐𝒄𝒌
𝒔𝒊𝒛𝒆 𝒐𝒇 𝒃𝒍𝒐𝒄𝒌
: بأستخدام القانون التاليcache memory الموجودة في الـslots يتم حساب عدد الـ
𝒔𝒊𝒛𝒆 𝒐𝒇 𝒄𝒂𝒄𝒉𝒆 𝑺𝒄
2. No. of block in cache memory = = 𝑺𝒃𝒍𝒐𝒄𝒌
𝒔𝒊𝒛𝒆 𝒐𝒇 𝒔𝒍𝒐𝒕
6
Computer Architecture
Solution)
𝑠𝑖𝑧𝑒 𝑜𝑓 𝑚𝑒𝑚𝑜𝑟𝑦 32𝑘
1. No. of block in main memory = = = 215/ 24
𝑠𝑖𝑧𝑒 𝑜𝑓 𝑏𝑙𝑜𝑐𝑘 16
=211=2k
𝑠𝑖𝑧𝑒 𝑜𝑓 𝑐𝑎𝑐ℎ𝑒 4𝑘
2. No. of block in cache memory = = = 212/24 = 28= 256
𝑠𝑖𝑧𝑒 𝑜𝑓 𝑠𝑙𝑜𝑡 16
Solution)
𝑠𝑖𝑧𝑒 𝑜𝑓 𝑚𝑒𝑚𝑜𝑟𝑦 64𝑘
1. No. of block in block memory = = = 216/23=213=8k
𝑠𝑖𝑧𝑒 𝑜𝑓 𝑏𝑙𝑜𝑐𝑘 8
𝑠𝑖𝑧𝑒 𝑜𝑓 𝑐𝑎𝑐ℎ𝑒 1𝑘
2. No. of block in cache memory = = =210/23=27=128
𝑠𝑖𝑧𝑒 𝑜𝑓 𝑠𝑙𝑜𝑡 8