Homework #1 - Up to 10 Points of class grade

Part 1
Modify the following program to measure and report the time taken to execute the for() loop in the most-precise and most-accurate way possible. Your version may execute the for() loop as many times as you would like, but only a single value (the time to run 1234567890 iterations of this loop) should be reported in the end.
volatile int x = 0;
int main(int argc, char* argv[]) {
  for(int y=0; y<1234567890; ++y) ++x;
  return x;
}
Part 2
Extend your program to determine how many data cache levels there are in the CPU and what is the hit time of each level by using the accurate and precise mechanism to measure how long a loop runs. Your program may run as long as you would like, performing time measurements of any number of loops containing memory accesses and/or arithmetic computations. The output should resemble the following:
123..890 Loop: 2500000000ns
Cache Latencies: 2ns 6ns 20ns 150ns
Part 3
Extend your program to measure and report the block size of each cache, the number of sets in each cache, the associativity of each cache, and compute the total capacity of each cache. The output should resemble the following:
123..890 Loop: 2500000000ns
Cache Latencies: 2ns 6ns 20ns 150ns
Caches: 64/256x4(64KB) 64/512x8(256KB) 128/8192x24(12MB)
Part 4
TBD