Question: Effects of associativity 3 . Write a simple C program for which a 4 - way associative cache has a significantly lower miss rate than
Effects of associativity
Write a simple C program for which a way associative cache has a significantly lower miss rate than an equally sized way set associative cache. It will be easiest if you use blockSizec as a starting point. You may choose any cache size and block size you wish, but they must remain the same for the entire problem.
Hints for writing programs with a specified cache behavior:
You need not loop through the entire array. Instead, find addresses that collide in the cache. Remove the inner loop and make NUMLOOPS 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. This is basically a pencilandpaper problem that we happen to be using a cache simulator to verify.Write the simplest program you can that will produce a miss rate for the way cache.
Submit the source code, all cache parameters, and resulting hit rates.
Write a simple C program for which an associativity of has a higher miss rate than a directmapped cache. You may choose any cache size and block size you wish, but they must remain the same for the entire problem.
Submit the source code, all cache parameters, and resulting hit rates.
Hints:
As with the previous problem, start by writing a program that has a miss rate for a way cache.Look for addresses that conflict in a twoway cache, but do not conflict in a directmapped cache.
Explain why your code above produces the miss rates observed ie why your code has a higer miss rate on the twoway cache
Next, we will monitor the effect of associativity on a more realistic program quicksort.
Choose a cache size and leave this constant for all of the runs.The qsort executable and sample inputs are found in ~lalejinaqsortUse inpute for input. It contains randomly generated integers.Copy qsort and inpute from ~lalejinaqsort into your current directory.The full command you are testing is
qsort inpute
Run this command through Cachegrind as you did in problem to monitor the cache behavior. However, this time you will be varying the block size and degree of associativity ie you will need a double loopThis program may take a few seconds to run.Produce a graph showing miss rates as associativity ranges over and fully associative. Your graph should have associativity on the xaxis and missrate on the yaxis. There should be four lines one per block size. Be sure to clearly label your graph with the cache size.You are welcome to plot the data in whatever program you prefer.
Submit this plot as your answer to
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
