Search code examples
gem5

Using a Skewed Associative Cache in Gem5


I am trying to learn how to implement an L2 cache with a skewed associativity. I see there is already implemented classes for skewed associativity (skewed_associative.cc/hh) under /gem5/src/mem/cache/tags/indexing_policies/ and i would like to use this to start off with.

What I do not understand is how to access those files and specify a given cache to act as a skewed associative. Do I need to create an entire new cache class that inherits from the basecache? Or is there a way to do it through implementing a new tag?

I'm still trying to figure out how gem5 has anything structured/works, so any amount of help or links would be greatly appreciated.


Solution

  • The above comments helped lead to a solution.

    When instantiating a given cache, assign its tags' indexing_policy as SkewedAssociative()

    in configs/common/CacheConfig.py:

    Instead of having:

    system.l2 = l2_cache_class(clk_domain=system.cpu_clk_domain, **_get_cache_opts('l2', options))
    

    you'd have

    system.l2 = l2_cache_class(clk_domain=system.cpu_clk_domain, tags=BaseSetAssoc(indexing_policy=SkewedAssociative()), **_get_cache_opts('l2', options))