Log In
29 votes

More than one word are put in one cache block to:

  1. exploit the temporal locality of reference in a program
  2. exploit the spatial locality of reference in a program
  3. reduce the miss penalty
  4. none of the above
in CO and Architecture
edited by

5 Answers

73 votes
Best answer
Exploit the spatial locality of reference in a program as, if the next locality is addressed immediately, it will already be in the cache.

Consider the scenario similar to cooking, where when an ingredient is taken from cupboard, you also take the near by ingredients along with it- hoping that they will be needed in near future.

Correct Answer: $B$

edited by
instructions are stored in sequential manner.
an instruction i of s byte s feched from memory. first it transfer from memory to cache.
let cache block size is s byte then only that instructions will be in cache.
next instructions i.e. i+1 again cache miss.
but if more than one word put into one block or cache block is capable to store more than one word then fetching instruction i from memory results both instructions i and   i+1 (may be some more) ll be in cache.
@laser0 You are right. But why consider only instruction access and not data access? Data accesses are usually more important.
sir normally instructions are sequential (untill unless branch) thats why m taking instructions as example.

same concept for accessing sequential data i.e. array access.. Eements of an array are neighbors in memory, and are likely to be referenced one after the other.

Consider the access of array[0] and array is of of int type of size 4 bytes.

Now, if the cache line is say 64 bytes, array[0] - array[15] are brought from memory to cache.

So, if the next accesses are array[1] or array[2] or any index till 15, we have a cache hit.

Whether array[1] or array[2] will be accessed after array[0] access? That is what spatial locality says. (Temporal locality means array[0] will be accessed again in near future)
As the bus that transfers data are of size = one word , then increasing Block size also increases Block transfer time, So, why can't block size be smaller and remaining words, if referenced , be fetched later ??
thats an optimization problem and this is usually done - minimize the transfer time, maximize the locality and that is how block size is fixed for a given architecture.

means somehow transfer time of chunk of words can be less than then the case when transferred individually.. 

not the individual transfer time- if we reduce the block size, it might cause more no. of transfers.
yes , more no. of Transfers but Suppose we transfer a block of size n word..Then let's say transfer time of this block be n*time for one word transfer

And in another case if we transfer 2 Blocks of n/2 words each then total time would be

2* n/2 * time to transfer one word , total time remains same.

However this case incurs two transfers.. but how more transfers degrade performance if time is same ?
because if we have 2 transfers, 2 instructions are getting stalled. And if the transfer time is doubling with block size as you gave, usually block size won't be increased- the transfer time involves identifying the block and transferring the words (in a pipeline fashion) and hence doubling the block size won't be doubling the transfer time.
Sir why not C) true?

means if we put more words in cache block , then no need to go main memory to find that word . So, miss rate of cache also reduced , Is not it?
miss penality will increase, because as the block size increase, if theres a miss and copying in out large blocks will take large read time from MM and copy time in that case , so large miss penality
@Arjun sir ,

sir in that array[0] example you have told that whether array[1] or array[2] will be accessed after array[0] access that is spatial locality says .but all array blocks are mapped to different cache lines means array[0] or array[1] belong to different block whether  locality  of reference is about the referred word or the  neighboring word of the same block.

 the referred word by the processor will be accessed again in future  that temporal locality says and spatial locality says about the surrounding words of the same block .

sir please correct me ..thanxx
sir when any word is being referred by  the cpu then the  block in which that word is present is brought in the cache if the size of main memory block and cache block size is same.

then my question is "when the complete block is  coping  to cache then what does it mean by putting more than one word in the block."

.please explain  i am very much confused.
Just forgot all cache concepts and imagine you designing a cache. When a word is accessed by processor and is not present in cache, you have the option of bringing that word alone or a group of word including that word to cache from the main memory. Which would you choose? If you choose the second then the reason must be spatial locality.
Yeah .. now I got it . Thank  you sir .

Please send me some link  where  I can read locality of reference  in detail  ... actually  now I am curious  to know  more about it ... thank  u sir once again

Analysis of large number of programs has shown that a number of instructions are executed repeatedly. This may be in the form of a simple loops, nested loops, or a few procedures that repeatedly call each other. It is observed that many instructions in each of a few localized areas of the program are repeatedly executed, while the remainder of the program is accessed relatively less. This phenomenon is referred to as locality of reference.

In simple words Locality is a fancy way of saying data that is ‘close together’ either in time(Temporal Locality) or space(Spatial Locality).

Temporal locality : Data which is used recently may be used again in near future.

Spatial locality : Data near to currently accessed data may be accessed in near future.


" exploit the spatial locality of reference in a program "

IT is actually done just to reduce the miss penalty..then why not answer is (C) ..?

We go to school to study which helps us in getting a job. Now if someone asks "why do you go to school?" should we say "to study" or "to get a job"?
awesome (Y) example
Very nice analogy..:)

Can we say like this:-

More than one word are put in one cache block will reduce the miss ratio, but on the other hand it will also increase the miss penalty.


Yes shubhanshu incresing cache size increase miss panality but reduce miss ratio.
Thanks Anu!!

Increasing cache size decrease miss ratio is sure, but it will affect miss penalty is not sure in case of simultaneous access because it depends on the size of next level memory. If that memory is large then the searching time will be more, hence miss penalty will be more.
@dhruv   it will reduce miss rate  . miss penality will depend on other factors like block size.
The purpose of block offset in cache mapping is to insure spatial locality ....
Suppose if we knew what words (assume these are at random locations) to put into cache, then we can reduce miss penalty. In this case, we neither use spatial nor temporal locality. Is this right?
why not temporal locality?:

exploit the temporal locality of reference in a program as, if the cache manager is intelligent enough to predict that time to time a particular conditional jump result in fetching of jump target instructions stored far apart from sequential access and thus caching it

Consider I am preparing food. I know after every 20 minutes I need to have a sip of a pepsi and pepsi can is stored far away in fridge away from cooking incgridients. So keep in near me on kitchen desk. (ignore that pepsi will loose its chillness ;p )
6 votes
When a word is accessed, we take a block of word and put in cache expecting words in that block to be accessed in nearby time- which is spatial locality.
sir it is temporal locality in above u have said  because in temporal locality it is related to near by time i cant understand plzz

according to above link it is temporal

from your link copied "Temporal locality refers to the reuse of specific data, and/or resources, within a relatively small time duration. Spatial locality refers to the use of data elements within relatively close storage locations."

temporal says same data will be accessed again in near future while spatial says the near data will be accessed. 

so what will be answer if we put more than one word in cache
We access one word- so putting more than one means neighboring data.
So how it is exploiting spatial locality..m nt undrrstanding?
exploitation means . make use of. so it make use of spacial locality. i.e next reference is near to the accessed element in term of space .
Option says "spatial locality of reference **in a program**" not **in a block**. And I guess there is no such thing as spatial locality within block since block is target not source.
1 vote
Temporal locality refers to the reuse of specific data and/or resources within relatively small time durations. Spatial locality refers to the use of data elements within relatively close storage locations.
To exploit the spatial locality, more than one word are put into cache block.
–1 vote

Question seems wrong. Let me explain.

First two points are:

"temporal locality of reference in a program"

"spatial locality of reference in a program"

Notice that they say "in a program". Now I guess both are true. For sequential instructions in program, spatial locality of reference will be exploited. It is somewhat not straightforward to imagine how temporal locality of reference can be exploited. WIkipedia definition of temporal locality:

If at one point a particular memory location is referenced, then it is likely that the same location will be referenced again in the near future. 

Its incorrect to think that any program cannot exhibit above behavior. (For example for non sequential instructions say conditional jumps instructions, temporal locality of reference will be exploited.) And its incorrect to say that cache manager will not be able to predict such behavior and cache the more probable instructions out of sequential access (say jump target instruction). So temporal locality can very well be exploited.

In fact I feel any kind of locality of reference be exploited. Its just that cache manager needs to have that much of intelligence of what to cache and what not to. So saying that just XType of locality reference is exploited seems incorrect, since it negates possibility of exploiting other types of locality of references. 

Option C is straight wrong. Miss ratio is reduced, not miss penalty. But are we supposed to make that difference between miss ratio and penalty?

I guess I will leave this question and will not attempt.

I will like someone proves me wrong.

understand the question .... this line "More than one word are put in one cache block" is enough to say its  spatial locality .... instructions r stored in sequential manner .... the purpose of block offset in cache mapping is to ensure spatial locality ...
–5 votes

I guess the answer is D .

As we stuff words into blocks as block is a unit of data access .
This should have no relation between temporal/spatial locality /miss penalty . 

It is an issue of memory being organized that way . 

If the question was about transfer of data from memory to cache , (as in why data transfer takes place in blocks,not words)
then it should be B)


Related questions

21 votes
2 answers
A CPU has $32-bit$ memory address and a $256 \ KB$ cache memory. The cache is organized as a $4-way$ set associative cache with cache block size of $16$ bytes. What is the number of sets in the cache? What is the size (in bits) of the tag field per ... bits are required to find the byte offset within a cache block? What is the total amount of extra memory (in bytes) required for the tag bits?
asked Sep 15, 2014 in CO and Architecture Kathleen 4.6k views
22 votes
3 answers
The performance of a pipelined processor suffers if: the pipeline stages have different delays consecutive instructions are dependent on each other the pipeline stages share hardware resources All of the above
asked Sep 16, 2014 in CO and Architecture Kathleen 4.3k views
18 votes
6 answers
Raid configurations of the disks are used to provide Fault-tolerance High speed High data density (A) & (B)
asked Sep 23, 2014 in Operating System Kathleen 5k views
23 votes
2 answers
Let a decision problem $X$ be defined as follows: $X$: Given a Turing machine $M$ over $\Sigma$ and any word $w \in \Sigma$, does $M$ loop forever on $w$? You may assume that the halting problem of Turing machine is undecidable but partially decidable. Show that $X$ is undecidable Show that $X$ is not even partially decidable
asked Sep 15, 2014 in Theory of Computation Kathleen 1.7k views