Hi,

As a follow-up to my previous email, I think I know what causes
the problem, but I don't know how to solve it.

The source of the problem seems to be that the value of the private
variable _compressed of RISC-V PCState objects is not set properly. In
other words, I couldn't find any place in the code where the setter
function "void compressed(bool c)" (implemented in src/arc/riscv/types.hh)
is called. So, since this variable is used in the "bool branching()"
function of the PCState class, branching() returns an incorrect value for
non-branch compressed instructions.

I'm going to make my RISC-V compiler not generate compressed instruction as
a temporary work-around. But I'd appreciate it if someone could help to
solve this problem.

Thanks,
Hossein




On Tue, Feb 25, 2020 at 12:48 PM Hossein Golestani <[email protected]>
wrote:

> Hello everyone,
>
> I'm facing an issue regarding using the RISC-V ISA with the DerivO3CPU
> model. Apparently, some RISC-V instructions are incorrectly detected as a
> branch. Here's a piece of debugging output:
> 5682918000: system.switch_cpus.fetch: [tid:0] Instruction PC 0x10586 (0)
> created [sn:1].
> 5682918000: system.switch_cpus.fetch: [tid:0] Instruction is: *c_fsd*
> fa5, 72(a5)
> 5682918000: system.switch_cpus.fetch: [tid:0] Fetch queue entry created
> (1/32).
> 5682918000: system.switch_cpus.fetch: *Branch detected* with PC =
> (0x10586=>0x10588).(0=>1)
> 5682918000: system.switch_cpus.fetch: [tid:0] *Done fetching*, predicted
> branch instruction encountered.
>
> c_fsd is a floating-point store rather than a branch. I observed such an
> issue for other non-branch instructions, including c_ld, c_sd, and c_mv.
> As you can see, this problem seems to have to do with RISC-V compressed
> instructions, as also suggested in a previous post (link
> <https://www.mail-archive.com/[email protected]/msg15576.html>). This
> problem causes inaccuracies in performance modeling of the OoO core, that
> is, since branch prediction needs to be performed at the fetch stage, no
> other instruction (as far as fetch bandwidth allows) is fetched after the
> wrong branches.
>
> Looking a bit in the code of the DefaultFetch<Impl>::fetch function in
> src/cpu/o3/fetch_impl.hh, it seems thisPC.branching() returns true for
> the instructions mentioned above. For the RISC-V ISA, this function is
> implemented in src/arc/riscv/types.hh.
>
> Before trying to solve this problem on my own, I just wanted to report it
> here to see if anyone can help. I will send a follow-up email if I make
> progress on this.
>
> By the way, I'm using the commit c4724cac6 of gem5 (3 months old as of
> today).
>
> Thanks,
> Hossein
>
>
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to