본문 바로가기

documents

숙제3

7.2

little temporal locality & spatial locality means accessing variable once(no looping) & no array in program. so I wrote a program that just add sum integers.

in C program
  1. a = (b + c) - (d + e);

 

in MIPS assembly program
  1.    .data
  2. a : .word
  3. b : .word
  4. c : .word
  5. d : .word
  6. e : .word
  7.    .text
  8. # load words
  9. la   $t2, a
  10. lw   $s0, 0($t2)
  11. la   $t2, b
  12. lw   $s1, 0($t2)
  13. la   $t2, c
  14. lw   $s2, 0($t2)
  15. la   $t2, d
  16. lw   $s3, 0($t2)
  17. la   $t2, e
  18. lw   $s4, 0($t2)
  19. # operate
  20. add   $t0, $s1, $s2
  21. add   $t1, $s3, $s4
  22. add   $s0, $t0, $t1
  23.  

 

 

7.3

very high amounts of temporal locality but very little spatial locality means accesing variable many times(looping) & there are no arrays in program. so I wrote a program that just looping.

 

In C program
  1. for(;;) a += 1;

 

In MIPS assembly program
  1.    .data
  2. a : .word
  3. .text
  4. loop:
  5. la   $t0, a
  6. lw   $s0, 0($t0)
  7. addi  $s0, $s0, 1
  8. j   loop

 

 

7.9

there are inputs : 2, 3, 11, 16, 21, 13, 64, 48, 19, 11, 3, 22, 4, 27, 6, 11

there are 16 one-word block.

so modulus operation on each input is here : 2, 3, 11, 0(16), 5(21), 13, 0(64), 0(48), 3(19), 11, 3, 6(22), 4, 11(27), 6, 11

then start!

  • 2 miss - fill 2 in 0010
  • 3 miss - fill 3 in 0011
  • 11 miss - fill 11 in 1011
  • 16 miss - fill 16 in 0000
  • 21 miss - fill 21 in 0101
  • 13 miss - fill 13 in 1101
  • 64 miss - delete 16 in 0000 and fill 64 in 0000
  • 48 miss - delete 64 in 0000 and fill 48 in 0000
  • 19 miss - delete 3 in 0011 and fill 19 in 0011
  • 11 hit
  • 3 miss - delete 19 in 0011 and fill 3 in 0011
  • 22 miss - fill 22 in 0110
  • 4 miss - fill 4 in 0100
  • 27 miss - delete 11 in 1011 and fill 27 in 1011
  • 6 miss - delete 22 in 0110 and fill 6 in 0110
  • 11 miss - delete 27 in 1011 and fill 11 in 1011

1 hits!

 

 

7.10

there are inputs : 2, 3, 11, 16, 21, 13, 64, 48, 19, 11, 3, 22, 4, 27, 6, 11

there are 4 four-word block.

result of modulus operation from 0 to 3 go to 00

result of modulus operation from 4 to 7 go to 01

result of modulus operation from 8 to 11 go to 10

result of modulus operation from 12 to 15 go to 11

so modulus operation on each input is here : 2, 3, 11, 0(16), 5(21), 13, 0(64), 0(48), 3(19), 11, 3, 6(22), 4, 11(27), 6, 11

then start!

  • 2 miss - put 0, 1, 2, 3 in 00
  • 3 hit(at 00)
  • 11 miss - put 8, 9, 10, 11 in 10
  • 16 miss - delete in 00 and put 16, 17, 18, 19 in 00
  • 21 miss - put 20, 21, 22, 23 in 01
  • 13 miss - put 12, 13, 14, 15 in 11
  • 64 miss - delete in 00 and put 64, 65, 66, 67 in 00
  • 48 miss - delete in 00 and put 48, 49, 50, 51 in 00
  • 19 miss - delete in 00 and put 16, 17, 18, 19 in 00
  • 11 hit(at 10)
  • 3 miss - delete in 00 and put 0, 1, 2, 3 in 00
  • 22 hit(at 01)
  • 4 miss - delete in 01 and put 4, 5, 6, 7 in 01
  • 27 miss - delete in 11 and put 24, 25, 26, 27 in 11
  • 6 hit(at 01)
  • 11 hit(at 10)

5 hits!

이 글은 스프링노트에서 작성되었습니다.