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 23 2 3 4 5 6 for (i = 31; i >= 0; i--) { for (j = 31; j total_x + total y + } } = 0; j--) { grid [i][j].x;

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 hit rate 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 23 2 3 4 5 6 for (i = 31; i >= 0; i--) { for (j = 31; j total_x + total y + } } = 0; j--) { grid [i][j].x; grid [i][j].y;

Step by Step Solution

3.47 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This loop has a nice stride1 reference pattern and thus the only misses are the initia... 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!