[PPC64LE] poly_tomont: trim dead callee-saved spills (frame 320->224) - #1773
[PPC64LE] poly_tomont: trim dead callee-saved spills (frame 320->224)#1773Scottcjn wants to merge 1 commit into
Conversation
mkannwischer
left a comment
There was a problem hiding this comment.
Thanks @Scottcjn. Below some nits. Could you address them first, and then we'll get the code changes reviewed.
| li 11, 208 | ||
| li 12, 224 | ||
| lxvx 32+20, 6, 1 | ||
| lxvx 32+21, 7, 1 | ||
| lxvx 32+22, 8, 1 | ||
| lxvx 32+23, 9, 1 | ||
| lxvx 32+24, 10, 1 | ||
| lxvx 32+25, 11, 1 | ||
| lxvx 32+26, 12, 1 | ||
| li 6, 240 | ||
| li 7, 256 | ||
| li 8, 272 | ||
| li 9, 288 | ||
| lxvx 32+27, 6, 1 | ||
| lxvx 32+28, 7, 1 | ||
| lxvx 32+29, 8, 1 | ||
| lxvx 32+30, 9, 1 | ||
| lxvx 32+23, 6, 1 | ||
| lxvx 32+24, 7, 1 | ||
| lxvx 32+27, 8, 1 | ||
| lxvx 32+28, 9, 1 | ||
| lxvx 32+29, 10, 1 | ||
| lxvx 32+30, 11, 1 | ||
| mtlr 0 | ||
| addi 1, 1, 320 | ||
| addi 1, 1, 224 | ||
| blr | ||
|
|
||
| /* To facilitate single-compilation-unit (SCU) builds, undefine all macros. | ||
| * Don't modify by hand -- this is auto-generated by scripts/autogen. */ | ||
| /* To facilitate single-compilation-unit (SCU) builds, undefine all macros. */ |
There was a problem hiding this comment.
Why was this changed? Please change it back.
| * SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT | ||
| * | ||
| * Written by Danny Tsen <dtsen@us.ibm.com> | ||
| * poly_tomont frame trim (#1722) by Scott Boudreaux. |
There was a problem hiding this comment.
That's the old PR number. I would prefer not linking specific PRs.
We don't usually add names to files. Is it important to keep your name in here?
There was a problem hiding this comment.
If you insist, you can add a copyright line higher in the file
Copyright (c) Scott Boudreaux
|
Thanks @mkannwischer. Nits addressed:
The assembly is unchanged from the reviewed version, so what is left vs main is just the frame trim (320 to 224) and the matching save/restore set. Ready for the code review whenever you are. |
mkannwischer
left a comment
There was a problem hiding this comment.
Thanks for your updates. The last 3 commits are missing the DCO signoff.
Also, could you please squash your 4 commits into one?
1f5ff37 to
14e8a39
Compare
|
Done. Squashed to a single commit with the DCO Signed-off-by line. Thanks. |
14e8a39 to
d77f500
Compare
|
Thanks @Scottcjn. @bhess, @dannytsen, could either if you provide a review for this change please? |
|
@mkannwischer The change looks OK to me. A note, the code we submitted is copyrighted under IBM and no other names can be added in the code unless a complete re-write of the code. So any modification is still under IBM copyright and owned by IBM. I have to make it clear. |
I don't think this is true? The code is licensed under MIT / Apache / ISC. Of course, IBM's copyright notice would be retained when creating a derivative. |
|
Thanks both. The review comments are all addressed in the current head:
The only functional change that remains is the frame trim itself: the epilogue now saves/restores just the callee-saved VRs the body actually clobbers (v23, v24, v27-v30), dropping the five unused v20-v22/v25/v26 spills and shrinking the frame from 320 to 224 bytes. @hanno-becker on the licensing point, agreed, the IBM copyright notice stays in the header. If nothing else is outstanding, this should be ready for another look. Thanks for the reviews. |
mkannwischer
left a comment
There was a problem hiding this comment.
Thanks @Scottcjn for your patience!
Thanks @dannytsen for reviewing this!
This looks good to me.
The prologue saved and restored v20-v30, but the body only clobbers v23, v24, and v27-v30. v20, v21, v22, v25, and v26 were spilled and reloaded but never used: five dead stxvx/lxvx pairs and 80 bytes of frame. This saves only the registers the body touches and trims the frame from 320 to 224 bytes. The Montgomery multiply is unchanged. The mlkem/ copy was regenerated with scripts/simpasm. Closes pq-code-package#1722. Signed-off-by: Scott Boudreaux <scottbphone12@gmail.com>
d77f500 to
2a7a6c0
Compare
|
Running full CI and benchmarks in #1799 |
|
Hmm, the benchmarks on POWER10 are not looking good: On main: mlk_polyvec_tomont cycles=439 Full benchmarks also show a small overall slowdown (see #1799 (review)) ppc64le (POWER10) benchmarks
@Scottcjn, any idea why this results in an overall slowdown on POWER10? |
benchmarks show no improvements on POWER10; we first need to discuss that.
Addresses the inline TODO in
poly_tomont_ppc_asm.S(#1722).The prologue saved and restored v20-v30, but the body only clobbers
v23, v24, and v27-v30. v20, v21, v22, v25, and v26 were spilled and
reloaded but never used: five dead stxvx/lxvx pairs and 80 bytes of
frame. This saves only the registers the body touches and trims the
frame from 320 to 224 bytes. The Montgomery multiply is unchanged.
Validation: func, kat, and unit all pass for ML-KEM-512/768/1024
(opt and no_opt) on a POWER8 S824 with -DMLK_FORCE_PPC64LE -mcpu=power8.
The mlkem/ copy was regenerated with scripts/simpasm.
Supersedes #1752, cleaned up per review feedback. Closes #1722.