CS140 Lab 11 - Profiling 2

Objective

  • Learn about profiling tools.
  • Use valgrind to profile a sample program.

Background

valgrind

Required Tasks

  1. Log into your Linux account on one of the CS machines.
  2. Create a directory for your lab11 experiments.
  3. Create a program from the following code.



#define N 200
char stuff[N][N];


int main(int argc, char **argv) {


    int i,j;
    int sum = 0.0;
    for(i=0; i<N; i++) {
        for(j=0; j<N; j++) {
            sum+= stuff[i][j];
        }
    }


    printf("The sum is %d", sum);

}

Profile your executable with valgrind



Look at the CacheLab writeup for how to use Valgrind. I suggest sending the output to a file to examine easier.

Task:
    Profile the output of this program. Examine the LOAD memory instructions and note the stride of memory load access.
      Switch the order of the for loops. Profile the output from the switched loops. Examine the output from Valgrind and note the stride of memory access.
    • Write a text file report of less than 5 sentences describing the results of your experiment.

      Lab Submission



      • A text file describing the results of your experiment.
      This submission is due by the end of the lab session.