Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is the code : #include #include #include int main(int argc, char *argv[]) { if( argc , argv[0]); int M = atoi(argv[1]); int N =

image text in transcribed

this is the code :

#include #include #include

int main(int argc, char *argv[]) { if( argc ", argv[0]); int M = atoi(argv[1]); int N = atoi(argv[2]); int nIter = atoi(argv[3]); int **arr, i, j; arr = malloc(sizeof(*arr) * M); clock_t start, end; for (i = 0; i 0){ for (i = 0; i Task #2: Branch prediction (50pts) Read about Cachegrind ? 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 gce using no optimization options (i.e., "-00") using the command: > gcc -00 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. Task #2: Branch prediction (50pts) Read about Cachegrind ? 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 gce using no optimization options (i.e., "-00") using the command: > gcc -00 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago