need help with cache homework~!

Hey people,

I am new to this forum and here for desperate need of help…

I have this assignment due very soon and I am having trouble understanding and approaching it…starting from Part 1 below…

Thanks in advance!

Part 1:

Create an address stream with good spatial locality but bad temporal locality called SpatialStream.txt. Then create a stream that has good temporal locality but bad spatial locality called TemporalStream.txt. Each stream must have at least 100 accesses in it.

// What do they mean by creating an address stream with 100 accesses in it???
I have somewhat an idea of what spatial and temporal locality is but don’t know how to interpret it to an address stream… please help!

Part 2:

Begin by writing a simple cache simulator in cache.c. This direct-mapped cache receives the cache size and line size for initialization.
2.

Write a simulator for the cache in cachesim.c. The simulator runs by reading in from a file. This file contains the address stream the cache sees. Each address is an integer, written in ascii characters. Each address represents an access into the cache. The simulator reports the # of accesses and miss rate at the end of the simulation.
3.

Run the simulation on each address stream with the following cache configurations:

Cache Size Line Size
64 4
64 2
64 1
128 4

Deliverables:

  1. TemporalStream.txt
  2. SpatialStrem.txt
  3. Make two graphs - one that graphs the different address streams with varying sizebut constant line size, and another that graphs the different address streams with varying line size but constant size. Graph the miss rates.
  4. cache.c
  5. cachesim.c

Thank you everyone! Any help will be greately appreciated!

As a warning, there are some great programmers here, and many if not all will be happy to point you in the right direction or answer any specific questions you may have, but I guarantee you will not get your homework done for you here.

In the context of a memory cache, an address stream would be a list of memory access events. Each access is to a specific address at a specific time. A typical system can have many address streams mixed in with each other, and one of the jobs of a good cache manager is to detect patterns in the stream and split out certain accesses into separate streams.

Yeah Vikesrock… I think i know that. I’m just looking for help on some kind of approach like Alan who posted after you who generously did. Thank you Alan.

I was just making sure, I was not accusing you of anything. People stumble in here every once in a while expecting to have their homework done for them.

I am glad that you were able to find some help here ( I would have helped myself if I had any idea what you were talking about, my programming knowledge is really small and mostly covers embedded systems)

Alan, it’s people like you who remind me daily that I don’t know a sliver of what there is to learn, Thanks!:cool:

it’s ok man. Just stressing to get something done thats all. I think we’ve all been there. haha

Heh, and I know even less, just a PDU. But, if someone reading this actually understands the original question, tell me how close I am with my guesses:

  1. A text file of an address stream would be merely a list of addresses and timestamps, right?
  2. If so, a stream with “good spatial locality but poor temporal locality” would just be a list with a wider range of addresses over a very short period of time - right? Or is it the other way around, addresses near each other over a long time?
    (2a - Good temporal and bad spatial is the opposite I guess)

The rest - I only wish I knew. It sounds like something cool to know, but all I know about cache is that bigger can be better, but optimization is critical.

Don

For all that are lost, Wikipedia is your friend - as always.

from Locality of reference - Wikipedia

In computer science, locality of reference, also known as the principle of locality, is the phenomenon of the same value or related storage locations being frequently accessed. There are three basic types of locality of reference: temporal, spatial and sequential:

Temporal locality
Here a resource that is referenced at one point in time is referenced again soon afterwards.
Spatial locality
Here the likelihood of referencing a storage location is greater if a storage location near it has been recently referenced.
Sequential locality
Here storage is accessed sequentially, in descending or ascending order.
Don, awesome deriving skills! :slight_smile:

My robocoach says I’m a pretty good deriver…:smiley:

Anyhow, I had it backwards: Good spatial locality is addresses near each other, and good temporal locality is close in time. What i described was spatial / temporal diversity.

Diversity is a good thing, except in caching I suppose.

Thanks for the explanation, I shoulda’ thoughta’ the wikipedia’

Don

.