4.6k views

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

edited | 4.6k views
+1

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$
by Veteran (424k points)
edited
0
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.
0
@laser0 You are right. But why consider only instruction access and not data access? Data accesses are usually more important.
+1
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.
0
@csegate2

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)
0
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 ??
+1
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.
0

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

0
not the individual transfer time- if we reduce the block size, it might cause more no. of transfers.
0
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 ?
+3
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.
0
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?
+2
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
0
@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
0
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.
+2
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.
0
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
+4

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.

0

" 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) ..?

+11
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"?
+1
awesome (Y) example
0
Very nice analogy..:)
0

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.

ryt??

0
Yes shubhanshu incresing cache size increase miss panality but reduce miss ratio.
+1
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.
0
@dhruv   it will reduce miss rate  . miss penality will depend on other factors like block size.
0
The purpose of block offset in cache mapping is to insure spatial locality ....
0
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?
+1
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 )
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.
by Veteran (424k points)
0
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

https://en.wikipedia.org/wiki/Locality_of_reference

according to above link it is temporal
+1

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.

0
so what will be answer if we put more than one word in cache
0
We access one word- so putting more than one means neighboring data.
0
So how it is exploiting spatial locality..m nt undrrstanding?
+1
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 .
0
Ohhkk.
0
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

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.

by Active (2.5k points)
0
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 ...

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)

https://www.cs.umd.edu/class/fall2001/cmsc411/proj01/cache/matrix.html

by Active (1.2k points)