04. Cache

MARS

Examples:

  1. Linear:
       1 .eqv    START   0x10010000
       2 .eqv    SZ      512
       3 .text
       4       li      $t9 0
       5 loop:   lw      $t0 START($t9)
       6       addiu   $t9 $t9 4
       7       blt     $t9 SZ loop
    
  2. Gapped
       1 .eqv    START   0x10010000
       2 .eqv    SZ      512
       3 .eqv    HSZ     256
       4 # Direct mapping burns out
       5 # Associative captures
       6 .text
       7       li      $t9 0
       8       li      $t8 HSZ
       9 loop:   lw      $t0 START($t9)
      10       lw      $t1 START($t8)
      11       addiu   $t9 $t9 4
      12       addiu   $t8 $t8 4
      13       blt     $t9 HSZ loop
    
  3. Equidistance (try to vary step):
       1 .eqv    START   0x10010000
       2 .eqv    SZ      256
       3 .eqv    GAP     3               # Try 5, 11
       4 .text
       5       li      $t8 0
       6       li      $t7 GAP
       7       sll     $t7 $t7 2
       8 loopg:  sll     $t9 $t8 2
       9 loop:   lw      $t0 START($t9)
      10       addu    $t9 $t9 $t7
      11       blt     $t9 SZ loop
      12       addiu   $t8 $t8 1
      13       blt     $t8 GAP loopg
    

Task: write a program, that:

  1. burns out default fully associative cache with 100% misses
  2. +does this in cycle (if previously not)
  3. +fills only 256 bytes of memory without a gap

H/W

(can be done in class if time allows)

  1. Write a program that utilizes memory sparsely, so it's footprint 100% misses 2-way associative MARS cache simulator, but (almost) fits into 4-way associative cache with 16 lines (blocks) of cache

  2. Make it available at sugon server in the subdirectory asm:

       1 localhost$ ssh sugon -p 2131
       2      ...
       3 [your_login@sugon ~]$ mkdir src
       4 [your_login@sugon ~]$ ls -a src
       5 .  ..
       6 [your_login@sugon ~]$ exit
       7      ...
       8 localhost$ scp -P 2131 progCache.asm your_login@sugon:src/
       9 progCache.asm              100%  285    26.7KB/s   00:00
      10 localhost$ ssh sugon -p 2131
      11      ...
      12 [your_login@sugon ~]$ mkdir src
      13 [your_login@sugon ~]$ ls -a src
      14 .  .. progCache.asm
      15 
    

HSE/ProgrammingOS/Lab_04_Cache (последним исправлял пользователь FrBrGeorge 2020-06-05 19:17:53)