1 / 36

Chapter 8 หน่วยความจำแคช Cache memory

Chapter 8 หน่วยความจำแคช Cache memory. เนื้อหา. Introduction to cache memory Hit rate/Miss rate Write Policy Replacement algorithm Mapping function. What is Cache memory. A high speed memory closely connected to the processor. Multilevel cache. ทำไมต้อง cache memory?.

Download Presentation

Chapter 8 หน่วยความจำแคช Cache memory

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8หน่วยความจำแคชCache memory

  2. เนื้อหา Introduction to cache memory Hit rate/Miss rate Write Policy Replacement algorithm Mapping function

  3. What is Cache memory • A high speed memory closely connected to the processor

  4. Multilevel cache

  5. ทำไมต้อง cache memory? • หน่วยความจำหลักทำงานได้ช้ามากเมื่อเทียบกับซีพียู • ก๊อปปี้ค่าในหน่วยความจำหลักมาใส่ในแคชก่อนแล้วค่อยให้ซีพียูอ้างถึงหน่วยความจำแคชด้วยความเร็วสูง • โปรแกรมส่วนใหญ่เมื่อใช้หน่วยความจำตำแหน่งหนึ่งแล้ว มักจะอ่านค่าหน่วยความจำตำแหน่งนั้นๆ อีกหลายๆ ครั้ง (locality of reference)

  6. Locality of reference :Example void main (void) { int table[1024]; for (i= 0; i<100000; i++) k = i % 26; c = table[k] printf(“%d”,c); }

  7. นิยามต่างๆ ของ Cache • Hit : โพรเซสเซอร์พบข้อมูลในแคช • Miss : โพรเซสเซอร์ไม่พบข้อมูลในแคช • Hit rate จำนวนครั้งที่พบข้อมูลในแคช จำนวนการแอกเซสหน่วยความจำแคชทั้งหมด

  8. Write policy • Write back • เขียนข้อมูลลงในแคชเท่านั้น แล้วค่อยไปเขียนลงหน่วยความจำหลักหลังยกเลิกการใช้แคชบล๊อกนั้นๆ • ประสิทธิภาพสูง - ไม่เหมาะกับระบบมัลติโพรเซสเซอร์ • Write through • ทุกครั้งที่เขียนข้อมูลในแคช ให้เขียนข้อมูลลงในหน่วยความจำหลักด้วย • ประสิทธิภาพต่ำกว่า แต่สามารถใช้กับระบบมัลติโพรเซสเซอร์ได้

  9. Multiprocessor

  10. Unified VS Separated cache • Unified cache • Keeping both program and data • More simple and higher hit rate • Separate cache • Keeps program in code cache • Keeps data in data cache • Suitable for Von-Neuman architecture

  11. Unified cache

  12. Separated cache

  13. Von-Neumann architecture and Cache

  14. Pentium Pro cache

  15. Replacement algorithm • แคชมีขนาดเล็ก เมื่อเทียบกับหน่วยความจำหลัก • ต้องเอาของเก่าออกจากแคชเพื่อใส่ข้อมูลที่ต้องการ • Least Recently used (LRU) • Least Frequently Used (LFU) • First-in-First-Out (FIFO)

  16. Cache mapping • Direct mapping • Fully associative mapping • Set associative mapping

  17. Direct mapping • ง่ายต่อการสร้าง • ใช้จำนวนบิตของ tag field น้อย • บล๊อก 0, 128, 256, … , 3968 ไม่สามารถอยู่ในหน่วยความจำพร้อมๆ กันได้

  18. Direct mapping

  19. Direct mapping

  20. Direct mapping

  21. Fully associative mapping • หน่วยความจำบล๊อกใดๆ ก็ตามสามารถอยู่ในแคชตำแหน่งใดก็ได้ • สิ้นเปลืองจำนวนเกทในการสร้างสูงมาก • จำนวนบิตที่ต้องการใน tag field มีจำนวนมาก

  22. Fully associativemapping

  23. Fully associativemapping

  24. Set-associative mapping • จับข้อดีของ Fully-associative และ Direct mapped มารวมกัน • สามารถออกแบบให้มีหลาย way ที่สามารถเก็บข้อมูล

  25. 2-way Set associative mapped

  26. 2-way Set associative mapped

  27. 4-way set associative mapped

  28. 4-way set associative mapped

  29. Processor cache comparison

  30. Cache of Intel Celeron

  31. Cache of Intel Celeron

  32. Cache of AMD Athlon

  33. Cache of AMD Athlon

  34. Homework • จงออกแบบหน่วยความจำแคชของโพรเซสเซอร์ที่สามารถอ้างหน่วยความจำได้ 64 กิโลไบต์ โดยกำหนดให้หน่วยความจำแคชมีขนาด 512 ไบต์ • จงออกแบบหน่วยความจำแคชในรูปแบบต่อไปนี้ • Direct mapped • Fully associative • 2-way set associative • 4-way set associative

  35. จบ บทที่ 8

More Related