From: globalsk on

I can't, this is for a university project and I have to use
simplescalar's cache. It's code is kinda of documented, but not enough
in the areas I'm looking and dont seem to find any information about
this, not even in the main web page. That's why I ask here as I'm
someone might have the knowledge about all this maskings.


user923005 ha escrito:

> Instead of trying to use something that you do not have documentation
> for and you do not understand, why not try to use this, which is
> documented:
> http://www.danga.com/memcached/apis.bml

From: user923005 on

globalsk wrote:
> I can't, this is for a university project and I have to use
> simplescalar's cache. It's code is kinda of documented, but not enough
> in the areas I'm looking and dont seem to find any information about
> this, not even in the main web page. That's why I ask here as I'm
> someone might have the knowledge about all this maskings.

Did you read this stuff:
http://simplescalar.com/docs/users_guide_v2.pdf

A search on "cache" shows 78 hits in that document.

And for this one:
http://simplescalar.com/docs/hack_guide_v2.pdf

A search on "cache" shows 105 hits.

35 hits in here:
http://simplescalar.com/docs/simple_tutorial_v4.pdf

159 in here:
http://simplescalar.com/docs/simple_tutorial_v2.pdf

If (after reading these things) you do not get your answers, why not
send an email to info(a)simplescalar.com with your specific questions.

From: Barry on

"globalsk" <jmilanasue(a)gmail.com> wrote in message
news:1168392800.832029.100260(a)o58g2000hsb.googlegroups.com...
> More insight about this topic and the core of the question relies in
> this part of code also:
>
> cp->blk_mask = bsize-1;
> cp->set_shift = log_base2(bsize);
> cp->set_mask = nsets-1;
> cp->tag_shift = cp->set_shift + log_base2(nsets);
> cp->tag_mask = (1 << (32 - cp->tag_shift))-1;
> cp->tagset_mask = ~cp->blk_mask;
>
> Don't understand how this masking works.
> I know all this is later used for testing cache's hit or miss in a
> block:
>
> if (CACHE_TAGSET(cp, addr) == cp->last_tagset)
> {
> /* hit in the same block */
> blk = cp->last_blk;
> goto cache_fast_hit;
> }),
>
> But if someone can give examples with addresses and bits it will be
> clearer.
>
> All this code is for cache simulation as you can see, where you can
> define associativity and all the regular parameters for a cache.
> globalsk ha escrito:
>
> > Hello,
> >
> > I'm trying to understand this fragment of code in Simplescalar's
> > cache.c code (I've search and look over dozens sites, including
> > simplescalar.com and there's no help about the coding):
> >
> > /* cache access macros */
> > #define CACHE_TAG(cp, addr) ((addr) >> (cp)->tag_shift)
> > #define CACHE_SET(cp, addr) (((addr) >> (cp)->set_shift) &
> > (cp)->set_mask)
> > #define CACHE_BLK(cp, addr) ((addr) & (cp)->blk_mask)
> > #define CACHE_TAGSET(cp, addr) ((addr) & (cp)->tagset_mask)
> >
> > I know is about shifting and moving bits around, but don't know how and
> > specially why is done in this way and for what.
> >
> > cp is an structure for a cache
> > addr is a typedef qword_t (64 bits)
> > md_addr_t blk_mask; idem, typedef qword_t
> > int set_shift;
> > md_addr_t set_mask; /* use *after* shift */
> > int tag_shift;
> > md_addr_t tag_mask; /* use *after* shift */
> > md_addr_t tagset_mask; /* used for fast hit detection */
> >
> > Maybe this is little information, but maybe someone with the knowledge
> > about caches and this type of coding can help out. Please if someone
> > can give a helping hand about this and links where they explain in more
> > detail simplescalar's code will be very appreciated.
> >
> > Please forgive my syntax mistakes, english is not my mother tongue.
>

I don't think you have clearly expressed whether you do not
understand the C code, or how the code is attempting to simulate
a cache.

I thought it was the C code in which case you can find many
sources on bit shifting and masking with a simple web search.
Of course you can search on Kernighan & Ritchie and learn
101 more things in the process. The chances that you are
programming in C at a university and someone doesn't have a
copy of K&R you could borrow are miniscule. But if you
intend to do any C programming you should just by one.

How the simulator does is job is certainly a question for the author(s)
unless you are willing to pay someone to take the time to do it for
you. Although, if it were a common tool you would likely find
someone here willing to give help.


From: globalsk on

user923005 ha escrito:

> globalsk wrote:
> > I can't, this is for a university project and I have to use
> > simplescalar's cache. It's code is kinda of documented, but not enough
> > in the areas I'm looking and dont seem to find any information about
> > this, not even in the main web page. That's why I ask here as I'm
> > someone might have the knowledge about all this maskings.
>
> Did you read this stuff:
> http://simplescalar.com/docs/users_guide_v2.pdf
>
> A search on "cache" shows 78 hits in that document.
>
> And for this one:
> http://simplescalar.com/docs/hack_guide_v2.pdf
>
> A search on "cache" shows 105 hits.
>
> 35 hits in here:
> http://simplescalar.com/docs/simple_tutorial_v4.pdf
>
> 159 in here:
> http://simplescalar.com/docs/simple_tutorial_v2.pdf
>
> If (after reading these things) you do not get your answers, why not
> send an email to info(a)simplescalar.com with your specific questions.

Of course, I did look those up, but they dont give answers to my
cuestions.

Thanks.

From: globalsk on

Barry ha escrito:

> "globalsk" <jmilanasue(a)gmail.com> wrote in message
> news:1168392800.832029.100260(a)o58g2000hsb.googlegroups.com...
> > More insight about this topic and the core of the question relies in
> > this part of code also:
> >
> > cp->blk_mask = bsize-1;
> > cp->set_shift = log_base2(bsize);
> > cp->set_mask = nsets-1;
> > cp->tag_shift = cp->set_shift + log_base2(nsets);
> > cp->tag_mask = (1 << (32 - cp->tag_shift))-1;
> > cp->tagset_mask = ~cp->blk_mask;
> >
> > Don't understand how this masking works.
> > I know all this is later used for testing cache's hit or miss in a
> > block:
> >
> > if (CACHE_TAGSET(cp, addr) == cp->last_tagset)
> > {
> > /* hit in the same block */
> > blk = cp->last_blk;
> > goto cache_fast_hit;
> > }),
> >
> > But if someone can give examples with addresses and bits it will be
> > clearer.
> >
> > All this code is for cache simulation as you can see, where you can
> > define associativity and all the regular parameters for a cache.
> > globalsk ha escrito:
> >
> > > Hello,
> > >
> > > I'm trying to understand this fragment of code in Simplescalar's
> > > cache.c code (I've search and look over dozens sites, including
> > > simplescalar.com and there's no help about the coding):
> > >
> > > /* cache access macros */
> > > #define CACHE_TAG(cp, addr) ((addr) >> (cp)->tag_shift)
> > > #define CACHE_SET(cp, addr) (((addr) >> (cp)->set_shift) &
> > > (cp)->set_mask)
> > > #define CACHE_BLK(cp, addr) ((addr) & (cp)->blk_mask)
> > > #define CACHE_TAGSET(cp, addr) ((addr) & (cp)->tagset_mask)
> > >
> > > I know is about shifting and moving bits around, but don't know how and
> > > specially why is done in this way and for what.
> > >
> > > cp is an structure for a cache
> > > addr is a typedef qword_t (64 bits)
> > > md_addr_t blk_mask; idem, typedef qword_t
> > > int set_shift;
> > > md_addr_t set_mask; /* use *after* shift */
> > > int tag_shift;
> > > md_addr_t tag_mask; /* use *after* shift */
> > > md_addr_t tagset_mask; /* used for fast hit detection */
> > >
> > > Maybe this is little information, but maybe someone with the knowledge
> > > about caches and this type of coding can help out. Please if someone
> > > can give a helping hand about this and links where they explain in more
> > > detail simplescalar's code will be very appreciated.
> > >
> > > Please forgive my syntax mistakes, english is not my mother tongue.
> >
>
> I don't think you have clearly expressed whether you do not
> understand the C code, or how the code is attempting to simulate
> a cache.
>
> I thought it was the C code in which case you can find many
> sources on bit shifting and masking with a simple web search.
> Of course you can search on Kernighan & Ritchie and learn
> 101 more things in the process. The chances that you are
> programming in C at a university and someone doesn't have a
> copy of K&R you could borrow are miniscule. But if you
> intend to do any C programming you should just by one.
>
> How the simulator does is job is certainly a question for the author(s)
> unless you are willing to pay someone to take the time to do it for
> you. Although, if it were a common tool you would likely find
> someone here willing to give help.

Hello is more about how the code is attempting to simulate a cache and
how it does it with all this masking and shifting (I now what the
instructions do but don't understand why). Of course the author could
answer it but is not likely, more likely is to find someone with a
little knowledge on cache, which for whom it will be pretty easy to
answer I think, don't have to be an expert. I myself is the first time
I have to touch something related with a cache and is taking some
effort fo find answers.

Thanks