代写代考 Exam 1 Solutions – cscodehelp代写
Exam 1 Solutions
15-213 / 18-213 Fall 2012
1-a 2-c 3-d 4-c 5-a 6-b 7-c 8-(b or d) 9-c 10-d
Copyright By cscodehelp代写 加微信 cscodehelp
The correct answer for 8 was initially listed as d) temporal locality,
but the correct answer is actually spatial locality. While it’s true
that blocking in things like matmult primarily exploits temporal
locality, blocking is effective for transpose because it exploits
spatial locality by effectively using the entries in each cache line;
there is no reuse.
Expression 4b decimal 4b binary 6b decimal 6b binary
—————————————————————–
-8 | -8 | 1000 | -8 | 11 1000
-TMin | -8 | 1000 | -32 | 10 0000
x >> 1 | -3 | 1101 | -3 | 11 1101
(-x ^ -1) >> 2 | -2 | 1110 | -2 | 11 1110
—————————————————————-
| A | B
One | 0 011 00 | 0 01 000 Exact in both formats
1/2 | 0 010 00 | 0 00 100 Exact in both formats, norm in A, denorm in B
11/8 | 0 011 10 | 0 01 011 Format A round to even, format B exact
unsigned transform(unsigned n)
for(m = 0; n != 0; n >>= 1) { // (or) for(m = 0; n > 0; n = n/2)
b = n & 1; // (or) b = n % 2;
if(b == 0) {
m = 2*m + 1; // (or) m = m + m + 1; (or) m = m<<1 + 1; Alternate solution: ------------------- unsigned transform(unsigned n) for(m = 0; n != 0;) { b = !(n & 1); // (or) b = (n % 2) - 1; if(b == 0) { m = 2*m + 1; n = n >> 1;
a X X X X X X X b b b b b b b b
c c c c d d d X e e e e e e e e
f f f f f f f f
f f f f f f f f b b b b b b b b
e e e e e e e e c c c c d d d a
a d d d c c c c b b b b b b b b
e e e e e e e e f f f f f f f f
B: bachelors
C: masters
int result = 4;
switch(a){
c = c – 5;
result = 4 * c; //or result *= c
result = 86547; //or 0x15213
b = b & c;
result += b; // or result = b + 4
return result;
Stack The diagram starts with the
addresss arguments for foo()
+———————————–+
0xffffd850| 5 |
+———————————–+
0xffffd84c| 4 |
+———————————–+
0xffffd848| 3 |
+———————————–+
0xffffd844| caller ra: 0x080483c9 |
+———————————–+
0xffffd840| old ebp: ffffd858 | <- Part B: %ebp=0xffffd840
+-----------------------------------+
0xffffd83c| 3 |
+-----------------------------------+
0xffffd838| 4 |
+-----------------------------------+
0xffffd834| foo ra: 0x08048397 | <- Part C: esp=0xffffd834
+-----------------------------------+
0xffffd830| old ebp: 0xffffd840 | ok to omit, not part of the stack anymore
+-----------------------------------+
0xffffd82c| |
+-----------------------------------+
0xffffd824| |
+-----------------------------------+
A. TTSSSBBB
Set:Tag:hit/miss
C. Final state: 0 X 3 X 1 X 2 3 (c)
程序代写 CS代考 加微信: cscodehelp QQ: 2235208643 Email: kyit630461@163.com