Question: Given the assumptions of Practice Problem 6.18, determine the cache performance of the following code: A. What is the total number of reads? B. What

Given the assumptions of Practice Problem 6.18, determine the cache performance of the following code:

1 2 3 4 5 6 for (i = 31; i >= 0; i--) { } for(j= 31; j = 0; j--) { total_x += grid [j] [i].x; total_y += grid

A. What is the total number of reads?

B. What is the total number of reads that hit in the cache?

C. What is the hit rate?

D. What would the miss hit be if the cache were twice as big?

Problem 6.18

The heart of the recent hit game SimAquarium is a tight loop that calculates the average position of 512 algae. You are evaluating its cache performance on a machine with a 2,048-byte direct-mapped data cache with 32-byte blocks (B = 32). You are given the following definitions:

1 2 3 4 5 6 7 8 struct algae_position { int x; int y; }; struct algae_position grid [32] [32]; int total_x =

You should also assume the following:

. sizeof(int) = 4.

. grid begins at memory address 0.

. The cache is initially empty.

. The only memory accesses are to the entries of the array grid. Variables i, j, total_x, and total_y are stored in registers.

Determine the cache performance for the following code:

1 2 WN 3 4 5 6 789 10 11 for (i = 31; i >= 0; i--) { } for (j = 31; j >= 0; j--) { total_x += grid [i][j].x;

1 2 3 4 5 6 for (i = 31; i >= 0; i--) { } for(j= 31; j = 0; j--) { total_x += grid [j] [i].x; total_y += grid [j] [i].y; }

Step by Step Solution

3.40 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The key to this problem is noticing that the cache can only hold 12 of the array S... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Systems A Programmers Perspective Questions!