-
Notifications
You must be signed in to change notification settings - Fork 83
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
Fix sat math #100
Fix sat math #100
Conversation
Looks like PPC now emits an LLVM Error on saturating math on SimdI128. How do we want to proceed? |
iirc, current PPC (until SimpleV comes around) only has 128-bit SIMD: how about just leave off |
or, just get rustc to use the fall-back scalar code for that case for the simd intrinsics |
There's no reason you can't do 128 bit saturating math in a 128 bit vector. Definitely an LLVM issue. We should probably report it and use a scalar fallback for now. Also worth noting this would fail on master, and only shows up because of the fixed tests. |
Something was sus about the last merge, so rerunning CI. |
True. I guess my point was that since PPC only supports 128-bit vectors and since a 128-bit vector of |
well that wasn't what I was expecting. |
|
Guess we're dropping even bitwise or is scalarized when avx512dq is enabled -- for both i128x2 and i128x4 |
(Edit: misread assembly, clang and gcc do have matching abis) gcc and clang don't even agree on how to pass i128x2 and i128x4 -- gcc passes them in avx2 and avx512 registers, clang passes them in memory. Both gcc and clang scalarize a bitwise or: |
I'd be more interested in implementing these in rust with smaller integers than dropping them entirely. |
@workingjubilee I opened an LLVM bug and stdsimd bug (#104) |
Well, if we're going to write a 2-limb vectorized BigInt why not just add full-featured vectorized BigInts? |
Because rust only has i128 right now :) |
Mm. Even if we resolve the kind of quasi-philosophical objection here, I am somewhat concerned about adding operations we don't actually have reasonably efficient implementations for, unless we intend to bugfix them immediately, or if we are confident that they are useful if you enable higher-level SIMD features. We have actually managed to take things out and then (ahem) "circle back" and readd them once we solved the problem on some level, too, so I think we should do that again here. It's not much of a SimdU128 if it's not actually doing any SIMD operations even with all the bells and whistles turned on, is it? |
Well, we can transmute to another type for bit ops, and then use an explicit non-vector implementation for arithmetic with the intention of adding better arithmetic in the future. |
f9a2d83
to
92d643b
Compare
/// let unsat = x.abs(); | ||
/// let sat = x.saturating_abs(); | ||
#[doc = concat!("assert_eq!(unsat, ", stringify!($name), "::from_array([MIN, 2, 0, 3]);")] | ||
#[doc = concat!("let xs = ", stringify!($name), "::from_array([MIN, -2, 0, 3]);")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm why xs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mild case of whim / there's a common pattern of for x in xs
thus, implied plurality (a vector)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I would just go with x
I think, it is a vector but we're not really concerned about the particular lanes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I realized this is my own PR so I can't "approve" anything, but everything looks good to me, don't let this comment hold up a merge
Looks good to me, just want to merge it in