Search code examples
gem5

Gshare branch predictor for gem5


I want to use Gshare in gem5. I have found the source code and instructions here. Unfortunately, the GshareBP option didn’t appeared on gem5’s branch predictor list. Any ideas?


Solution

  • The list is generated from the Python classes. The author forgot to add the Python declarations of the parameter classes, so you will have to do that yourself.

    For example, GShareBP needs the parameters localPredictorSize and localCtrBits, so you will need to add the following class src/cpu/pred/BranchPredictor.py (this is just an example; I don't know the actual values of the parameters):

    class GShareBP(BranchPredictor):
        type = 'GShareBP'
        cxx_class = 'GShareBP'
        cxx_header = "cpu/pred/gshare.hh"
    
        localPredictorSize = Param.Unsigned(2048, "Size of local predictor")
        localCtrBits = Param.Unsigned(2, "Bits per counter")
    

    You will also need to inform that gshare.cc must be compiled (in src/cpu/pred/SConscript):

    Source('gshare.cc')
    

    You will face a lot of errors after doing that; that code was written for 2014's gem5.

    Things you may also need to do:

    • Add the following to gshare.cc #include "params/GShareBP.hh"
    • Add typedef GShareBPParams Params; to gshare.hh
    • Rename SatCounter as SatCounter8

    For more information, you may find the book Learning gem5 helpful