Bài giảng Kiến trúc máy tính - Bộ nhớ và các thiết bị lưu trữ

pdf 86 trang hapham 340
Bạn đang xem 20 trang mẫu của tài liệu "Bài giảng Kiến trúc máy tính - Bộ nhớ và các thiết bị lưu trữ", để tải tài liệu gốc về máy bạn click vào nút DOWNLOAD ở trên

Tài liệu đính kèm:

  • pdfbai_giang_kien_truc_may_tinh_bo_nho_va_cac_thiet_bi_luu_tru.pdf

Nội dung text: Bài giảng Kiến trúc máy tính - Bộ nhớ và các thiết bị lưu trữ

  1. Kiến trúc máy tính Bộ nhớ và các thiết bị lưu trữ NGUYỄN Ngọc Hoá Bộ môn Hệ thống thông tin, Khoa CNTT Trường Đại học Công nghệ, Đại học Quốc gia Hà Nội 13 September 2011 Hoa.Nguyen@vnu.edu.vn
  2. Nội dung  Khái niệm  Bộ nhớ chính  Bộ nhớ cache  Bộ nhớ ngoài (các thiết bị lưu trữ) Tham khảo chương 4,5,6 của [1] Computer Architecture –Department of Information Systems @ Hoá NGUYEN 2
  3. 1. Khái niệm  Bộ nhớ: thiết bị có thể bảo quản và khôi phục một thông tin  Từ nhớ: tập bits có thể được đọc hay ghi đồng thời  Các kiểu vật liệu nhớ:  Bán dẫn – semiconductor (register, cache, bộ nhớ chính, )  Từ - mangnetic (đĩa mềm, đĩa cứng, )  Optic (CD-ROM, DVD-ROM)  Computer Architecture –Department of Information Systems @ Hoá NGUYEN 3
  4. Đặc điểm  Vị trí  Dung lượng  Đơn vị truyền  Kiểu truy cập  Hiệu năng  Kiểu vật liệu  Đặc trưng vật liệu  Tổ chức Computer Architecture –Department of Information Systems @ Hoá NGUYEN 4
  5. Đặc điểm  Vị trí  CPU  Internal  External  Dung lượng  Đo theo từ nhớ  Số lượng từ nhớ  Đơn vị truyền  Bên trong: phụ thuộc vào độ rộng bus dữ liệu  Bên ngoài: block(>từ nhớ)  Đơn vị có thể đánh địa chỉ được Computer Architecture –Department of Information Systems @ Hoá NGUYEN 5
  6. Đặc điểm  Kiểu truy cập  Tuần tự: VD băng từ  Trực tiếp:  Mỗi 1 block có 1 địa chỉ duy nhất  Truy cập = cách nhảy đến vùng lân cập và tìm tuần tự  Thời gian truy cập vào vị trị hiện tại hiện tại và trước đó  VD: HardDisk, Floppy Disk,  Ngẫu nhiên:  Mỗi địa chỉ xác định chính xác một vị trí  Thời gian truy cập không phụ thuộc vào vị trí cũng như lần truy cập trước  VD: RAM,  Kết hợp:  Một từ được định vị thông qua việc sử dụng một phần nội dung của từ đó  Thời gian truy cập không phụ thuộc vào vị trí cũng như lần truy cập trước  VD: cache, Computer Architecture –Department of Information Systems @ Hoá NGUYEN 6
  7. Đặc điểm  Chiến thuật phân cấp bộ nhớ: How much? How fast? How expensive?  Registers  L1 Cache  L2 Cache  Main memory  Disk cache  Disk  Optical  Tape Computer Architecture –Department of Information Systems @ Hoá NGUYEN 7
  8. Đặc điểm  Hiệu năng:  Thời gian truy cập: khoảng thời gian từ khi gửi địa chỉ cho đến khi thu được dữ liệu trọn vẹn  Thời gian chu trình nhớ - Memory Cycle Time:  Thời gian bộ nhớ đòi hỏi để “hồi phục” trước lần truy cập kế tiếp  = access + recovery  Tốc độ chuyển dữ liệu  Kiểu vật liệu:  Semiconductor :RAM  Magnetic: Disk & Tape  Optical: CD & DVD  Others: Bubble, Hologram Computer Architecture –Department of Information Systems @ Hoá NGUYEN 8
  9. Đặc điểm  Đặc trưng vật liệu:  Phân rã - Decay  Dễ thay đổi - Volatility  Có thể xoá được - Erasable  Năng lượng tiêu thụ  Tổ chức:  Cách thức sắp xếp các bits trong một từ  Thường không rõ ràng  VD: interleaved Computer Architecture –Department of Information Systems @ Hoá NGUYEN 9
  10. 2. Bộ nhớ chính  Bộ nhớ bên trong máy tính  Semi-conductor  Truy cập ngẫu nhiên  Kiểu:  RAM- Random Access Memory: lưu giữ những dữ liệu tạm thời  ROM – Read Only Memory: lưu giữ thông tin cố định Computer Architecture –Department of Information Systems @ Hoá NGUYEN 10
  11. Read Only Memory (ROM)  Lưu giữ thông tin cố định - permanent storage, nonvolatile  Microprogramming  Library subroutines  Systems programs (BIOS)  Function tables  Kiểu:  Written during manufacture  Very expensive for small runs  Programmable (once)  PROM  Needs special equipment to program  Read “mostly”  Erasable Programmable (EPROM)  Erased by UV  Electrically Erasable (EEPROM)  Takes much longer to write than read  Flash memory  Erase whole memory electrically Computer Architecture –Department of Information Systems @ Hoá NGUYEN 11
  12. RAM  DRAM – Dynamic RAM  Bits được lưu trữ trong các tụ điện  Đơn giản, kích thước bé, giá thành rẻ  Chậm, cần 1 chu trình làm tươi ngay cả khi đã được cung cấp nguồn  SRAM – Static RAM  Bits được lưu trong các flip-flops  Không cần làm tươi, có tốc độ cao  Phức tạp, kích thước to hơn, giá thành cao Computer Architecture –Department of Information Systems @ Hoá NGUYEN 12
  13. Dynamic RAM  Đường địa chỉ được kích hoạt khi đọc/ghi bit  Transistor switch closed (current flows)  Ghi  Voltage to bit line  High for 1 low for 0  Then signal address line  Transfers charge to capacitor  Đọc  Address line selected  transistor turns on  Charge from capacitor fed via bit line to sense amplifier  Compares with reference value to determine 0 or 1  Capacitor charge must be restored Computer Architecture –Department of Information Systems @ Hoá NGUYEN 13
  14. Destructive Read sense amp Vdd bitline 01 voltage Wordline Enabled Sense Amp Enabled After read of 0 or 1, cell contains something close to 1/2 Vdd storage cell voltage Computer Architecture –Department of Information Systems @ Hoá NGUYEN 14
  15. Cơ chế làm tươi - refresh  Sau khi đọc, nội dung của DRAM cell đã bị thay đổi  Lưu các giá trị cells trong bộ đệm hàng row buffer  Ghi lại các giá trị đó cho các cells trong lần đọc kế tiếp DRAM cells Sense Amps Row Buffer  Thực tế, DRAM cell sẽ mất nội dung ngay cả khi không có tác vụ đọc lý do được gọi là “dynamic” 10  Vì thế các cells trong DRAM cần được định kỳ đọc và ghi lại nội dung Gate Leakage Computer Architecture –Department of Information Systems @ Hoá NGUYEN 15
  16. Static RAM  Transistor arrangement gives stable logic state  State 1  C1 high, C2 low  T1 T4 off, T2 T3 on  State 0  C2 high, C1 low  T2 T3 off, T1 T4 on  Address line transistors T5 T6 is switch  Write – apply value to B & compliment to B  Read – value is on line B Computer Architecture –Department of Information Systems @ Hoá NGUYEN 16
  17. SRAM vs. DRAM  Cả hai đều có tính chất volatile  Cần cung cấp năng lượng để bảo quản dữ liệu  Dynamic cell  Đơn giản, kích thước nhỏ gọn  Mật độ cell cao  Chi phí thấp  Cần chu kỳ làm tươi  Cho phép kết hợp thành các đơn vi nhớ lớn  Static  Nhanh hơn, cồng kềnh hơn  Cho phép xây dựng các bộ nhớ Cache Computer Architecture –Department of Information Systems @ Hoá NGUYEN 17
  18. Synchronous DRAM (SDRAM)  Truy cập được đồng bộ hoá với một đồng hồ bên ngoài  Địa chỉ được truyền đến RAM  RAM tìm dữ liệu (CPU đợi như DRAM thông thường)  Khi SDRAM chuyển dữ liệu theo thời gian đồng bộ với system clock, CPU biết được khi nào dữ liệu sẵn sàng => CPU không cần phải chờ và có thể làm việc khác  Burst mode: cho phép SDRAM thiết lập dòng dữ liệu theo từng block  Chỉ chuyển dữ liệu 1 lần trong 1 chu kỳ đồng hồ  DDR-SDRAM - Double-data-rate 1 SDRAM  Gửi dữ liệu 2 lần trong một chu kỳ đồng hồ (leading & trailing edge)  DDR2-SDRAM - Double-data-rate 2 SDRAM  DDR3-SDRAM - Double-data-rate 3 SDRAM  Cache DRAM: (misubishi)  Tích hợp SRAM cache (16k) vào trong DRAM chip Computer Architecture –Department of Information Systems @ Hoá NGUYEN 18
  19. DRAM Read Timing Việc truy cập là không đồng bộ: được kiểm soát bởi các tín hiệu RAS & CAS, các tín hiệu này có thể được sinh ra ngẫu nhiên Computer Architecture –Department of Information Systems @ Hoá NGUYEN 19
  20. SDRAM Read Timing Double-Data Rate (DDR) DRAM transfers data on both rising and falling edge of the clock Command frequency does not change Burst Length Timing figures taken from “A Performance Comparison of Contemporary DRAM Architectures” by Cuppu, Jacob, Davis and Mudge Computer Architecture –Department of Information Systems @ Hoá NGUYEN 20
  21. DDR SDRAM Computer Architecture –Department of Information Systems @ Hoá NGUYEN 21
  22. Tổ chức bộ nhớ  Mạch nhớ W từ B bits được tổ chức dưới dạng 1 ma trận n hàng và m cột từ nhớ B bits  Cần n*m =W words, kích thước bus địa chỉ = /log2W/  B đường dữ liệu RowDecoder Row Memory Address Cell Array Sense Amps Row Buffer Column Address Column Decoder Data Bus Computer Architecture –Department of Information Systems @ Hoá NGUYEN 22
  23. Ví dụ : 16 Mb DRAM (4M x 4) RAS: Row Address Select; CAS: Column Address Select OE: Output Enable ; WE: Write Enable Computer Architecture –Department of Information Systems @ Hoá NGUYEN 23
  24. DRAM Read Operation RowDecoder Memory 0x1FE Cell Array Sense Amps Row Buffer 0x0000x0020x001 Column Decoder Data Bus Computer Architecture –Department of Information Systems @ Hoá NGUYEN 24
  25. Packaging Computer Architecture –Department of Information Systems @ Hoá NGUYEN 25
  26. Tổ chức bộ nhớ lớn Computer Architecture –Department of Information Systems @ Hoá NGUYEN 26
  27. Ví dụ  Xây dựng một không gian nhớ 216 từ 32 bits  4096 từ nhớ trong RAM  4096 từ nhớ trong ROM Sử dụng:  chip RAM 1024 × 8 bits  chip ROM 4096 × 8 bits  Cách thức:  Từ = 4 chips 8 bits song song  Bản đồ địa chỉ nhớ  4096 từ nhớ RAM ở địa chỉ thấp nhất (0 - 4095)  4096 từ nhớ ROM ở địa chỉ cao nhất (61440 - 65535)  Những địa chỉ khác không sử dụng Computer Architecture –Department of Information Systems @ Hoá NGUYEN 27
  28. Ví dụ  4 tầng RAM (0 - 4095) Tầng Bits địa chỉ  0 -1023 RAM 0 0000 00xx xxxx xxxx  1024 - 2047 RAM 1 0000 01xx xxxx xxxx  2048 - 3071 RAM 2 0000 10xx xxxx xxxx  3072 - 4095 RAM 3 0000 11xx xxxx xxxx  1 tầng ROM (61440 - 65535) Inoccupied  Big Endian <> Little Endian ROM 1111 xxxx xxxx xxxx  VD: 0x12.34.56.78 Computer Architecture –Department of Information Systems @ Hoá NGUYEN 28
  29. Latency Độ trễ từ MC đến chips nhớ Độ trễ từ CPU -> memory controller Width/Speed thay đổi theo kiểu bộ nhớ (+ return trip ) Computer Architecture –Department of Information Systems @ Hoá NGUYEN 29
  30. Memory Controller Read Write Response Commands Queue Queue Queue Data To/From CPU Scheduler Buffer Memory Controller Bank 0 Bank 1 Computer Architecture –Department of Information Systems @ Hoá NGUYEN 30
  31. On-Chip Memory Controller Also: cơ chế lập lịch phức tạp hơn Memory controller thi hành cùng tốc độ CPU thay vì tốc độ xung FSB All on same chip Disadvantage: memory type is now tied to the CPU implementation Computer Architecture –Department of Information Systems @ Hoá NGUYEN 31
  32. Memory Latency is Long  Thường từ 60-100ns  Lãng phí thời gian của CPU:  2GHz CPU  0.5ns / cycle  100ns memory 200 cycle memory latency!  Solution: sử dụng bộ nhớ đệm có tốc độ cao hơn - Caches Computer Architecture –Department of Information Systems @ Hoá NGUYEN 32
  33. 3. Cache  Bộ nhớ có tốc độ truy cập nhanh  Thường nằm giữa main memory và CPU  Có thể nằm trong CPU chip hoặc một module riêng Computer Architecture –Department of Information Systems @ Hoá NGUYEN 33
  34. Cấu trúc Cache/Main Memory Computer Architecture –Department of Information Systems @ Hoá NGUYEN 34
  35. Cơ chế hoạt động  CPU yêu cầu nội dung nhớ tại một vùng nhớ  Kiểm tra cache đối với dữ liệu đó  Nếu có, lấy dữ liệu đó từ cache ( faster)  Nếu không, đọc block yêu cầu từ main memory vào cache  Chuyển dữ liệu đó từ cache đến CPU  Cache sử dụng tags để xác định block nào của main memory trong mỗi khe cache (cache slot) Computer Architecture –Department of Information Systems @ Hoá NGUYEN 35
  36. Biểu đồ Computer Architecture –Department of Information Systems @ Hoá NGUYEN 36
  37. Thiết kế Cache  Size: tốc độ và chi phí  More cache is faster (up to a point)  Checking cache for data takes time  More cache is expensive  Mapping Function  Ánh xạ trực tiếp  Ánh xạ kết hợp  Ánh xạ kết hợp theo tập  Replacement Algorithm  Write Policy  Block Size  Number of Caches  1 hay nhiều caches ở mức 1 (bên trong)  1 cache ở mức 2 (trong hoặc ngoài) (thường VL1 >= 4VL2)  Đôi khi có thể sử dụng 1 cache ở mức 3 (ngoài) Computer Architecture –Department of Information Systems @ Hoá NGUYEN 37
  38. Tổ chức cache điển hình Computer Architecture –Department of Information Systems @ Hoá NGUYEN 38
  39. Bảng so sánh caches một số CPU Year of Processor Type L1 cachea L2 cache L3 cache Introduction IBM 360/85 Mainframe 1968 16 to 32 KB — — PDP-11/70 Minicomputer 1975 1 KB — — VAX 11/780 Minicomputer 1978 16 KB — — IBM 3033 Mainframe 1978 64 KB — — IBM 3090 Mainframe 1985 128 to 256 KB — — Intel 80486 PC 1989 8 KB — — Pentium PC 1993 8 KB/8 KB 256 to 512 KB — PowerPC 601 PC 1993 32 KB — — PowerPC 620 PC 1996 32 KB/32 KB — — PowerPC G4 PC/server 1999 32 KB/32 KB 256 KB to 1 MB 2 MB IBM S/390 G4 Mainframe 1997 32 KB 256 KB 2 MB IBM S/390 G6 Mainframe 1999 256 KB 8 MB — Pentium 4 PC/server 2000 8 KB/8 KB 256 KB — High-end server/ IBM SP 2000 64 KB/32 KB 8 MB — supercomputer CRAY MTAb Supercomputer 2000 8 KB 2 MB — Itanium PC/server 2001 16 KB/16 KB 96 KB 4 MB SGI Origin 2001 High-end server 2001 32 KB/32 KB 4 MB — Itanium 2 PC/server 2002 32 KB 256 KB 6 MB IBM POWER5 High-end server 2003 64 KB 1.9 MB 36 MB CRAY XD-1 Supercomputer 2004 64 KB/64 KB 1MB — Computer Architecture –Department of Information Systems @ Hoá NGUYEN 39
  40. Ánh xạ cache – main memory  Ánh xạ trực tiếp:  Mỗi block của bộ nhớ chính được đặt chỉ vào 1 dòng cache  Ánh xạ kết hợp:  1 block của bộ nhớ chính có thể được đặt vào bất kỳ dòng nào trong cache  Ánh xạ kết hợp theo tập:  1 block của bộ nhớ chính có thể được đặt vào bất kỳ dòng nào trong 1 tập n-blocks của cache Tag s-r Cache slot r Word w Computer Architecture –Department of Information Systems @ Hoá NGUYEN 40
  41. Direct Mapping  Độ dài: s+w bits Độ lớn block = 2w từ  Số lượng block = 2s Số slots = 2r  Tag = s-r bits Computer Architecture –Department of Information Systems @ Hoá NGUYEN 41
  42. Ánh xạ trực tiếp từ Cache đến MM Computer Architecture –Department of Information Systems @ Hoá NGUYEN 42
  43. Bảng ánh xạ trực tiếp Vị trí slot (cache line) Khối MM có thể chứa 0 0, m, 2m, 3m 2s-m 1 1,m+1, 2m+1 2s-m+1 m-1 m-1, 2m-1,3m-1 2s-1 Computer Architecture –Department of Information Systems @ Hoá NGUYEN 43
  44. Ví dụ  Cache size = 64kByte,  Cache block = 4 bytes -> có 16k (214) lines  Main memory = 16MBytes, 24 bit address (224=16M) Computer Architecture –Department of Information Systems @ Hoá NGUYEN 44
  45. Ưu/Nhược của ánh xạ trực tiếp  Đơn giản, không cần thời gian tính toán nhiều  Chi phí cài đặt thấp  Mỗi block chỉ có một vị trí duy nhất trong cache (slot tương ứng) có thể dẫn đến tỷ lệ cache miss tăng lên Computer Architecture –Department of Information Systems @ Hoá NGUYEN 45
  46. Ánh xạ kết hợp  MM block có thể được đưa vào bất kỳ dòng cache nào  Địa chỉ từ nhớ sẽ được chia thành hai phần: tag và word  Tag sẽ cho phép xác định địa chỉ block trong MM  Word cho phép xác định vị trí từ trong dòng cache tương ứng với địa chỉ Tag  Việc so khớp cache hit/miss được tiến hành dựa trên trường Tag, có thể dẫn đến trường hợp phải so khớp toàn bộ các dòng cache Computer Architecture –Department of Information Systems @ Hoá NGUYEN 46
  47. Ánh xạ kết hợp  Độ dài: s+w bits Độ lớn block = 2w từ  Số lượng block = 2s Số slots = undefined  Tag = s bits Computer Architecture –Department of Information Systems @ Hoá NGUYEN 47
  48. Computer Architecture –Department of Information Systems @ Hoá NGUYEN 48
  49. Ánh xạ kết hợp theo tập – Set Associative Mapping  Cache được chia thành nhiều tập, mỗi tập chứa một số slots  Mỗi block trong MM được đưa vào một tập duy nhất theo cơ chế ánh xạ trực tiếp; tuy nhiên, nó có thể được đặt vào bất kỳ slot nào trong tập đó theo cơ chế ánh xạ kết hợp  Chẳng hạn với 2 lines mỗi tập, mỗi block có thể ở 1 trong 2 lines tại vị trí một tập duy nhất  Với k dòng, cơ chế ánh xạ này được gọi là k-Way Set Associative Mapping Computer Architecture –Department of Information Systems @ Hoá NGUYEN 49
  50. Set Associative Mapping Computer Architecture –Department of Information Systems @ Hoá NGUYEN 50
  51. k-Way Set Associative  Độ dài: s+w bits Độ lớn block = 2w từ  Số lượng block = 2s Số lines/set=k  Số set v = 2d, Số slots = k.v Tag = s-d bits Computer Architecture –Department of Information Systems @ Hoá NGUYEN 51
  52. Computer Architecture –Department of Information Systems @ Hoá NGUYEN 52
  53. So sánh hiệu năng 1.0  Khác biệt giữa direct và k-way tối đa đến 64kB 0.9 0.8  Khác biệt giữa 2-way và 0.7 o i t 0.6 4-way tại cache 4kB nhỏa r t i 0.5 hơn so với cache 8kB H 0.4  Độ phức tạp của cache 0.3 tăng theo độ kết hợp 0.2  Không có lý do gì để 0.1 không tăng cache lên 0.0 1k 2k 4k 8k 16k 32k 64k 128k 256k 512k 1M 8kB hay 16kB Cache size (bytes)  Từ 32kB trở lên không direct 2-way cải thiện nhiều về hiệu 4-way 8-way năng 16-way Computer Architecture –Department of Information Systems @ Hoá NGUYEN 53
  54. Truy cập cache  Xây dựng địa chỉ nhớ dựa trên hàm ánh xạ  Địa chỉ nhớ 1 từ cho phép tìm được:  block mà nó phụ thuộc  Vị trí của nó trong block đó  Vị trí block đó trong cache  Cấu trúc: 2 phần  Số block:  index: vị trí block trong cache  tag: xác định block trong số những blocks có cùng vị trí  Độ rời: địa chỉ của từ trong block Computer Architecture –Department of Information Systems @ Hoá NGUYEN 54
  55. Giải thuật thay thế  Ánh xạ trực tiếp: không có sự lựa chọn  1 block được đặt chỉ vào 1 vị trí  Ánh xạ kết hợp – kết hợp tập:  Chọn block ngẫu nhiên  FIFO: Chọn block cũ nhất trong cache  Chọn block được su dung som nhất (LRU Least Recently Used)  Chọn block có tần xuất sử dụng ít nhất (LFU Least Frequently Used)  Hiệu quả nhất: LFU, LRU, ngẫu nhiên  Dễ cài đặt: ngẫu nhiên, FIFO Computer Architecture –Department of Information Systems @ Hoá NGUYEN 55
  56. Chính sách Write  Không được ghi đè một cache block trừ khi CPU cập nhật dữ liệu đó  Mỗi CPU có thể có cache riêng  I/O có thể truy cập trực tiếp main memory  Phân biệt:  Write through  Write back Computer Architecture –Department of Information Systems @ Hoá NGUYEN 56
  57. Write through  Ghi cả main memory lẫn cache  Nếu có nhiều CPU, cần quản lý lưu lượng của bộ nhớ chính để giữ cache cục bộ được cập nhật  Giảm tốc độ ghi, gây nhiều traffic Computer Architecture –Department of Information Systems @ Hoá NGUYEN 57
  58. Write back  Cập nhật đầu tiên trong cache, lưu trạng thái trong bit cập nhật của cache slot (update bit = set)  Nếu block có yêu cầu thay đổi dữ liệu, ghi nội dung hiện thời vào main memory chi khi update bit đã được thiết lập  I/O phải truy cập main memory thông qua cache  Khoảng 15% truy cập bộ nhớ là thao tác ghi Computer Architecture –Department of Information Systems @ Hoá NGUYEN 58
  59. Độ lớn đường cache (line size)  Tăng kích thước line sẽ tăng tỷ lệ hit (dựa trên nguyên lý cục bộ của chương trình)  Tỷ lệ hit sẽ giảm nếu kích thước block lớn hơn  Xác suất sử dụng dữ liệu mới tải lên nhỏ hơn xác suất sử dụng lại dữ liệu được thay thế  Block lớn hơn  Giảm số blocks nằm trong cache  Khả năng dữ liệu bị đè sau khi được tải vào tăng lên  Các từ nhớ có tính cục bộ nhỏ đi giảm tỷ lệ hit  Không có giá trị tối ưu được xác định chính thức, từ 8 đến 64 bytes là giá trị hợp lý  Với những hệ thống tính toán hiệu năng cao, kích thước block thường từ 64 đến 128 bytes Computer Architecture –Department of Information Systems @ Hoá NGUYEN 59
  60. Cache đa mức - Multilevel Caches  Hầu hết các CPU ngày này đều có cache on chip (do có mật độ logic gates tăng lên) Nhanh hơn vì không cần sử dụng bus Bus được sử dụng cho những mục đích khác  Thường thì cache đa mức được cài đặt trong cả trong và ngoài chip  L1 on chip, L2 off chip in static RAM  L2 access much faster than DRAM or ROM  L2 often uses separate data path  L2 may now be on chip  Resulting in L3 cache  Bus access or now on chip Computer Architecture –Department of Information Systems @ Hoá NGUYEN 60
  61. Tỷ lệ Hit (L1 & L2) với 8 kB và 16 kB L1 Computer Architecture –Department of Information Systems @ Hoá NGUYEN 61
  62. Unified v Split Caches  Unified Cache: cache chung cho cả lệnh và dữ liệu Tỷ lệ hit cao hơn; cân bằng tải lệnh và dữ liệu; chỉ phải thiết kế, cài đặt một bộ nhớ cache  Split Cache: một cache cho lệnh và một cache cho dữ liệu Loại được sự cạnh tranh cache (cache contention) trong chu trình tải/giải mã lệnh và chu trình thi hành (nâng cao hiệu năng pipeline) Computer Architecture –Department of Information Systems @ Hoá NGUYEN 62
  63. Hiệu năng  Thời gian truy cập trung bình = Thời gian truy cập thành công + tỷ lệ thất bại x penality thất bại  Thời gian truy cập = Thời gian truy cập một dữ liệu trong cache  Tỷ lệ thất bại = số lần dữ liệu cần đọc không chứa trong cache /số lần truy cập cache Computer Architecture –Department of Information Systems @ Hoá NGUYEN 63
  64. Pentium Cache  80386 – no on chip cache  80486 – 8k using 16 byte lines and four way set associative organization  Pentium (all versions) – two on chip L1 caches  Data & instructions  Pentium III – L3 cache added off chip  Pentium 4  L1 caches  8k bytes  64 byte lines  four way set associative  L2 cache  Feeding both L1 caches  256k  128 byte lines  8 way set associative  L3 cache on chip Computer Architecture –Department of Information Systems @ Hoá NGUYEN 64
  65. Pentium Cache Processor on which feature Problem Solution first appears Add external cache using faster 386 External memory slower than the system bus. memory technology. Move external cache on-chip, 486 Increased processor speed results in external operating at the same speed as the bus becoming a bottleneck for cache access. processor. Internal cache is rather small, due to limited Add external L2 cache using faster 486 space on chip technology than main memory Contention occurs when both the Instruction Create separate data and Pentium Prefetcher and the Execution Unit simultane- instruction caches. ously require access to the cache. In that case, the Prefetcher is stalled while the Execution Unit’s data access takes place. Create separate back-side bus that Pentium Pro runs at higher speed than the main Increased processor speed results in external (front-side) external bus. The BSB bus becoming a bottleneck for L2 cache access. is dedicated to the L2 cache. Move L2 cache on to the processor Pentium II chip. Some applications deal with massive databases Add external L3 cache. Pentium III and must have rapid access to large amounts of data. The on-chip caches are too small. Move L3 cache on-chip. Pentium 4 Computer Architecture –Department of Information Systems @ Hoá NGUYEN 65
  66. Pentium 4 Block Diagram Computer Architecture –Department of Information Systems @ Hoá NGUYEN 66
  67. PowerPC Cache  601 – single 32kb 8 way set associative  603 – 16kb (2 x 8kb) two way set associative  604 – 32kb  620 – 64kb  G3 & G4  64kb L1 cache  8 way set associative  256k, 512k or 1M L2 cache  two way set associative  G5  32kB instruction cache  64kB data cache Computer Architecture –Department of Information Systems @ Hoá NGUYEN 67
  68. PowerPC G5 Block Diagram Computer Architecture –Department of Information Systems @ Hoá NGUYEN 68
  69. ARM Cache Core Cache Cache Size Cache Line Associativity Location Write Type (kB) Size Buffer Size (words) (words) ARM720T Unified 8 4 4-way Logical 8 ARM920T Split 16/16 D/I 8 64-way Logical 16 ARM926EJ-S Split 4-128/4-128 8 4-way Logical 16 D/I ARM1022E Split 16/16 D/I 8 64-way Logical 16 ARM1026EJ-S Split 4-128/4-128 8 4-way Logical 8 D/I Intel StrongARM Split 16/16 D/I 4 32-way Logical 32 Intel Xscale Split 32/32 D/I 8 32-way Logical 32 ARM1136-JF-S Split 4-64/4-64 8 4-way Physical 32 D/I Computer Architecture –Department of Information Systems @ Hoá NGUYEN 69
  70. Tổ chức ARM Cache  Small FIFO write buffer  Enhances memory write performance  Between cache and main memory  Small c.f. cache  Data put in write buffer at processor clock speed  Processor continues execution  External write in parallel until empty  If buffer full, processor stalls  Data in write buffer not available until written  So keep buffer small Computer Architecture –Department of Information Systems @ Hoá NGUYEN 70
  71. Tổ chức ARM Cache Computer Architecture –Department of Information Systems @ Hoá NGUYEN 71
  72. 4. Bộ nhớ ngoài  RAM for storage  Flash  Đĩa từ - Magnetic Disk  HDD  RAID  Removable  Đĩa quang - Optical  CD-ROM  CD-Recordable (CD-R)  CD-R/W  DVD  Băng từ - Magnetic Tape Computer Architecture –Department of Information Systems @ Hoá NGUYEN 72
  73. Magnetic Disks Computer Architecture –Department of Information Systems @ Hoá NGUYEN 73
  74. Magnetic Disks  Ưu điểm: rẻ($/MB), độ tin cậy chấp nhận được  Primary storage, memory swapping  Nhược: chỉ có thể đọc/ghi toàn bộ một sector  không thể truy cập trực tiếp như bộ nhớ chính  Thời gian truy cập đĩa  Queuing delay  Wait until disk gets to do this operation  Seek time  Head moves to correct track  Rotational latency  Correct sector must get under the head  Data transfer time and controller time Computer Architecture –Department of Information Systems @ Hoá NGUYEN 74
  75. Khuynh hướng của đĩa từ  Dung lượng: ~gấp đôi sau mỗi năm  Thời gian truy cập trung bình  5-12ms (việc cải thiện tốc độ tương đối chậm)  Latency quay trung bình (1/2 full rotation)  5,000 RPM to 10,000 RPM to 15,000 RPM  Cải thiện chậm, phức tạp (reliability, noise)  Tốc độ truyền dữ liệu  Phục thuộc vào bề mặt đĩa, dữ liệu trên một track Computer Architecture –Department of Information Systems @ Hoá NGUYEN 75
  76. Đĩa quang  Giới hạn bởi các chuẩn  CD and DVD capacity fixed over years  Technology actually improves, but it takes time for it to make it into new standards  Kích thước bé, dễ thay thế  Good for backups and carrying around Computer Architecture –Department of Information Systems @ Hoá NGUYEN 76
  77. Băng từ  Thời gian truy cập rất chậm  Must rewind tape to correct place for read/write  Chi phí thấp ($/MB)  It’s just miles of tape!  But disks have caught up anyway  Được sử dụng để sao lưu dữ liệu (secondary storage)  Large capacity & Replaceable Computer Architecture –Department of Information Systems @ Hoá NGUYEN 77
  78. RAM for Storage  Disks are about 100 times cheaper ($/MB)  DRAM is about 100,000 faster (latency)  Solid-State Disks  Actually, a DRAM and a battery  Much faster than disk, more reliable  Expensive (not very good for archives and such)  Flash memory  Much faster than disks, but slower than DRAM  Very low power consumption  Can be sold in small sizes (few GB, but tiny) Computer Architecture –Department of Information Systems @ Hoá NGUYEN 78
  79. Một số vấn đề lỗi  Phân loại theo nguyên nhân  Hardware Faults  Hardware devices fail to perform as designed  Design Faults  Faults in software and some faults in HW  E.g. the Pentium FDIV bug was a design fault  Operation Faults  Operator and user mistakes  Environmental Faults  Fire, power failure, sabotage, etc. Computer Architecture –Department of Information Systems @ Hoá NGUYEN 79
  80. Khắc phục: cải thiện độ tin cậy  Fault Avoidance  Prevent occurrence of faults by construction  Fault Tolerance  Prevent faults from becoming failures  Typically done through redundancy  Error Removal  Removing latent errors by verification  Error Forecasting  Estimate presence, creation, and consequences of errors Computer Architecture –Department of Information Systems @ Hoá NGUYEN 80
  81. Disk Fault Tolerance with RAID  Redundant Array of Independent/Inexpensive Disks  Several smaller disks play a role of one big disk  Can improve performance  Data spread among multiple disks  Accesses to different disks go in parallel  Can improve reliability  Data can be kept with some redundancy Computer Architecture –Department of Information Systems @ Hoá NGUYEN 81
  82. RAID Tập các đĩa vật lý thành một đĩa logic nhìn bởi hệ điều hành  RAID 0: không dư thừa dữ liệu  Truy cập song song các đĩa  Dữ liệu có thể phân tán trên nhiều đĩa  RAID 1:  Mirrored disks  2 copies được lưu trên 2 đĩa khác nhau  Đọc từ 1 trong 2, ghi đồng thời lên 2  Đắt  RAID 2:  Các đĩa được đồng bộ hoá  Dư thừa nhiều, giá thành cao Computer Architecture –Department of Information Systems @ Hoá NGUYEN 82
  83. RAID  RAID 3  Như RAID 2  Chỉ sử dụng 1 đĩa dư thừa  RAID 4  Mỗi đĩa hoạt động một cách độc lập  Parity được lưu trong một đĩa parity riêng  RAID 5  Như RAID 4  Parity được phân ra trên tất cả các đĩa  RAID 6  Hai lần tính parity  Lưu các block khác nhau trên các đĩa khác nhau Computer Architecture –Department of Information Systems @ Hoá NGUYEN 83
  84. RAID 0, 1, 2 Computer Architecture –Department of Information Systems @ Hoá NGUYEN 84
  85. RAID 3 & 4 Computer Architecture –Department of Information Systems @ Hoá NGUYEN 85
  86. RAID 5 & 6 Computer Architecture –Department of Information Systems @ Hoá NGUYEN 86