-
Notifications
You must be signed in to change notification settings - Fork 184
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
Add Support for Zmmul #122
Conversation
Should the new |
Yes! |
@scottj97 Actually |
It's nice that this is much simplified, but please squash the two commits back into one. It first appeared that the one commit was doing two things (adding missing haveMulDiv(), and adding Zmmul) which is why I asked for two commits. Since it turns out that was not the case, this PR is only doing one thing (adding Zmmul) so it only needs one commit. |
When it will merge it will squash merge into the master i.e., will go as one commit. Do I need to squash commits anyway ? |
You're assuming the admin who clicks the Merge button chooses the Squash option. I don't think that's a safe assumption. |
Does M not imply Zmmul, and thus only the latter needs checking? |
model/riscv_sys_regs.sail
Outdated
@@ -180,6 +180,8 @@ function haveUsrMode() -> bool = misa.U() == 0b1 | |||
function haveNExt() -> bool = misa.N() == 0b1 | |||
/* see below for F and D extension tests */ | |||
|
|||
function haveZmmul() -> bool = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with the bitmanip PR, keep the lists of dummy Z* extension checks sorted, i.e put Zm* below Zk*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does M not imply Zmmul, and thus only the latter needs checking?
Yes, M does not imply Zmmul. You can read the discussion on this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with the bitmanip PR, keep the lists of dummy Z* extension checks sorted, i.e put Zm* below Zk*
Sure :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does M not imply Zmmul, and thus only the latter needs checking?
Yes, M does not imply Zmmul. You can read the discussion on this PR
This contradicts riscv/riscv-isa-manual#648 (comment), which is as close to an authoritative source as I can find. Pointing at someone's own comments on their own Spike pull request is hardly authoritative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put it in this way. An implementation can have both extensions as a time. When I said does not imply I meant to say If misa.M() ==1 it does not mean that Zmmul extension is there as well. if Either or both of them are in implementation the Mul instructions will work. That's why there is a or
between haveMulDiv and haveZmmul.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand. The benefit of Zmmul is, as it supports only MUL instructions (Not DIV/REM), it will save hardware in those implementations where DIV/REM instructions are not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One difference between M and Zmmul is that the latter is not controlled by misa.M. If you have Zmmul then the multiply instructions are always enabled. If you have M then the multiply instructions are enabled iff misa.M==1. That's why saying "M implies Zmmul" is inaccurate -- because that would mean that misa.M only controls divide and not multiply.
This Sail model doesn't support modifying misa.M so this is moot here -- but that might change in the future so I think it's better to keep them separate here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah indeed that is an important but subtle difference. I believe modifying misa.M should work if sys_enable_writable_misa is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this code supports modifying bits C/D/F only. And reading it, I see a bug, which I'll file separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right, I skimmed it and thought it was mostly fixing up v, but it's just using v to fix up the existing m.
Sure. I'll squash commits. |
22af6e5
to
7c334f3
Compare
@bilalsakhawat-10xe can you please fix the Git commit message. It doesn't make sense to include "Removed extra haveMulDiv() checks" because it doesn't do that anymore. |
7c334f3
to
97757e6
Compare
Please amend your commit message to include a verb ("Add support for Zmmul", "Implement Zmmul", etc., don't really care exactly what), it's good practice (otherwise it doesn't actually mean anything as it leaves one asking what are you doing to the zmmul support? adding it? removing it? refactoring it? all possibilities without looking at the changes themselves). Otherwise this looks ready. |
97757e6
to
fe9e82a
Compare
This was fine until you pushed that merge commit. Never merge into a pull request branch, always rebase the branch. But in this case there was no need to do either, the changes to master don't affect this PR whatsoever. |
Yes, please rebase in order to lose the merge commit |
(same goes for your bitmanip, and now scalar crypto, PRs) |
Steps I have in mind:
Is there a good way to do it? |
Just |
(or |
1318b81
to
4cb28ae
Compare
I wonder if it's a good idea to haveZmmul==true as the default. We also haveMulDiv==true as the default, and it doesn't really make sense to have both of these at once. (As discussed above w.r.t. misa.M.) It seems the configuration system that the Arch Test SIG is working on should have a configuration knob with three choices: None, M, or Zmmul. |
@jrtc27 you may have a proper answer, why we are using haveZmmul==true as default for now. |
@jrtc27 some input from you will be great. |
I originally defined it such that Zmmul and M were incompatible, but I was told there weren't. Zmmul is redundant with M, but not disallowed. So, stupid, but not forbidden. |
Ok, thanks for the clarification. Given we have all the Zb* and Zk* extensions on by default with no way to turn them off (currently), it does seem a bit odd to not provide Zmmul. I know it means setting misa.M to 0 no longer turns off MUL*, but does that actually matter? I don't personally mind either way all that much, just so far the philosophy's been to enable as much as we can by default for maximum utility. |
From the point of view of architectural tests: the fact that either are on doesn't matter. |
The I don't care what the default is for Zmmul in this Sail model. |
If MISA.M is writable, we could, sort of, but it is a bit pointless. t boot, if M-ext is implemented, MISA.M will be set, and we will test that it works. IF MISA.M is writable, we can test that it can be cleared, and set again, but that is all. |
I know a way how we can run all Zmmul tests without having to re-write all the M tests. We just need to check if Zmmul is in the ISA string and if yes include mul, mulh, mulhsu, mulhu and mulw tests in the database.yaml (it contains the list of tests to be run on Ref and DUT). We just need to change 1-2 files in riscof env. |
I don't think it's that simple. We potentially have to run the tests twice; once if M-extension is supported (and MISA.M is set, which should be the case after reset. Hmm, our tests probably need to check that) and once if Zmmul is supported and either MISA.M is clear or M-ext isn't supported). I think that means those tests need to be replicated. |
Running test twice is not an issue. We can do that for misa.M and zmmul. The issue will be when collecting coverage, we need to make changes in riscv-ctg as well. Even this is a simple task. But this is not a recommended solution to make changes riscof and riscv-ctg for just zmmul. Replicating the tests is the best solution. |
I talked to Krste. He is suggesting that if an implemention does have both
Zmmul AND M-extension AND misa.M is RW, then vendor is responsible for
running the tests twice with different boot code, the normal one and one
that clears misa.M before running tests. It’s unlikely that anyone will
ever build this specific configuration (why would you ever disable M?) so
making the umplementir do the extra work is fine.
…On Sunday, December 5, 2021, Bilal Sakhawat ***@***.***> wrote:
I don't think it's that simple. We potentially have to run the tests
twice; once if M-extension is supported (and MISA.M is set, which should be
the case after reset. Hmm, our tests probably need to check that) and once
if Zmmul is supported and either MISA.M is clear or M-ext isn't supported).
I think that means those tests need to be replicated. I thought we could
avoid that, but we can't.
Running test twice is not an issue. We can do that for misa.M and zmmul.
The issue will be when collecting coverage, we need to make changes in
riscv-ctg as well. Even this is a simple task. But this is not a
recommended solution to make changes riscof and riscv-ctg for just zmmul.
Replicating the tests is the best solution.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#122 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHPXVJTDNKULGBWD42YN4DDUPRTV5ANCNFSM5HI5LHDA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I think I've discussed this elsewhere, but the corner case only occurs when there is an implementation that has both M-extension and Zmmul, AND misa.M is read-write, so the M-extension can be disabled (which effectively disables only DIV/REM ops, since Zmmul can't be disabled). |
So I think, the changes I made in this PR are good enough for now. Later we may add a plusargs in sail '--isa=RVxxx' like we have in spike. Then for 64-bit we can have the cases like:
|
Well, it's not a plusarg, those are specifically |
So, if nobody has any strong opinions on this, I suggest we go ahead and merge it with Zmmul defaulting to enabled, given so far we've only disabled extensions by default if they conflict? |
Thanks for correction. I choose the wrong terms actually, I should have said command-line argument. |
From the point of view of ACTs - it is our intention that we don't execute tests for extensions that don't have support (or are disabled) because results are unpredictable. At reset, all extensions that implemented are enabled, regardless of whether it is possible to disable them. So, defaulting them to enabled seems just fine. |
@scottj97 @jrtc27 @allenjbaum @bilalsakhawat-10xe I would like to merge this PR this week. Any objections to that? |
not from me!
…On Tue, Jan 18, 2022 at 3:13 AM Martin Berger ***@***.***> wrote:
@scottj97 <https://github.com/scottj97> @jrtc27
<https://github.com/jrtc27> @allenjbaum <https://github.com/allenjbaum>
@bilalsakhawat-10xe <https://github.com/bilalsakhawat-10xe> I would like
to merge this PR this week. Any objections to that?
—
Reply to this email directly, view it on GitHub
<#122 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHPXVJQBEYJG3JA3ABCJ4YDUWVDM5ANCNFSM5HI5LHDA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Nope, long overdue |
Merged. Thanks @bilalsakhawat-10xe @scottj97 @jrtc27 @allenjbaum |
RISC-V Zmmul extension includes following instructions:
The opcode encodings and instruction semantics are identical to those in the M-extension.
The ISA string is Zmmul.
8.3 Zmmul Extension, Version 0.1 (riscv unpriv spec)