Lab 3 - Caches

Due: Wednesday at noon

You may work in groups on this lab. Make sure all lab members put their name on the writeup. It is also useful to put an entry in the Note section on Moodle that lists your lab partners.

This lab will investigate the cache performance on Sleipnir using code provided by Dr. Marc Thomas. You can retrieve the code from the following directory: www.cs.csub.edu/~melissa/cs321-w15/lab3/

Make sure to copy every file from that directory, including the Makefile. To compile all of the programs for this lab, give the command:

make all

Program 1 - cache_info

This program prints out information about the cache on the current system. On Linux systems, this information can also be found in the /sys subsystem in the directories:
/sys/devices/system/cpu/cpu*/cache/index*/
Run the code with the command
./cache_info

Program 2 - cache_off

This program defeats the L2 cache on Sleipnir to give really poor memory bandwidth (e.g. poor performance). Run the program with
./cache_off
Note the poor performance, as this might be useful when evaluating the next program, which is the bulk of this lab.

Program 3 - cache

This program allocates a very large array and then accesses indexes using a skip amount specified on standard in to the program. For example, if you specify a skip amount of 127, it will access j, then j+127, and so on. For this portion of the lab, we will investigate the effects of giving different skip values (the line_offset variable in the program).

To run this program, you will give the following shell command:

while true; do echo "127" | ./cache | grep Bandwidth; sleep 10; done
where 127 is the skip value. Let this loop run for about a dozen iterations before hitting CTRL-C, so that you can gather an observed average (removing any outliers that may have been caused by other running programs). The results of the last iteration will be stored in the logfile cache_<skipValue>.log

Use the following skip values when running the program (note that these are pairs of similar numbers where the second number is a power of 2 and the first number is a prime close to the second number):

127   128  251  256  509  512  1021  1024  2039  2048  4093  4096

Lab Writeup

Create a table of the number of runs, and the maximum, minimum, average, and standard deviation for the memory bandwidth in each of the runs of the cache program that was requested above.

Note any trends between the pairs of values (e.g. between 127 and 128 or between 1021 and 1024) you saw when compiling this table. Try to explain these trends.

Upload your writeup to Moodle.