cpu_features: add PPC64LE compile-time SIMD feature detection#482
cpu_features: add PPC64LE compile-time SIMD feature detection#482runlevel5 wants to merge 1 commit into
Conversation
Add is_enabled_altivec(), is_enabled_vsx(), and is_enabled_power9() for powerpc64 targets. These use compile-time detection via cfg!(target_feature) following the same pattern as wasm32/simd128, since runtime detection (is_powerpc64_feature_detected!) is not available on stable Rust. Users enable PPC64LE SIMD with -C target-feature=+altivec,+vsx or -C target-cpu=pwr8 (or higher).
|
By itself this is kind of pointless, because this code will never run. We also don't currently test on powerpc64 at all, but you can set that up in the CI file. So, weirdly, I think that this PR is too small, can you make something that runs end-to-end and actually gets tested in CI? |
|
Also, just interested, what makes you want to add powerpc64 support? |
I and many people have been using C zlib-ng to develop softwares for PPC64 for years. Many are now picking up Rust, to me having zlib-rs supporting SIMD would be a big win for Rust adoption in enterprise sector. |
This is just the starter. In the upcoming PR I will port over more features. |
Neat! Now, something that you're already running into here is that much of the PPC64 infrastructure is still unstable. This is mostly due to a (perceived) lack of a need. With modest amounts of funding, these features can actually be stabilized (I speak here also as co-maintainer of
Sure, could you at least add CI support in this PR? I think you can base that on the s390x code here zlib-rs/.github/workflows/checks.yaml Lines 28 to 30 in e00c7ac and zlib-rs/.github/workflows/checks.yaml Lines 72 to 75 in e00c7ac |
|
@folkertdev could you please apply for a native runner from IBM? Please see https://github.com/IBM/actionspz, IMHO it is way faster than cross-compilation |
To be fair it is going to take some time for the enterprise customers to onboard with Rust, atm all I could see is traditional stack like Java, C, C++, Python ...COBOL, FORTRAN. So I hope by working with Rust folks to lay a good foundation, it would encourage more adoption and hopefully more funding from those firms in Rust-based techs. |
|
Cross-compilation with rust is plenty fast in our experience. Let's see first how far we get with that.
Well now you know that the option exists. By default powerpc64 rarely makes it to the top of the to-do list, but it could with relatively small amounts of funding. |
|
I've just added CI support. However, I'd actually like to see the followup that actually uses altivec/vsx before merging this, otherwise there is a risk of having a bunch of code that just never gets used. |
Sure I could add them into this same PR if you are okay with a bigger size PR |
|
sure let's do that. I'd rather have something that works start-to-finish. |
|
friendly ping? |
|
@folkertdev I am still here, I will resume this work once I am back from my holiday |
Summary
is_enabled_altivec(),is_enabled_vsx(), andis_enabled_power9()tocpu_features.rsfor powerpc64 targetscfg!(target_feature = ...), following the same pattern as wasm32/simd128Why?
This is groundwork for PPC64LE SIMD support. The
core::arch::powerpc64intrinsics andis_powerpc64_feature_detected!macro are both nightly-only in Rust (tracked by rust-lang/rust#111145 (rust-lang/rust#111145) and #111191 (rust-lang/rust#111191)), so runtime detection is not possible on stable. Compile-time detection viacfg!(target_feature)is stable and is the same approach used for wasm32.Users enable PPC64LE SIMD at build time with -C
target-feature=+altivec,+vsxor-C target-cpu=pwr8(or higher).Testing
Future plan
Port features from the C Zlib