-
Notifications
You must be signed in to change notification settings - Fork 11
Introduce semantic conversion traits #31
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
base: main
Are you sure you want to change the base?
Conversation
1b0786f
to
28aba20
Compare
Open question: Should this supplant |
28aba20
to
cbafbac
Compare
Discussion about this proposal: https://xi.zulipchat.com/#narrow/channel/514230-simd/topic/Ergonomic.20native-width.20conversions |
3a57607
to
5b83500
Compare
5b83500
to
80b5c5c
Compare
Second draft:
I don't like the trait or primitive method names much at all; please bikeshed. Especially "float" as a verb feels bad. |
788569b
to
39df826
Compare
Tweaked naming, factored out common generation logic, and expanded to a superset of existing conversion operations. I think this is ready now, though still happy to brainstorm on better names. |
39df826
to
f9f9141
Compare
1f94ffd
to
7a9bd6d
Compare
Reworked to allow conversions for e.g. |
@@ -667,6 +669,10 @@ pub trait SimdFloat<Element: SimdElement, S: Simd>: | |||
+ core::ops::Div<Output = Self> | |||
+ core::ops::Div<Element, Output = Self> | |||
{ | |||
#[inline(always)] | |||
fn to_int<T: SimdCvtTruncate<Self>>(self) -> T { |
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.
Naming bikeshed thread. Ideas: to_int_truncate
, truncate_to_int
, one of those but with trunc
...
|
||
/// Construction of floating point vectors from integers | ||
pub trait SimdCvtFloat<T> { | ||
fn float_from(x: T) -> Self; |
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.
Naming bikeshed: from_int
, convert_from_int
, ...
d26ca59
to
eed1d41
Compare
Sorry for the lack of communication – I plan to discuss this PR and proposal at the next Renderer office hours. Thank you for your excellent work! |
eed1d41
to
b1b3115
Compare
This proposes a generic API for conversions between vectors of the same element size and count, usable on generic native-width vectors. If I get positive feedback I'll fill out some more cases before merging.