CS代考 COMP30023: Computer Systems

School of Computing and Information Systems
COMP30023: Computer Systems

Practical Week 4

Copyright By PowCoder代写 加微信 powcoder

1 Spatial & Temporal Locality
The principle of spatial locality says that if a program accesses one memory address, there is
a good chance that it will also access other nearby addresses. CPU caches take advantage of
this by reading in cache lines from physical memory and reading from the CPU cache is order
of magnitudes faster than actually reading from Physical RAM1.
Write two programs, fast.c and slow.c, which access or modify a two dimensional array in
a way that is fast (exhibits spatial locality) and slow (does not exhibit spatial locality) respec-
Ensure that fast takes at least 0.3 seconds to run.

You may want to use the time command, e.g. $ time ./slow , to measure the time it takes
for a program to finish.

The principle of temporal locality states says that if a program accesses one memory address,
there is a good chance it will access the same memory address again.
Write another pair of programs, fast-temp.c and slow-temp.c, which access or modify a one
dimensional array in a way that is fast (exhibits temporal locality) and slow respectively.

Sample solutions will be later released.
1https://gist.github.com/jboner/2841832

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com