Question: Now, write a C program for which the miss rate is considerably higher for a 6 4 - byte block than for a 3 2
Now, write a C program for which the miss rate is considerably higher for a byte block than for a byte block. The easiest way to do this is to find two array locations that conflict with a byte block, but not with a byte block. If you do this, you will see the cache with the byte blocks have a nearly miss rate while the cache with the byte blocks has nearly a miss rate.
You may not change the associativity or overall cache size. List your source code, all cache parameters used, and the resulting hit rates.
Hint: You need not loop through the entire array. Instead, find two addresses that collide in the cache. Remove the inner loop and make NUMLOOPS
Hint for writing programs with a specified cache behavior:
Notice in blockSizec that array is an array of characters; therefore, each item in the array is exactly byte. As a result, it is easy to identify data items that will or will not conflict in the cache. For example, in an KB directmapped cache, array bytes and will conflict. Your job is to find sets of array elements that conflict with a byte block, but not a byte block. This is basically a pencilandpaper problem that we happen to be using a cache simulator to verify
ieKB The array needs to be at least twice the size of the
KB cache so that the array doesn't fit in memory.
#define ARRAYSIZE
#define NUMLOOPS
Notice that the array is an array of characters. This means that
each item in the cache is exactly byte. This makes it easy to
identify data items that will or will not conflict in the cache.
For example, in an KB directmapped cache, array bytes and
will conflict.
This program simply iterates through each byte in the cache NUMLOOPS
times.
Declaring the local variables as "register" variables encourages
the compiler to keep the values of these variables in a register,
thereby reducing their effect on the cache hit rate.
int main
Alignas make sure that the array aligns with the cache.
char arrayARRAYSIZE;
register int outerloop;
register int innerloop;
register int solution ;
for outerloop ; outerloop NUMLOOPS; outerloop
for innerloop ; innerloop ARRAYSIZE; innerloop
solution arrayinnerloop;
return solution;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
