Question: Using the sample program results in Figure 5.33: a. How many levels of cache are there? b. What are the overall size and block size
a. How many levels of cache are there?
b. What are the overall size and block size of the first-level cache?
c. What is the miss penalty of the first-level cache?
d. What is the associativity of the first-level cache?
e. What effects can you see when the size of the data used in the array is equal to the size of the second-level cache?
-1.png)
-2.png)
-3.png)
Figure 5.32 C program for evaluating memory systems.
-4.png)
Figure 5.33 Sample results from program in Figure 5.32.
#include "stdatx.h" #1 nclude #include #define ARRAY MIN (1024) /* 1/4 smallest cache * #define ARRAY-MAX (4096*4096)/* 1/4 largest cache */ int x[ARRAY MAX]; /* array going to stride through */ double get seconds/ routine to read time in seconds */ time64 t 1time time64<ime return (double) 1time; int label (int )/generate text labels if (icle3) printf("%18,",i); else if (le6) printf (1dK1/1024) else if le9) printf(1dM,i/1048576); else printf(1,",i/1073741824); return 0 int tmain int argc, TCHAR argv 0) int register nextstep, i, index, stride; int csize double steps, tsteps; double loadtime lastsec, seco, secl, sec; /* timing variables */ /Initialize output/ rintf(,"); or (stride, stride ARRAY MAX/2; stride=stride*2) label (stride sizeof int)); printf("n") * Main loop for each configuration * for (csize-ARRAY MIN; csizee ARRAY X csize-csize*2) [ label (csize sizeof (int); /* print cache size this loop / for (stride- stride csize/2; stride-stride*2) t /Lay out path of memory references in array * or index-0; index < csize index-index+stride x(index] = index + stride; /* pointer to next */ x[index-stride] 0; /* loop back to begning * Wait for timer to roll over/ astsec = get seconds(); do seco get seconds while (sec lastsec); /* Walk through path in array for twenty seconds / * This gives 5% accuracy with second resolution * steps 0.0; /number of steps taken */ nextstep 0 start at beginning of path seco get seconds 0 start timer* do /repeat until collect 20 seconds */ for (i-stride;i1-0-1-1) / keep samples same / nextstep0; do nextstepx [nextstep]: /* dependency while (nextstep 0); steps steps + 1.0; /* count loop iterations */ ec get seconds; / end timer/ ) while ((secI sec020.0) / collect 20 seconds / sec seci - sec0; Repeat empty loop to loop subtract overhead/ steps 0.0used to match no. while iterations/ dec ge eacont? same start iterations as ave do /*repeat until same no. iterations as above/ for (istride;il 0;--1) keep samples same/ index- 0 do indexindex stride while index < csize); tsteps = tsteps + 1.0; sec get seconds ); /* overhead/ } while (tsteps-steps); /* until no. iterations * sec sec (sec sec0 loadtime(sec e9)/(steps csize) / write out results in.csv format for Excel/ printf("%4.lf,", (loadtime
Step by Step Solution
3.40 Rating (169 Votes )
There are 3 Steps involved in it
a There are two levels of cache b The firstlevel cache is 32 KB and ha... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
903-C-S-S-A-D (3218).docx
120 KBs Word File
