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](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1698/2/2/7/2366538e4242e33e1698227234376.jpg)
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 =](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1698/2/2/3/5826538d5dec94d11698223576454.jpg)
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;](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1698/2/2/3/6326538d610910cf1698223631235.jpg)
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
The key to this problem is noticing that the cache can only hold 12 of the array S... View full answer
Get step-by-step solutions from verified subject matter experts
