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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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.

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)
1 participant