serialize simulator on wfi
authorAndrew Waterman <andrew@sifive.com>
Tue, 21 Feb 2017 02:48:35 +0000 (18:48 -0800)
committerAndrew Waterman <andrew@sifive.com>
Tue, 21 Feb 2017 02:48:35 +0000 (18:48 -0800)
This improves simulator perf when a thread is idle, or waiting on HTIF.

riscv/decode.h
riscv/execute.cc
riscv/insns/wfi.h

index b607bf38a02daccce1b90daafa71b89eb38a8c4c..d82767deecacd61879b56925773b843980dee5c9 100644 (file)
@@ -202,9 +202,10 @@ private:
      } while(0)
 
 #define set_pc_and_serialize(x) \
-  do { set_pc(x); /* check alignment */ \
+  do { reg_t __npc = (x); \
+       set_pc(__npc); /* check alignment */ \
        npc = PC_SERIALIZE_AFTER; \
-       STATE.pc = (x); \
+       STATE.pc = __npc; \
      } while(0)
 
 /* Sentinel PC values to serialize simulator pipeline */
index ebc9dc7e79e12474e4a6735d248a2d2a9fb85103..1b53ccf7c3e4eeff9dfcf426f3b3024d5f354d99 100644 (file)
@@ -84,7 +84,7 @@ void processor_t::step(size_t n)
      if (unlikely(invalid_pc(pc))) { \
        switch (pc) { \
          case PC_SERIALIZE_BEFORE: state.serialized = true; break; \
-         case PC_SERIALIZE_AFTER: instret++; break; \
+         case PC_SERIALIZE_AFTER: n = ++instret; break; \
          default: abort(); \
        } \
        pc = state.pc; \
index 6f037f8a9c689c7b5df689470d60c1f0b9e80427..643c3747cda991997651b8294d96021abeda159b 100644 (file)
@@ -1 +1 @@
-// nop
+set_pc_and_serialize(npc);