-
Notifications
You must be signed in to change notification settings - Fork 188
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 Zfh extension #129
Conversation
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.
Why do you commit prover snapshots? They are auto-generated.
it's often handy, e.g. so people can see the prover definitions directly
…On Sat, 20 Nov 2021 at 16:52, Martin Berger ***@***.***> wrote:
***@***.**** commented on this pull request.
Why do you commit prover snapshots? They are auto-generated.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#129 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFMZZSBL7SRVKCCJZAT2WDUM7GVPANCNFSM5IMF2XVQ>
.
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>.
|
They already existed in the repo, so he's just keeping them up to date, which is better than letting them fall behind. Are you recommending these be deleted from the repo? |
@PeterSewell Yes, but then we need to make sure the generated prover definitions stay up-to-date with the sail model. For example generating prover snapshots in not in the GH Actions CI. So I'm wondering if they are even up-to-date. @scottj97 If they get auto-generated by the CI, we can delete them. |
@PeterSewell How much work do you think it would be to script the building of all the prover snapshot with GitHub Actions, so we can remove the word "not" from https://github.com/riscv/sail-riscv/blob/master/prover_snapshots/README.md ? I imagine there was a reason why the current build process does not automate this. |
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.
Unfortunately with the recent landing of Zfinx you picked a bad time to submit this pull request, and will need to rebase on top of that and apply the same changes to the new Zfh code. I think it should be relatively straightforward, if tedious. The only thing noteworthy that comes to mind is nan_(un)box should probably be made overloaded calling _S and _H versions (with the _S version being what is currently there) rather than having nan_(un)box and nan_(un)box_H as is done here.
Glancing at the implementation I'm reminded of how non-conforming the F/D code is (blame Bluespec's internal code style for that, which I suspect is derived from treating everything like it's Haskell), but I agree with your choice here to copy the F/D code style (I assume you just copied F and swept through converting all the F-specificity to Zfh-specificity) rather than reformat it for Zfh and increase the divergence between them.
model/riscv_softfloat_interface.sail
Outdated
@@ -112,6 +113,35 @@ function update_softfloat_fflags(flags) = { | |||
/* **************************************************************** */ | |||
/* ADD/SUB/MUL/DIV */ | |||
|
|||
|
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.
Stray extra line
@@ -389,6 +418,13 @@ function process_fload32(rd, addr, value) = | |||
MemException(e) => { handle_mem_exception(addr, e); RETIRE_FAIL } | |||
} | |||
|
|||
val process_fload16 : (regidx, xlenbits, MemoryOpResult(bits(16))) |
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.
Really the functions should be the other way round, but that's not your problem, so this is the right thing to do in the situation
@@ -0,0 +1,916 @@ | |||
|
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.
Should probably have the copyright header from fext given this is heavily derived from it, as well as an equivalent to:
/* **************************************************************** */
/* This file specifies the instructions in the F extension */
/* (single precision floating point). */
/* RISC-V follows IEEE 754-2008 floating point arithmetic standard. */
/* Original version written by Rishiyur S. Nikhil, Sept-Oct 2019 */
/* **************************************************************** */
/* IMPORTANT! */
/* The files 'riscv_insts_fext.sail' and 'riscv_insts_dext.sail' */
/* define the F and D extensions, respectively. */
/* The texts follow each other very closely; please try to maintain */
/* this correspondence as the files are maintained for bug-fixes, */
/* improvements, and version updates. */
/* **************************************************************** */
That should probably also be updated across all three to reference Zfh
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.
(Normally wouldn't mandate that block of documentation but F and D, and now Zfh, are a bit special in how they're implemented and we want to ensure they stay as similar as possible)
cf8049b
to
19153a0
Compare
@jrtc27 I refactor the code for Zfh Extension. I think, modifications from Zfh to ZFinx_Zfh should be in a separate Pull Request. If you agree, I just need to add copyright header in the |
Deferring Zhinx seems ok to me, it's true that requesting it is moving the goalposts for this PR. Had you been slightly later and copied the F or D file with Z[fd]inx support then you would've been 95% of the way there already for free, but alas that's not what happened and so instead it's a bunch of work to repeat all the changes to the Zfh code. I quickly skimmed the PR and noticed that the stray line comment from 8 days ago also still applies. I also found the "RV64 only" comment for the L[U] conversions mentions F not Zfh. I'll try and take a more thorough look tomorrow. |
19153a0
to
9517c69
Compare
@jrtc27 Did you manage to take a look? |
model/riscv_insts_fext.sail
Outdated
-> Retired effect {escape, rreg, wreg} | ||
function process_fload16(rd, addr, value) = | ||
match value { | ||
MemValue(result) => { F(rd) = nan_box_H(result); RETIRE_SUCCESS }, |
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.
This can just be nan_box, same as process_fload32
model/riscv_insts_zfh.sail
Outdated
FDIV_H => riscv_f16Div (rm_3b, rs1_val_16b, rs2_val_16b) | ||
}; | ||
write_fflags(fflags); | ||
F(rd) = nan_box_H (rd_val_16b); |
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.
These can all be nan_box, for consistency with F (that or those should be changed to nan_box_S, but I don't see the benefit from that, might as well make use of the language's overloading to make the code a bit cleaner to read), though given they'll all need changing in future to F_or_X_H(rd) = ...
with the NaN boxing implicit I guess this is fine, unlike the one for FP_LOAD which will stay and thus should be fixed (though arguably pushing that into a new F_H/S/D might make things slightly cleaner and more consistent, as a future minor refactor).
/* Execution semantics ================================ */ | ||
|
||
function clause execute (F_BIN_RM_TYPE_H(rs2, rs1, rm, rd, op)) = { | ||
let rs1_val_16b = nan_unbox_H (F(rs1)); |
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.
These will all need to use (a new) F_or_X_H but I guess it's fine to express it this way for now
I did not but have now. One minor comment, the rest observations. The commits should also be squashed down into a single commit rather than the 3 there are now (or 4 that it may become). |
9517c69
to
217a46a
Compare
@jrtc27 I have incorporated the changes suggested by you. |
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.
I think this is now ready
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.
Looks fine to me.
Merged. Thanks @bilalsakhawat-10xe @jrtc27 |
“Zfh” Standard Extensions for Half-Precision Floating-Point, Version 0.1
Chapter 15 in the draft spec.
FCVT.Q.H and FCVT.H.Q are not implemented. (Quad-Precision is not supported by sail yet)