4. In this question, we consider the relative performance obtained by running a particular program with various caches installed between the memory and the CPU. Consider the following C function: char...


4. In this question, we consider the relative performance obtained by running a particular program<br>with various caches installed between the memory and the CPU.<br>Consider the following C function:<br>char a [512], b[512]<br>add_arrays () {<br>register int i;<br>for (i = 0; i < 511; i = i+1) {<br>a[i+1] = a [i] + b[i]; // Work!!<br>}<br>9 }<br>(The register keyword tells the C compiler to reserve a register for the variable i; let's assume<br>it keeps i in RO. What does this mean for us? The variable i is not stored in main memory-<br>it's stored in the CPU; this mean that it never has to be pulled from main memory into the<br>cache when the CPU accesses it.<br>The char keyword allocates character arrays at fixed locations in memory, using 1 byte per<br>character.)<br>Recall that in C, an array is a contiguous chunk of memory. Therefore, in this code, array a<br>starts at some address (say, 0x00A), and ends at (start address) + n-sizeof (char) address,<br>where n is the number of elements and sizeof (char) is the number of bytes a char takes<br>in memory (and in this example, we're using char because it's 1 byte and makes calculating<br>simple!).<br>For the following questions, assume that the memory can read or write 1 byte at a time.<br>

Extracted text: 4. In this question, we consider the relative performance obtained by running a particular program with various caches installed between the memory and the CPU. Consider the following C function: char a [512], b[512] add_arrays () { register int i; for (i = 0; i < 511;="" i="i+1)" {="" a[i+1]="a" [i]="" +="" b[i];="" work!!="" }="" 9="" }="" (the="" register="" keyword="" tells="" the="" c="" compiler="" to="" reserve="" a="" register="" for="" the="" variable="" i;="" let's="" assume="" it="" keeps="" i="" in="" ro.="" what="" does="" this="" mean="" for="" us?="" the="" variable="" i="" is="" not="" stored="" in="" main="" memory-="" it's="" stored="" in="" the="" cpu;="" this="" mean="" that="" it="" never="" has="" to="" be="" pulled="" from="" main="" memory="" into="" the="" cache="" when="" the="" cpu="" accesses="" it.="" the="" char="" keyword="" allocates="" character="" arrays="" at="" fixed="" locations="" in="" memory,="" using="" 1="" byte="" per="" character.)="" recall="" that="" in="" c,="" an="" array="" is="" a="" contiguous="" chunk="" of="" memory.="" therefore,="" in="" this="" code,="" array="" a="" starts="" at="" some="" address="" (say,="" 0x00a),="" and="" ends="" at="" (start="" address)="" +="" n-sizeof="" (char)="" address,="" where="" n="" is="" the="" number="" of="" elements="" and="" sizeof="" (char)="" is="" the="" number="" of="" bytes="" a="" char="" takes="" in="" memory="" (and="" in="" this="" example,="" we're="" using="" char="" because="" it's="" 1="" byte="" and="" makes="" calculating="" simple!).="" for="" the="" following="" questions,="" assume="" that="" the="" memory="" can="" read="" or="" write="" 1="" byte="" at="" a="">
(f) Suppose we use a 2-way, 256-set (that is, 512-byte) set-associative cache with a block size<br>of 1 byte. The timing specifications are the same as in Part (c). A quasi-LRU replacement<br>strategy is used, replacing the least recently used element within the set. Does this cache<br>help any? What is the average memory overhead now for this instruction? Explain.<br>

Extracted text: (f) Suppose we use a 2-way, 256-set (that is, 512-byte) set-associative cache with a block size of 1 byte. The timing specifications are the same as in Part (c). A quasi-LRU replacement strategy is used, replacing the least recently used element within the set. Does this cache help any? What is the average memory overhead now for this instruction? Explain.

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here