Skip to content
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

Support AVX512_BITALG instructions and relax base register req in VM operands #199

Closed
wants to merge 31 commits into from

Conversation

vsivsi
Copy link
Contributor

@vsivsi vsivsi commented Sep 8, 2021

This PR updates the AVX512 branch only, and brings the following:

  • Relaxes the current requirement that VM operands in VPSCATTER/GATHER have a base register.

  • Adds support for AVX512_BITALG instructions / forms.

    • Adds VPOPCNTB/W byte/word forms of VPOPCNT, including AVX512VL 128/256-bit wide (xmm/ymm) forms
    • Adds AVX512VL 128/256-bit wide (xmm/ymm) forms to the existing supported AVX512_VPOPCNTDQ instructions.
    • Adds new instruction VPSHUFBITQMB with its AVX512VL 128/256-bit wide (xmm/ymm) forms.
    • Support for these instructions/forms was hand edited into internal/data/x86_64.xml as that seemed the path of least resistance, and scripts/generate was run to regenerate build/zinstructions.go et al.

Additionally it:

  • Merges in all changes from the current master branch
  • Updates CI for go1.17 (from go1.17 branch)

josharian and others added 30 commits January 3, 2021 19:29
…hlin#165)

This makes it easier to debug avogen: when you emit invalid syntax, you can inspect the generated file to determine what went wrong, instead of having only gofmt's error to work with.
Add necessary feature checks to the dot and geohash examples to prevent illegal instruction errors.

Fixes mmcloughlin#170 mmcloughlin#153
Replaces gobin with the preferred tools.mod solution for pinning tool dependencies.

Updates mmcloughlin#166
Adds a method to the Attribute type to test for each flag in the textflag.h header.
…#182)

Many of the instruction functions correctly match the size of immediate values, but they only accept unsigned immediates. This PR fixes the operand check functions for intermediate types to also accept the signed variants.

Fixes mmcloughlin#181
Currently `avo` uses `BP` as a standard general-purpose register. However, `BP` is used for the frame pointer and should be callee-save. Under some circumstances, the Go assembler will do this automatically, but not always. At the moment `avo` can produce code that clobbers the `BP` register. Since Go 1.16 this code will also fail a new `go vet` check.

This PR provides a (currently sub-optimal) fix for the issue. It introduces an `EnsureBasePointerCalleeSaved` pass which will check if the base pointer is written to by a function, and if so will artificially ensure that the function has a non-zero frame size. This will trigger the Go assembler to automatically save and restore the BP register.

In addition, we update the `asmdecl` tool to `asmvet`, which includes the `framepointer` vet check.

Updates mmcloughlin#156
Update github.com/klauspost/compress version.

Add github.com/klauspost/reedsolomon and github.com/minio/md5-simd.

Add `-mod=mod` to commands due to golang/go#44129.
Required updates to the thirdparty test suite due to modules changes in go toolchain.
Link to Filippo's live stream of rewriting the filippo.io/edwards25519 assembly with avo.

Reformat the "learn more" links in a list.
Restrict permissions of github token. Pin action versions.

Following advice in briansmith/untrusted#50.
@vsivsi vsivsi changed the title Support AVX512_BITALG instructions and relax base register req in VM operands (#193) Support AVX512_BITALG instructions and relax base register req in VM operands Sep 8, 2021
@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2021

Codecov Report

Merging #199 (fdca336) into avx512 (d60cc02) will decrease coverage by 4.34%.
The diff coverage is 97.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           avx512     #199      +/-   ##
==========================================
- Coverage   75.57%   71.22%   -4.35%     
==========================================
  Files          58       59       +1     
  Lines       79634    90787   +11153     
==========================================
+ Hits        60184    64666    +4482     
- Misses      19294    25963    +6669     
- Partials      156      158       +2     
Flag Coverage Δ
integration 3.20% <17.63%> (+0.53%) ⬆️
unittests 70.26% <96.29%> (-4.54%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
attr/attr.go 100.00% <ø> (ø)
build/zinstructions.go 1.61% <ø> (-0.09%) ⬇️
gotypes/components.go 92.37% <ø> (+0.70%) ⬆️
internal/gen/gen.go 0.00% <0.00%> (ø)
pass/pass.go 51.61% <ø> (+10.43%) ⬆️
reg/types.go 83.20% <ø> (+1.49%) ⬆️
reg/x86.go 100.00% <ø> (ø)
x86/zoptab.go 0.00% <ø> (ø)
x86/zctors.go 95.21% <98.14%> (+0.25%) ⬆️
attr/ztextflag.go 100.00% <100.00%> (ø)
... and 62 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d60cc02...fdca336. Read the comment docs.

@vsivsi
Copy link
Contributor Author

vsivsi commented Sep 8, 2021

I'm not sure why the lint CI run is exiting with retval 1. But it looks like lint has been failing for the AVX512 branch all along.

It also looks like 'lint' and 'thirdparty' are currently failing on the go1.17 branch, and since I merged that in... Also failing here.

Perhaps it was a mistake to do that, happy to revert the CI to 1.16 on this branch if moving to 1.17 is complicated.

@mmcloughlin mmcloughlin mentioned this pull request Nov 7, 2021
@vsivsi
Copy link
Contributor Author

vsivsi commented Nov 15, 2021

@mmcloughlin What needs to happen to get this merged? This is the last thing blocking me from moving off my fork and back to Avo master. Specifically this addresses #193 and #20 (comment). If it would be helpful to have me resubmit this as a PR against the master branch, I'd be happy to do that.

@mmcloughlin
Copy link
Owner

Can we split this into two?

For the BITALG stuff, I'd like any hand edits to be recorded as patch files. It's looking unlikely that opcodes will ever be updated, but in theory, it could be. Basically, we need to get to the point where running the dl.sh script produces the datafiles. I'd suggest a PR that:

  • adds a internal/data/patches/avx512bitalg.patch
  • update internal/data/dl.sh script to add an applypatch function
  • the applypatch function should call the patch command with a given patch file
  • echo some output to record the patch in the internal/data/README.md file

For the vm operands, it basically looks good but it needs more tests. Let me take a look at this.

@vsivsi
Copy link
Contributor Author

vsivsi commented Nov 15, 2021

Sure thing! Thanks for the quick response. Here's a new PR for the S/G mem op validation: #233

@vsivsi
Copy link
Contributor Author

vsivsi commented Nov 15, 2021

And another PR with the requested patch file. #234

If it's not too much to ask, I'll leave the patching mechanics and opcodes rebuild up to you, since you seem to have a vision for how that should all work that would probably take longer to communicate than to just implement.

@vsivsi
Copy link
Contributor Author

vsivsi commented Nov 15, 2021

With #233 and #234 this PR is now defunct, so I'm closing it.

@vsivsi vsivsi closed this Nov 15, 2021
@mmcloughlin
Copy link
Owner

If it's not too much to ask, I'll leave the patching mechanics and opcodes rebuild up to you, since you seem to have a vision for how that should all work that would probably take longer to communicate than to just implement.

For sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants