Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This problem tests your ability to predict the cache behavior of C code. You are given the following code to analyze: 1 int x[2][128]; 2

This problem tests your ability to predict the cache behavior of C code. You are given the following code to analyze:

1 int x[2][128];

2 int i;

3 int sum = 0;

4

5 for (i = 0; i < 128; i++) {

6 sum += x[0][i] * x[1][i];

7 }

Assume we execute this under the following conditions:

sizeof(int) = 4

Array x begins at memory address 0x0 and is stored in row-major order

In each case below, the cache is initially empty

The only memory accesses are to the entries of the array x. All other variables are stored in registers.

Given these assumptions, estimate the miss rates for the following cases:

A. Case 1: Assume the cache is 512 bytes, direct-mapped, with 16-byte cache blocks. What is the miss rate?

B. Case 2: What is the miss rate if we double the cache size to 1024 bytes?

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

More Books

Students also viewed these Databases questions