Lab 7: Results
Part 1
See example code
Part 2
Table 1: Access Pattern for sumarrayrows() Assuming ROWS=2 and COLS=3.
Memory Address | 0 | 4 | 8 | 12 | 16 | 20 |
Memory Contents | a[0][0] | a[0][1] | a[0][2] | a[1][0] | a[1][1] | a[1][2] |
Program Access Order | 1 | 2 | 3 | 4 | 5 | 6 |
Note: Address assumes array starts at memory address 0.
For the array: Good spatial locality. No temporal locality (since the array is only read once).
For the other variables (i, j, and sum): Good temporal locality (accessed more than once).
Table 2: Access Pattern for sumarraycols() Assuming ROWS=2 and COLS=3.
Memory Address | 0 | 4 | 8 | 12 | 16 | 20 |
Memory Contents | a[0][0] | a[0][1] | a[0][2] | a[1][0] | a[1][1] | a[1][2] |
Program Access Order | 1 | 3 | 5 | 2 | 4 | 6 |
Note: Address assumes array starts at memory address 0.
For the array: Poor spatial locality due to the access order. No temporal locality (since the array is only read once).
For the other variables (i, j, and sum): Good temporal locality (accessed more than once).
Table 3: Access Pattern for sumarray3d() Assuming ROWS=2, COLS=3, and DEPTH=4.
XXXXXXXXXXXXXX
Note: Address assumes array starts at memory address 0.
For the array: Poor spatial locality due to the access order. (Even worse than sumarraycols()). No temporal locality (since the array is only read once).
For the other variables (i, j, and sum): Good temporal locality (accessed more than once).
Part 3
xxxxxxxxxxxxxxxxx
Part 4
Running experiment shell script
Bash version 4.2.24(1)-release...
*** Testing algorithm 1 at array size of 256 x 256 ***
Configuration: Algorithm 1, array size 256
Total size of all 3 arrays: 1.5 MB
Result for sanity checking: c[255][255]=62.498
Floating-point ops/sec: 6.99E+08
*** Testing algorithm 1 at array size of 512 x 512 ***
Configuration: Algorithm 1, array size 512
Total size of all 3 arrays: 6 MB
Result for sanity checking: c[511][511]=133.201
Floating-point ops/sec: 4.97E+08
*** Testing algorithm 1 at array size of 768 x 768 ***
Configuration: Algorithm 1, array size 768
Total size of all 3 arrays: 14 MB
Result for sanity checking: c[767][767]=195.151
Floating-point ops/sec: 1.44E+08
*** Testing algorithm 1 at array size of 1024 x 1024 ***
Configuration: Algorithm 1, array size 1024
Total size of all 3 arrays: 24 MB
Result for sanity checking: c[1023][1023]=259.366
Floating-point ops/sec: 1.12E+08
*** Testing algorithm 1 at array size of 1280 x 1280 ***
Configuration: Algorithm 1, array size 1280
Total size of all 3 arrays: 38 MB
Result for sanity checking: c[1279][1279]=324.184
Floating-point ops/sec: 1.28E+08
*** Testing algorithm 1 at array size of 1536 x 1536 ***
Configuration: Algorithm 1, array size 1536
Total size of all 3 arrays: 54 MB
Result for sanity checking: c[1535][1535]=388.654
Floating-point ops/sec: 1.03E+08
*** Testing algorithm 1 at array size of 1792 x 1792 ***
Configuration: Algorithm 1, array size 1792
Total size of all 3 arrays: 74 MB
Result for sanity checking: c[1791][1791]=440.186
Floating-point ops/sec: 1.04E+08
*** Testing algorithm 1 at array size of 2048 x 2048 ***
Configuration: Algorithm 1, array size 2048
Total size of all 3 arrays: 96 MB
Result for sanity checking: c[2047][2047]=516.606
Floating-point ops/sec: 9.59E+07
*** Testing algorithm 2 at array size of 256 x 256 ***
Configuration: Algorithm 2, array size 256
Total size of all 3 arrays: 1.5 MB
Result for sanity checking: c[255][255]=62.498
Floating-point ops/sec: 1.40E+09
*** Testing algorithm 2 at array size of 512 x 512 ***
Configuration: Algorithm 2, array size 512
Total size of all 3 arrays: 6 MB
Result for sanity checking: c[511][511]=133.201
Floating-point ops/sec: 1.29E+09
*** Testing algorithm 2 at array size of 768 x 768 ***
Configuration: Algorithm 2, array size 768
Total size of all 3 arrays: 14 MB
Result for sanity checking: c[767][767]=195.151
Floating-point ops/sec: 1.10E+09
*** Testing algorithm 2 at array size of 1024 x 1024 ***
Configuration: Algorithm 2, array size 1024
Total size of all 3 arrays: 24 MB
Result for sanity checking: c[1023][1023]=259.366
Floating-point ops/sec: 1.11E+09
*** Testing algorithm 2 at array size of 1280 x 1280 ***
Configuration: Algorithm 2, array size 1280
Total size of all 3 arrays: 38 MB
Result for sanity checking: c[1279][1279]=324.184
Floating-point ops/sec: 1.05E+09
*** Testing algorithm 2 at array size of 1536 x 1536 ***
Configuration: Algorithm 2, array size 1536
Total size of all 3 arrays: 54 MB
Result for sanity checking: c[1535][1535]=388.654
Floating-point ops/sec: 1.06E+09
*** Testing algorithm 2 at array size of 1792 x 1792 ***
Configuration: Algorithm 2, array size 1792
Total size of all 3 arrays: 74 MB
Result for sanity checking: c[1791][1791]=440.186
Floating-point ops/sec: 1.08E+09
*** Testing algorithm 2 at array size of 2048 x 2048 ***
Configuration: Algorithm 2, array size 2048
Total size of all 3 arrays: 96 MB
Result for sanity checking: c[2047][2047]=516.606
Floating-point ops/sec: 1.10E+09