-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HW Loop Rd after Wr error #189
Comments
I would say this is a reasonable way to do it so if that is the behavior of the HW, this is an HW bug. However, the compiler should never use this scheme, thus only explicit SW assembly routines may generate such conditions. I would say it is not an urgent HW bug but to be fixed. Before confirming it, I would ask @eflamand and or @haugoug a confirmation about my compiler statements. Thanks |
That's not something the compiler will generate, he's never directly accessing HW loop CSRs. These CSRs are only accessed when saving/restoring interrupted context. So to me it would be reasonable to forbid such code if it simplifies the HW. |
Loop related registers can always be manipulated by lp.xyz instructions:
lp.count level, iter_reg
lp.start level, start_label
lp.end level, end_label
…On Tue, Nov 17, 2020 at 3:46 PM Pasquale Davide Schiavone < ***@***.***> wrote:
Dear @jm4rtin <https://github.com/jm4rtin> and @haugoug
<https://github.com/haugoug> ,
shall we make the CSR of the HWLoop READ ONLY?
There is no meaning to me that SW writes them explicitly. It should be
allowed only via hwloop instructions in my opinion.
If you guys agree I make the RTL change.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#189 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGAUF3ZX2XCRT7YNEHLFBBDSQKEDLANCNFSM4JILGAMQ>
.
|
Sorry, was sent before being finished :(
Loop related registers can always be manipulated by lp.xyz instructions:
most general form
lp.count level, iter_reg
lp.start level, start_label
lp.end level, end_label
So it is safe to make related CSR read only, imo
Best
Eric
On Tue, Nov 17, 2020 at 3:57 PM Eric Flamand <
[email protected]> wrote:
… Loop related registers can always be manipulated by lp.xyz instructions:
lp.count level, iter_reg
lp.start level, start_label
lp.end level, end_label
On Tue, Nov 17, 2020 at 3:46 PM Pasquale Davide Schiavone <
***@***.***> wrote:
> Dear @jm4rtin <https://github.com/jm4rtin> and @haugoug
> <https://github.com/haugoug> ,
>
> shall we make the CSR of the HWLoop READ ONLY?
>
> There is no meaning to me that SW writes them explicitly. It should be
> allowed only via hwloop instructions in my opinion.
>
> If you guys agree I make the RTL change.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#189 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AGAUF3ZX2XCRT7YNEHLFBBDSQKEDLANCNFSM4JILGAMQ>
> .
>
|
Agree with you @eflamand ! |
I don't agree. |
Very good point @gautschimi - here the discussion can extend further as if we have an operating system that schedule 2 threads, both using HW loops, then the HWLoop should be part of the contex switch as well. so your ISR would look like this: //read hwloop ... your ISR ... lw x10, somwhere in the stack |
Actually I was too quick too, there is no lp.start and lp.end instruction with the register as source. |
ok if you can restore the hwloop context with lp.start/end/count instructions it is ok. |
Pinging to the discussion @jeremybennett as well as he is working on the compiler side |
Unfortunately only loop count reg can be loaded from a register: lp.count
L,bitrS1 lpcount[L] = rS1
Loop start and stop are loaded through pc + an imm value, no way to use it
to reload them unless you know distance from restore point to actual hw
loop which is a bit of stretch :)
Eric
…On Tue, Nov 17, 2020 at 5:20 PM Pasquale Davide Schiavone < ***@***.***> wrote:
Pinging to the discussion @jeremybennett
<https://github.com/jeremybennett> as well as he is working on the
compiler side
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#189 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGAUF35DCC53GWI7OJDDEADSQKPFVANCNFSM4JILGAMQ>
.
|
Hi @eflamand , yes that's why I proposed to you, @jeremybennett , and @jm4rtin to add the register version of lp.start and lp.end. funct3 has 2 places free :) |
The compiler would only ever generate loops using CSRs directly if that led to better code (size of speed). Is there any circumstance where this is the case. The CORE-V GCC is a work in progress (this is the rewrite for modern GCC). At present hardware loop is only used to optimize block moves. In principle you can generate hardware loop for other loops, but that is not there yet (known hard part of GCC - ask the ARC developers!) |
Hi @jeremybennett - I personally prefer only lp.start or lp.end instructions . But this does not matter too much. I would just remove redundancies. Davide |
Is there a reason the hardware loop can't be saved and restored as part of the context through a CSR read/write as long as it is not mixed with the HW loop instructions? What makes a CSR write to these registers not equivalent to using the instructions? Is the only difference the timing of the CSR write that creates this hazard? Are you opposed to leaving it up to software developers to avoid this illegal sequence of instructions? In such a case do you prefer an illegal instruction exception instead? If so, yes it may be better to forbid writing to the CSRs from an RTL complexity standpoint. A register version of How does the hardware loop react to interrupts (or exceptions)? Does it automatically return to normal operation? Does it know to resume the hardware loop when returning with I'm not opposed to adding the instructions if there is a good reason to do so. I think they will fit into the encoding space but there should be some clarification as to how context switching is supposed to work with the hardware loops. |
@davideschiavone @eflamand We are happy to add a register version of these instructions. I'd like @jm4rtin to confirm the encoding - IIRC HW loop uses CUSTOM-3, so can keep the existing encoding. We should ask @jessicamills (GNU Tools Project Lead), @ASintzoff (LLVM Project Lead) to comment. It might be useful to get opinion from @flip1995, since has has just completed implementation of HW Loop in the LLVM Integrated Assembler for RISC-V. |
For the current state of the LLVM implementation, only a few lines (+tests) would have to be added for those two new instructions. |
For the GNU Tools project this is fine and easily implemented in binutils-gdb. GCC is a work in progress, however, we can incorporate these changes into the work. We are happy to add the two new instructions upon confirmation and with further encoding details. |
Hi @jm4rtin
No. Indeed this can be done. What makes a CSR write to these registers not equivalent to using the instructions? Is the only difference the timing of the CSR write that creates this hazard? They are not equivalent from an RTL point of view. Thus, it's safer to remove such differences.
In PULP we do not usually write those registers except in save context parts. This code should be changed. Asking @haugoug to add comments on this part.
This is possible yes. That's why we restricted the HWLoop from an HW point of view. To make it possible. Several bugs have been found with jumps inside the HWLoop with compressed instructions or misaligned ones when handling interrupts in the middle of the loop. Is it valid to use the hardware loop in an interrupt context? If so, does the interrupt function attribute (compiler question) take into account the hardware loop before it is used/a function is called? Yes from an HW point of view (the core does not care which code it is handling). From a SW point of view, I remember @haugoug disabled it during ISR code.
Yes, let's have a meeting about it |
Hello everyone, We have two problems here:
We can force both the instructions to write the CSR in the same pipeline stage, but we would keep the redundancy. We can also remove the lp. instructions and keep only the csr_writes to deal with the HW loop CSRs, but we would lose the flexibility of the PC-relative addressing. |
Another point, the bug related to this issue is not present:
At the end of the simulation a4 and a5 have the same value. So we are using this issue to discuss the realted ISA changes, but the bug is not present in the RTL |
Discussion continues in #598 |
running the following code we encounter the following issue:
In the simulation results I see next error message that is worrying me:
UVM_ERROR /proj/dbm10l/denisg/ws_dbm10l_test/blk/ri5cy/verif/classes/pulpino_scoreboard_c.sv(467) @ 2813000: uvm_test_top.pp_env.pp_scoreboard [SPIKE_DBG] EX stage. Register #1 aka ra update mismatch. Expected value is 0x16, actual value is 0x0
Using csrrwi instruction test wanted to update HW loop #0 start address. then we follow with lp.end instruction to write to the end register. the error is that the first (start) write is not executed as seen in the waves:
It is a mix of Direct CSR writes to the start register and Loop Instruction writes to the loop end register.
We know from the lp.setup issues that these two instructions update registers in different instruction pipe stages. From the waves we see that the lp.end write of the end register is in the same cycle as the previous direct write of the start register, the end write wins (start write not executed).
Is it a reasonable use case that such a mix of loop setup instructions will be used, or is there a restriction not to use hybrid types (direct csr wr + loop inst wr) of writes when updating the HW loops registers in order to avoid this conflict?
The text was updated successfully, but these errors were encountered: