-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Minimum x86_64 feature support required for SIMD proposal #3809
Comments
For cg_clif it would be nice if Cranelift could always legalize simd operations too big for the target arch to smaller simd operations or even scalar operations as necessary. The code has to exist somewhere as portable-simd allows vectors bigger than the natively supported size. Putting it in Cranelift allows others to reuse the same code and allows cg_clif to not contain a hardcoded list of which operation of which size is allowed when each specific target feature is enabled. |
Aspirationally I think it would be nice to have the ability to run all features on any x86_64 machine; that means SSE2 (required by x86_64 ISA) only. But practically speaking, SSE4.1 was introduced with Core 2 in 2007-ish and so is 14-15 years old at this point; if we have to require it when SIMD is turned on, at least for now, that's not the end of the world. (Almost all extant x86_64 chips will be newer than that -- we'd just be excluding the very early Athlon 64s and late-model Pentium 4s.) In any case, we should fail more nicely than an internal panic, as you say -- I can do some thinking about where the right place might be. Perhaps we can take an I'll file an issue to track making SIMD "SSE2-clean" as well. |
If we decide to go the route of "simd in wasmtime simply requires these features" then I could see that either happening in Wasmtime or in Cranelift, I dont think it necessarily is required to be in Cranelift. I suspect it might actually be easiest in Wasmtime to avoid having to keep everything in sync about individual instructions and at the Cranelift layer we could point existing panics to #3810 and for Wasmtime you'd get a first-class error on creating an |
|
Chiming in late, but here's some context from the Wasm SIMD sub-group: at some point we reached a general consensus that, on x86, SSE 4.1 would form the baseline for instructions added to the proposal, e.g, see this comment (probably documented more clearly somewhere else):
I agree with @cfallin that #3810 is a "nice to have" but most hardware running has at least SSE 4.1. Whether we link Wasm SIMD and SSE 4.1 in Wasmtime (as @alexcrichton has suggested) or in Cranelift (as @bjorn3 has suggested) is not too important to me but if either of you implements this could you tag me in the PR so I can take a look? |
This commit unconditionally enables some x86_64 instructions when fuzzing because the cranelift backend is known to not work if these features are disabled. From discussion on the wasm simd proposal the assumed general baseline for running simd code is SSE4.1 anyway. At this time I haven't added any sort of checks in Wasmtime itself. Wasmtime by default uses the native architecture and when explicitly enabling features this still needs to be explicitly specified. Closes bytecodealliance#3809
Ok I went ahead and posted #3814 and figure this issue can be closed otherwise. If in practice no one's actually running without SSE 4.1 then I don't think it's a big issue to leave these panics. |
…nabled. Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
I actually had someone complain about cg_clif not working on cpu's before nehalem due to enabling the nehalem feature for simd support: https://github.com/bjorn3/rustc_codegen_cranelift/issues/1148 |
…nabled. Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
* Unconditionally enable sse3, ssse3, and sse4.1 when fuzzing This commit unconditionally enables some x86_64 instructions when fuzzing because the cranelift backend is known to not work if these features are disabled. From discussion on the wasm simd proposal the assumed general baseline for running simd code is SSE4.1 anyway. At this time I haven't added any sort of checks in Wasmtime itself. Wasmtime by default uses the native architecture and when explicitly enabling features this still needs to be explicitly specified. Closes #3809 * Update crates/fuzzing/src/generators.rs Co-authored-by: Andrew Brown <andrew.brown@intel.com> Co-authored-by: Andrew Brown <andrew.brown@intel.com>
…nabled. Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
…nabled. Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
…nabled. Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
…nabled. Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
…nabled. Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
…nabled. Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
…alliance#3814) * Unconditionally enable sse3, ssse3, and sse4.1 when fuzzing This commit unconditionally enables some x86_64 instructions when fuzzing because the cranelift backend is known to not work if these features are disabled. From discussion on the wasm simd proposal the assumed general baseline for running simd code is SSE4.1 anyway. At this time I haven't added any sort of checks in Wasmtime itself. Wasmtime by default uses the native architecture and when explicitly enabling features this still needs to be explicitly specified. Closes bytecodealliance#3809 * Update crates/fuzzing/src/generators.rs Co-authored-by: Andrew Brown <andrew.brown@intel.com> Co-authored-by: Andrew Brown <andrew.brown@intel.com>
…nabled. (bytecodealliance#3816) Addresses bytecodealliance#3809: when we are asked to create a Cranelift backend with shared flags that indicate support for SIMD, we should check that the ISA level needed for our SIMD lowerings is present.
With #3800 on oss-fuzz last night it quickly found a few "bugs" in the cranelift backend for x86_64, primarily around SIMD support. This led me to raise a question, however, as to whether or not we want to consider these issues bugs. The crashes all have the same pattern where we're forcibly disabling processor features and testing whether wasm still works.
Currently in Wasmtime it appears that at least for some instructions the SSE 4.1 extensions are required. If those are not present then two crashes found so far are:
Cannot emit inst 'pmovsxdq 0(%r19J), %r0V' for target; failed to match ISA requirements: [SSE41]
f32x4.floor
With this in mind I'm wondering if it makes sense to consider these bugs or not? There's nothing wrong with the SSE 4.1 codegen this is only a problem for when that feature isn't available we're unable to generate code. Is this something we want to consider as a bug? Or alternatively we can also simply declare that running Wasmtime with the SIMD wasm feature enabled requires SSE 4.1 on x86_64 and we can provide a more first-class error in Wasmtime when a module is attempted to be used without SSE 4.1
The text was updated successfully, but these errors were encountered: