-
Notifications
You must be signed in to change notification settings - Fork 270
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
Are rotate_left/right/swap_bytes methods possible? #419
Comments
I'm also curious about |
Sine one can easily perform these using shuffles, I think the question is rather whether it is worth it to implement these. Is there an ISA that supports them? EDIT: FWIW horizontal rotate_left/right would need to rotate bytes and not bits, so that might be an issue. Vertical rotates should be implementable on top of the shift operators + splat, and the bitwise operators. I don't know which names to use to differentiate these though, maybe For swap bytes both vertical and horizontal versions can use shuffles AFAICT. |
To be clear, I want to rotate each lane. Not shuffle the lanes around.
…Sent from my mobile device
On Apr 9, 2018, at 23:07, gnzlbg ***@***.***> wrote:
Sine one can easily perform these using shuffles, I think the question is rather whether it is worth it to implement these. Is there an ISA that supports them?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I see. In the meantime you can manually implement rotates using bitwise operators, shifts, and splat: #![feature(stdsimd)]
use std::simd::*;
fn rotate_left(x: u32x4, n: u32) -> u32x4 {
let n = n % 32;
(x << n) | (x >> (32 - n) % 32)
} (note that
The problem is that "rotate left" is both an operation on the primitive type (e.g. For
Somebody sending a PR with a tested implementation might just be enough. From there to having these land on stable Rust, a mini-FCP might be enough as well. |
vertical rotates pull request here #496 |
We need |
You can send a PR. I think we can just call it Just keep in mind that |
Oh I was thinking to use shuffles. Would |
Indeed, shuffles should definitely work. I don't know if |
I have little context but ISTM that element-wise bswap is quite a different operation from "interpret the vector as a huge integer and bswap that". But even if I'm mistaken about that, huge integer types like i256 and i512 (and even i128 to a lesser degree) have very spotty support in most backends even functionality-wise, let alone in terms of performance optimizations. Shuffles OTOH sound great. Except:
Where'd you get that idea? https://godbolt.org/g/NG6Gxu |
I got it from the LLVM LangRef :/
…On Fri 29. Jun 2018 at 21:06, Robin Kruppe ***@***.***> wrote:
I have little context but ISTM that element-wise bswap is quite a
different operation from "interpret the vector as a huge integer and bswap
that". But even if I'm mistaken about that, huge integer types like i256
and i512 (and even i128 to a lesser degree) have very spotty support in
most backends even functionality-wise, let alone in terms of performance
optimizations. Shuffles OTOH sound great. Except:
Just keep in mind that llvm.bswap only works for integers, not vectors, so
you are going to have to cast the 256-bit and 512-bit vectors to i256 and
i512 somehow..
Where'd you get that idea? https://godbolt.org/g/NG6Gxu
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#419 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA3Npk1Ouepr-TqH7FgWjg-MSusQI3nzks5uBnqXgaJpZM4TNoRb>
.
|
Swap bytes PR #509 |
@rkruppe https://llvm.org/docs/LangRef.html#llvm-bswap-intrinsics doesn't mention vectors, only integers :/ But if |
That's curious. But I'm inclined to say it's a docs bug (that someone could report to get clarity) since most similar intrinsics can be applied to vectors "by default" and vector-bswap even has target-independent tests. |
I've reported the bug: https://bugs.llvm.org/show_bug.cgi?id=38012 |
This is fixed in https://github.com/gnzlbg/packed_simd |
I'm curious what it would take to get functionality like integer primitives' methods.
The text was updated successfully, but these errors were encountered: