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

Implement Relaxed SIMD proposal #1994

Merged
merged 2 commits into from
Nov 30, 2022
Merged

Conversation

marcusb
Copy link
Contributor

@marcusb marcusb commented Sep 11, 2022

This adds support for the new opcodes from the Relaxed SIMD proposal (https://github.com/WebAssembly/relaxed-simd) behind the "--enable-relaxed-simd" flag.

@marcusb marcusb force-pushed the relaxed-simd branch 2 times, most recently from f9ceacd to 821b0a5 Compare September 13, 2022 11:56
@keithw
Copy link
Member

keithw commented Sep 16, 2022

Thank you for doing this! I'm probably not the most qualified person to review this, but, as a starter, I don't think we want to vendor the relaxed-simd test scripts into wabt unless we really have to. My suggestion would be to submit a PR to add relaxed-simd to the testsuite repo list (https://github.com/WebAssembly/testsuite/blob/main/update-testsuite.sh#L9) and then add them there, and then coming back here with a PR that updates the testsuite submodule, and then we go from there.

@marcusb
Copy link
Contributor Author

marcusb commented Sep 18, 2022

Ok, added to testsuite in WebAssembly/testsuite#62

@keithw
Copy link
Member

keithw commented Sep 20, 2022

Those test changes don't look like a problem, but we should probably update the testsuite in a separate PR... For the non-wasm2c tests, it looks like they just need to be rebased. For the wasm2c tests, either this will need to happen after #1877 (in which case updating the test suite is just a rebase too) or more tests will need to be frozen and moved to old-spec.

@marcusb
Copy link
Contributor Author

marcusb commented Sep 23, 2022

The Relaxed SIMD proposal is still in flux so there will be some changes down the line:

  • The FMS instructions have new names and operand order, but the spec tests haven't been adjusted to match so I'm holding off with that change.
  • There is a new instruction f32x4.relaxed_dot_bf16x8_add_f32x4, not implemented in this PR.

case O::F32X4Min: return DoSimdBinop(FloatMin<f32>);
case O::F32X4Max: return DoSimdBinop(FloatMax<f32>);
case O::F32X4Div:
return DoSimdBinop(FloatDiv<f32>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep this on a single line like the others? It doesn't looks like we are near the line limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done by clang-format and enforced by the linting, if I'm not mistaken.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unfortunate.. I guess we should exclude this whole block from clang-formatting.

/*
* Number of bits required to store an opcode
*/
#define MAX_OPCODE_BITS 9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an intentional part of the relaxed simd proposal, that the opcode space is now larger and a byte?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vector instructions were always using variable-length integer opcodes, but these are the only instructions in this implementation with opcodes above 0xff. This necessitates a change in the structure of the internal lookup table (and also unfortunately doubles its size to 128 kB).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, adding relaxed SIMD introduces opcode whose encoding is > 0xff for the first time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to be precise we're adding prefixed opcodes with suffixes over 0xff.

@keithw
Copy link
Member

keithw commented Nov 8, 2022

@marcusb Do you have cycles to respond to the review (which might just be about formatting at this point) and rebase? This seems close and would be great to have it in...

@marcusb
Copy link
Contributor Author

marcusb commented Nov 9, 2022

@keithw I'll bring the PR up to date with the latest changes in the spec. Here is the testsuite bump PR for a start.

@marcusb
Copy link
Contributor Author

marcusb commented Nov 11, 2022

@keithw Seems there are a few unrelated test failures after pulling in the latest testsuite, eg some elem-type mismatches.

@sbc100
Copy link
Member

sbc100 commented Nov 11, 2022

@keithw Seems there are a few unrelated test failures after pulling in the latest testsuite, eg some elem-type mismatches.

I've been working on a PR to update the testsuite .. along with the corresponding fixes. Uploading now.

@sbc100
Copy link
Member

sbc100 commented Nov 11, 2022

#2054

@marcusb
Copy link
Contributor Author

marcusb commented Nov 15, 2022

Rebased and brought up to date with spec.

@sbc100 sbc100 requested a review from ngzhian November 15, 2022 16:03
Copy link
Member

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but maybe lets hear from @ngzhian first

Copy link
Member

@ngzhian ngzhian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

@keithw
Copy link
Member

keithw commented Nov 18, 2022

Ok to merge this now?

@marcusb
Copy link
Contributor Author

marcusb commented Nov 18, 2022

Ok to merge as far as I'm concerned.

@keithw
Copy link
Member

keithw commented Nov 30, 2022

Ok, merging. Hope there's no objection, but I'd like to copy the note from the commit message (about the missing f32x4.relaxed_dot_bf16x8_add_f32x4 instruction) to a footnote in the README so we don't forget about it and nobody gets surprised if they try to use that instruction and get an error. Of course we should remove the note and add the remaining test as soon as we implement the instr (and I assume the proposal may continue to evolve anyway).

@keithw
Copy link
Member

keithw commented Nov 30, 2022

Sigh, I thought I was going to be able to merge this but I guess we have to wait until after #2082.

marcusb and others added 2 commits November 30, 2022 12:50
This adds support for the new opcodes from the Relaxed SIMD proposal
(https://github.com/WebAssembly/relaxed-simd) behind the
"--enable-relaxed-simd" flag.

The exception is the f32x4.relaxed_dot_bf16x8_add_f32x4 instruction
which is not yet implemented.
@keithw keithw enabled auto-merge (squash) November 30, 2022 20:51
@keithw keithw merged commit 93c534c into WebAssembly:main Nov 30, 2022
@marcusb marcusb deleted the relaxed-simd branch December 1, 2022 03:19
matthias-blume pushed a commit to matthias-blume/wabt that referenced this pull request Dec 16, 2022
This adds support for the new opcodes from the Relaxed SIMD proposal
(https://github.com/WebAssembly/relaxed-simd) behind the
"--enable-relaxed-simd" flag.

The exception is the f32x4.relaxed_dot_bf16x8_add_f32x4 instruction
which is not yet implemented.
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.

4 participants