kiến trúc máy tính võ tần phương chương ter05 bonho sinhvienzone com

62 57 0
kiến trúc máy tính võ tần phương chương ter05 bonho sinhvienzone com

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

dce 2013 COMPUTER ARCHITECTURE CSE Fall 2013 BK TP.HCM Faculty of Computer Science and Engineering Department of Computer Engineering Vo Tan Phuong http://www.cse.hcmut.edu.vn/~vtphuong CuuDuongThanCong.com https://fb.com/tailieudientucntt dce 2013 Chapter Bộ nhớ máy tính CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS dce Nội dung trình bày 2013  Công nghệ thuật ngữ liên quan đến nhớ  Tổ chức / thiết kế nhớ  Sự cần thiết phải có nhớ đệm  Phân loại nhớ đệm  Đánh giá hiệu nhớ đệm CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS dce Máy tính PC 2013  Nhìn từ bên ngồi, xử lý kết nối với RAM chip cầu bắc (quản lý kết nối vào bus tốc độ cao card đồ họa, khe PCI), chip cầu bắc nối với chip cầu nam (quản lý USB bus, network, ổ cứng, ổ CD…) CuuDuongThanCong.com Computer Architecture – Chapter RAM Card đồ họa CPU RAM Chip cầu bắc Khe cắm PCI Chip cầu nam https://fb.com/tailieudientucntt ©Fall 2013, CS Hệ thống nhớ máy tính  Bộ nhớ máy tính hiểu theo nghĩa rộng tất nơi chứa liệu (thanh ghi, nhớ đệm, nhớ chính, nhớ ngồi)  Hệ thống nhớ tổ chức theo mơ hình phân cấp, ghi, đến nhớ đệm L1, L2, nhớ chính, nhớ phụ Processor Control Devices Memory Datapath Input Output Microprocessor Registers L1 Cache L2 Cache Memory Bus Bigger 2013 Faster dce Main Memory I/O Bus Magnetic or Flash Disk CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS Hệ thống nhớ phân cấp Pipline MIPS CPU Imm RW Rd A L U BusB BusW 32 ALUout A 2 D-Cache Address 32 Data_out 1 WB Data RB BusA 32 Data_in 32 Rd4 Address Rt RA ALU result 32 D PC Instruction Rs Register File I-Cache Instruction E Rd3 Imm16 B 2013 Rd2 dce Data Block D-Cache miss I-Cache miss D-Cache miss làm trình pipeline bị stall Block Address Instruction Block I-Cache miss Block Address clk Interface to L2 Cache or Main Memory CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS dce Cấu tạo ghi 2013  Thanh ghi có thành phần D Flip-Flop, có n bit liệu vào, n bit liệu ra, tín hiệu WE (Write Enable) tín hiệu xung nhịp Clock Register D C D C D0 D1 D Flip-Flop Q Q Data_In Data_Out 32 D C D31 32 Q D Latch WE Clock CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS dce Chi tiết ghi 2013 Bộ ghi MIPS gồm 32 ghi 32 bit; RA, RB đầu vào yêu cầu truy xuất liệu, liệu đưa BusA, BusB; để ghi liệu cần nơi lưu RW, giá trị lưu BusW, yêu cầu ghi RegWrite thời điểm ghi đồng với xung nhịp Clock RA Register File BusA 32 RB 32 BusB RW Clock BusW RegWrite 32 CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS dce 2013 Bộ nhớ truy xuất ngẫu nhiên RAM  Là mảng 2n phần tử nhớ, phần tử nhớ lưu trữ m-bit liệu  Là nhớ “bốc hơi”  Dữ liệu lưu cung cấp điện  Truy xuất ngẫu nhiên  Thời gian truy xuất liệu từ phần tử nhớ  Tín hiệu điều khiển Output Enable (OE) RAM n  Yêu cầu xuất liệu “đọc” Address  Tín hiệu điều khiển Write Enable (WE) Data m OE WE  Yêu cầu ghi liệu  2n × m RAM : n-bit địa chỉ, m-bit liệu CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS dce Công nghệ nhớ 2013  Static RAM (SRAM) dùng cho nhớ đệm  bit nhớ cần transistor  Tốc độ truy xuất liệu cao (~ 1ns)  Cần lượng để trì giá trị lưu trữ  Dynamic RAM (DRAM) dùng cho nhớ  bit nhớ cần transistor + capacitor  Tốc độ truy xuất liệu thấp (~ 100ns)  Cần phải ghi lại giá trị vào ô nhớ sau đọc  Cần phải định kỳ “làm tươi”  Mỗi hàng làm tươi đồng thời CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 10 dce Ví dụ Cache Hits & Misses 2013  Xét nhớ đệm direct-mapped có 32 block  Bộ nhớ đệm ban đầu rỗng, Block size = 16 bytes  Các địa sau (dạng thập phân) tham khảo: 1000, 1004, 1008, 2548, 2552, 2556  Ánh xạ địa vào block nhớ đệm xác định 23 hit/miss  Lời giải:       1000 = 0x3E8 1004 = 0x3EC 1008 = 0x3F0 2548 = 0x9F4 2552 = 0x9F8 2556 = 0x9FC CuuDuongThanCong.com Tag Index offset cache index = 0x1E cache index = 0x1E cache index = 0x1F cache index = 0x1F cache index = 0x1F cache index = 0x1F Computer Architecture – Chapter Miss (truy xuất lần đầu) Hit Miss (V = không hợp lệ) Miss (khác tag) Hit Hit https://fb.com/tailieudientucntt ©Fall 2013, CS 48 dce Ví dụ Cache Hits & Misses 2013  Direct-mapped cache, line, block size = word 4 15 Start with an empty cache - all blocks initially marked as not valid 00 miss Mem(1) Mem(0) 00 hit Mem(1) Mem(0) 00 00 hit Mem(1) Mem(0) Mem(3) Mem(2) 01 00 00 miss Mem(1) Mem(0) Mem(3) Mem(2) 01 00 hit Mem(5) Mem(4) Mem(3) Mem(2) 1101 00 00 00 miss Mem(1) Mem(0) Mem(3) Mem(2) 01 00 hit Mem(5) Mem(4) Mem(3) Mem(2) 15 miss Mem(5) Mem(4) 15 14 Mem(3) Mem(2) ©2011, Dr Dinh Duc Anh Vu CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 49 49 dce 2013 Q3: Thay block đầy + miss  Khơng có lựa chọn nhớ đệm “direct-mapped”  Vớ nhớ đệm “associative”, block thay đầy miss?  Ngẫu nhiên  Least Recently Used (LRU)  Thay block không tham khảo lâu  Cập nhật thứ tự block “hit”  First In First Out (FIFO)  Thay block đưa vào trước set  Một đếm theo dõi tăng “miss” CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 50 dce Q4: Chiến lược ghi 2013  Trường hợp “Cache Hit”:  Write Through – ghi liệu vào nhớ đệm nhớ  Write Back – ghi liệu vào nhớ đệm, ghi liệu vào nhớ “miss”  Trường hợp “Cache Miss”:  Write Allocate – nạp block chứa liệu cần ghi vào nhớ đệm, sau thực ghi  No Write Allocate – không thay đổi nhớ đệm, ghi xuống nhớ  Các kết hợp thông dụng:  Write Through & No Write Allocate  Write Back & Write Allocate CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 51 dce Nội dung trình bày 2013  Công nghệ thuật ngữ liên quan đến nhớ  Tổ chức / thiết kế nhớ  Sự cần thiết phải có nhớ đệm  Phân loại nhớ đệm  Đánh giá hiệu nhớ đệm CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 52 dce Hit Rate & Miss Rate 2013  Hit Rate = Hits / (Hits + Misses)  Miss Rate = Misses / (Hits + Misses)  I-Cache Miss Rate = Miss rate nhớ đệm lệnh  D-Cache Miss Rate = Miss rate nhớ đệm liệu  Ví dụ:  1000 lệnh nạp, 150 lần miss I-Cache  25% lệnh load-store, 50 lần miss D-Cache  Tính I-cache D-cache miss rate?  I-Cache Miss Rate = 150 / 1000 = 15%  D-Cache Miss Rate = 50 / (25% × 1000) = 50 / 250 = 20% CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 53 dce Memory Stall Cycles 2013  Bộ xử lý stall trường hợp Cache miss  Khi nạp lệnh từ Instruction Cache (I-cache)  Khi load/store liệu Data Cache (D-cache) Memory stall cycles = Combined Misses  Miss Penalty  Miss Penalty: số chu kỳ xung nhịp cần để xử lý “miss” Combined Misses = I-Cache Misses + D-Cache Misses I-Cache Misses = I-Count × I-Cache Miss Rate D-Cache Misses = LS-Count × D-Cache Miss Rate LS-Count (Load & Store) = I-Count × LS Frequency CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 54 dce 2013 Memory Stall Cycles Per Instruction  Memory Stall Cycles Per Instruction = Combined Misses Per Instruction × Miss Penalty  Miss Penalty giả sử cho I-cache & Dcache  Miss Penalty giả sử cho Load & Store  Combined Misses Per Instruction = I-Cache Miss Rate + LS Frequency × D-Cache Miss Rate  Do đó, Memory Stall Cycles Per Instruction = I-Cache Miss Rate × Miss Penalty + LS Frequency × D-Cache Miss Rate × Miss Penalty CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 55 dce 2013 Ví dụ vệ Memory Stall Cycles  Xét chương trình có thơng số sau:  Instruction count (I-Count) = 106 lệnh  30% lệnh load & store  D-cache miss rate 5%; I-cache miss rate 1%  Miss penalty: 100 clock cycles (chu kỳ xung nhịp  Tính combined misses per instruction memory stall cycles  Combined misses per instruction in I-Cache and D-Cache  1% + 30%  5% = 0.025 combined misses per instruction  25 lần miss 1000 lệnh  Memory stall cycles  0.025  100 (miss penalty) = 2.5 stall cycles per instruction  Total memory stall cycles = 106  2.5 = 2,500,000 CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 56 dce 2013 CPU Time với Memory Stall Cycles CPU Time = I-Count × CPIMemoryStalls × Clock Cycle CPIMemoryStalls = CPIPerfectCache + Mem Stalls per Instruction  CPIPerfectCache = CPI nhớ đệm lý tưởng (không bị miss)  CPIMemoryStalls = CPI tính đến memory stalls  Memory stall cycles làm tăng CPI tổng thể CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 57 dce 2013 Ví dụ CPI với Memory Stalls  Một xử lý có CPI 1.5 cho trường hợp không miss  Cache miss rate 2% cho I-cache 5% cho D-cache (load & store)  20% lệnh load & store  Cache miss penalty: 100 clock cycles cho I-cache & D-cache  Tính CPI tính tới cache miss?  Lời giải: Instruction data Mem Stalls per Instruction = 0.02×100 + 0.2×0.05×100 = CPIMemoryStalls = 1.5 + = 4.5 cycles per instruction CPIMemoryStalls / CPIPerfectCache = 4.5 / 1.5 = Bộ xử lý chạy chậm lần memory stall cycles CPINoCache = 1.5 + (1 + 0.2) × 100 = 121.5 (rất lớn) CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 58 dce 2013 Average Memory Access Time  Average Memory Access Time (AMAT) AMAT = Hit time + Miss rate × Miss penalty  Thời gian truy xuất trung bình tính cho trường hợp hit & miss  Ví dụ: Tính AMAT cho nhớ đệm:  Thời gian truy xuất nhớ đệm (Hit time) = clock cycle = ns  Miss penalty: 20 clock cycles  Miss rate: 0.05  Lời giải: AMAT = + 0.05 × 20 = cycles = ns Khi không dùng nhớ đệm, AMAT Miss penalty = 20 cycle CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 59 dce 2013 Cải tiến hiệu nhớ đệm  Average Memory Access Time (AMAT) AMAT = Hit time + Miss rate * Miss penalty  Công thức AMAT sử dụng để thực cải tiến  Giảm Hit time  Bộ nhớ đệm phải nhỏ đơn giản  Giảm Miss Rate  Bộ nhớ đệm phải lớn, associativity nhiều, block size lớn  Giảm Miss Penalty  Bộ nhớ đệm phải nhiều cấp CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 60 dce Phân loại Miss – 3C 2013  Compulsory (bắt buộc): Tham khảo đến block chưa tồn nhớ đệm (valid bit có giá trị khơng hợp lệ)  Capacity (dung lượng): Dung lượng nhớ đệm không đủ để chứa liệu cần chương trình (vd: chương trình cần block để chứa liệu > 4)  Conflict (xung đột): Đụng độ thiếu associativity (vd: chương trình lặp block liệu > 2) CuuDuongThanCong.com Computer Architecture – Chapter https://fb.com/tailieudientucntt ©Fall 2013, CS 61 dce Phân loại Miss 2013 Compulsory misses độc lập với cache size Rất nhỏ chạy chương trình dài Miss Rate 14% Capacity misses giảm tăng dung lượng nhớ đệm 1-way 12% 2-way Conflict misses tăng tính associativity 10% 4-way 8% 8-way 6% Capacity Compulsory 4% 2% CuuDuongThanCong.com Computer Architecture – Chapter 16 32 64 128 KB Dung lượng https://fb.com/tailieudientucntt ©Fall 2013, CS 62 ... CuuDuongThanCong .com Computer Architecture – Chapter RAM Card đồ họa CPU RAM Chip cầu bắc Khe cắm PCI Chip cầu nam https://fb .com/ tailieudientucntt ©Fall 2013, CS Hệ thống nhớ máy tính  Bộ nhớ máy tính. .. CuuDuongThanCong .com Computer Architecture – Chapter https://fb .com/ tailieudientucntt ©Fall 2013, CS 10 dce Cấu tạo SRAM 2013 CuuDuongThanCong .com Computer Architecture – Chapter https://fb .com/ tailieudientucntt...dce 2013 Chapter Bộ nhớ máy tính CuuDuongThanCong .com Computer Architecture – Chapter https://fb .com/ tailieudientucntt ©Fall 2013, CS dce Nội dung trình bày

Ngày đăng: 28/01/2020, 23:10

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan