Skip to content
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

Add portable_simd support #45

Merged
merged 6 commits into from
Jun 22, 2024

Conversation

farnoy
Copy link
Contributor

@farnoy farnoy commented Jun 16, 2023

Fixes #33

Does not have acceleration for trigonometric functions due to rust-lang/portable-simd#6

Follows the packed_simd implementation closely, but masks are called mask<$elt>x<$lanes> not m<$elt>x<$lanes>

Has a few more things than packed_simd like native recip, floor, ceil, trunc, but crucially it's missing trigonometry accelration.


#[inline(always)]
unsafe fn extract_unchecked(&self, i: usize) -> Self::Element {
self.0[i]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no unchecked version from what I've seen


#[inline(always)]
unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element) {
self.0[i] = val;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here?

};
use approx::AbsDiffEq;
#[cfg(feature = "decimal")]
use decimal::d128;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have not tested with this feature, TODO

#[inline(always)]
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> $wrapped {
<$wrapped>::new($(
ignore_snd!([self.sample(rng)], [$i])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a nicer specialization for packed_simd vectors in the rand crate, not sure if it's faster or by how much. It uses fill_bytes loaded into an int vector and then shuffled to fit into a float vector.

@sebcrozet
Copy link
Member

Thank you for this PR! Since it’s been a while, I took the liberty of rebasing on top of master and updated to the latest nightly.

@sebcrozet sebcrozet merged commit 2cd20ed into dimforge:master Jun 22, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate from packed_simd to stdlib simd (aka portable simd)
2 participants