Read about Cachegrind 1 which is a tool for simulating cache and branch misses in a program.
Question:
Read about Cachegrind 1 which is a tool for simulating cache and branch misses in a program. Examine the attached toy example BP test toy.c and understand how it works. Your task is to modify the BP test toy.c code such that the number of miss predictions is significantly reduced. • Compile the code with gcc using no optimization options (i.e., “-O0”) using the command: > gcc -O0 BP test toy.c -o BP toy • Observe the branch miss predict rate using: > valgrind --tool=cachegrind --branch-sim=yes ./BP toy M N #iter • Modify the code for reducing the branch miss predict rate and run cachegrind again. • Report the runtime, as well as the miss, predict rate before and after your modification. • Use different N, M and #iter values in your tests. Prepare a table with initially the following inputs: M = 100, N = 1000000, #iter = 3, M = 500, N = 1000000, #iter = 10, M = 2000, N = 200000, #iter = 5, You can add mode test cases to the table. • Explain the reasoning behind your modification to the code and how it affected the performance