how to evaluate the branch predictor used by rocket

298 views
Skip to first unread message

leishangwen

unread,
Dec 22, 2016, 4:12:36 AM12/22/16
to sw-...@groups.riscv.org
hi, does anybody know how to evaluate the branch predictor used by rocket ? 
I used to run the emulation test, but there isn't any stats result about branch predict.
So If I change the number of BTB entry  from 40 to 64, How to evaluate it ?
Thank you!


 

Christopher Celio

unread,
Dec 22, 2016, 4:16:36 AM12/22/16
to leishangwen, sw-...@groups.riscv.org
The boom branch of rocket-chip adds hpm events to track this (and other) data.

This should help get you started: 


If you pursue the HPM route, you'll also have to modify your software to enable and initialize the HPM counters and event selectors. The privilege spec v1.9.1 talks about HPM in more detail.


-Chris



--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To post to this group, send email to sw-...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/4970e06a.8d26.15925c82a84.Coremail.leishangwen%40163.com.

leishangwen

unread,
Dec 24, 2016, 1:33:59 AM12/24/16
to Christopher Celio, sw-...@groups.riscv.org
Thank you Christopher.
I checked out BOOM code, and found BOOM use a new BTB, different with Rocket, so I changed Rocket to print branch prediction info, just like BOOM.
Now I can get the branch predictor stats, and I changed the number of BTB entry to 32, 40, 60, 64, 120, 128.
Below is the result, it shows the misprediction ratio. 
 
But it seems that the misprediction ratio is lower when the number of BTB entry is not power of 2.
40, 60, 120 is lower than 32, 64, 128.
 This is a strange thing. Maybe there is a bug in btb.scala. What do you think? Thank you.
无标题.jpg

leishangwen

unread,
Dec 28, 2016, 10:02:12 PM12/28/16
to sw-...@groups.riscv.org

I think the problem is the BTB entry replace algorithm, here is the code:
  val nextRepl =
    if (!isPow2(entries)) {
      Counter(r_btb_update.valid && !updateHit, entries)._1
    } else {
      val plru = new PseudoLRU(entries)
      when (hits.orR) { plru.access(OHToUInt(hits)) }
      plru.replace
    }

Different replace algorithm results different branch prediction efficiency.

Christopher Celio

unread,
Jan 5, 2017, 12:58:35 AM1/5/17
to leishangwen, sw-...@groups.riscv.org
Hi leishangwen!

I'm glad you were able to get the branch predictor HPM events working AND that you were able to find a rocket performance bug too! We really appreciate it. 

Andrew Waterman found a bug in the PseudoLRU state handling and he'll have a fix incoming soon. Until then, you can remove the pow2 special case and always use the FIFO replacement policy:

val nextRepl =
    Counter(r_btb_update.valid && !updateHit, entries)._1

Thanks,
Chris



On Dec 28, 2016, at 5:01 PM, leishangwen <leish...@163.com> wrote:


I think the problem is the BTB entry replace algorithm, here is the code:
  val nextRepl =
    if (!isPow2(entries)) {
      Counter(r_btb_update.valid && !updateHit, entries)._1
    } else {
      val plru = new PseudoLRU(entries)
      when (hits.orR) { plru.access(OHToUInt(hits)) }
      plru.replace
    }

Different replace algorithm results different branch prediction efficiency.

At 2016-12-24 14:33:37, "leishangwen" <leishangwe163.com> wrote:
Thank you Christopher.
I checked out BOOM code, and found BOOM use a new BTB, different with Rocket, so I changed Rocket to print branch prediction info, just like BOOM.
Now I can get the branch predictor stats, and I changed the number of BTB entry to 32, 40, 60, 64, 120, 128.
Below is the result, it shows the misprediction ratio. 
 
<无标题.jpg>
Reply all
Reply to author
Forward
0 new messages