8 releases

0.3.9 Jul 30, 2023
0.3.8 Apr 16, 2023
0.3.3 Feb 5, 2019
0.3.2 Jan 31, 2019
0.1.0 Jul 26, 2018

#1351 in Hardware support

Download history 9047/week @ 2024-01-03 8622/week @ 2024-01-10 8899/week @ 2024-01-17 9510/week @ 2024-01-24 9597/week @ 2024-01-31 8457/week @ 2024-02-07 8240/week @ 2024-02-14 9995/week @ 2024-02-21 10220/week @ 2024-02-28 10097/week @ 2024-03-06 10683/week @ 2024-03-13 9402/week @ 2024-03-20 12438/week @ 2024-03-27 13258/week @ 2024-04-03 11871/week @ 2024-04-10 10882/week @ 2024-04-17

50,031 downloads per month
Used in fewer than 27 crates

MIT/Apache

580KB
13K SLoC

Simd<[T; N]>

Implementation of Rust RFC #2366: std::simd

Latest Version docs

WARNING: this crate only supports the most recent nightly Rust toolchain and will be superseded by #![feature(portable_simd)].

Documentation

Examples

Most of the examples come with both a scalar and a vectorized implementation.

Cargo features

  • into_bits (default: disabled): enables FromBits/IntoBits trait implementations for the vector types. These allow reinterpreting the bits of a vector type as those of another vector type safely by just using the .into_bits() method.

Performance

The following ISPC examples are also part of packed_simd's examples/ directory, where packed_simd+rayon are used to emulate ISPC's Single-Program-Multiple-Data (SPMD) programming model. The performance results on different hardware is shown in the readme.md of each example. The following table summarizes the performance ranges, where + means speed-up and - slowdown:

  • aobench: [-1.02x, +1.53x],
  • stencil: [+1.06x, +1.72x],
  • mandelbrot: [-1.74x, +1.2x],
  • options_pricing:
    • black_scholes: +1.0x
    • binomial_put: +1.4x

While SPMD is not the intended use case for packed_simd, it is possible to combine the library with rayon to poorly emulate ISPC's SPMD programming model in Rust. Writing performant code is not as straightforward as with ISPC, but with some care (e.g. see the Performance Guide) one can easily match and often out-perform ISPC's "default performance".

Platform support

The following table describes the supported platforms: build shows whether the library compiles without issues for a given target, while run shows whether the test suite passes for a given target.

Linux build run
i586-unknown-linux-gnu
i686-unknown-linux-gnu
x86_64-unknown-linux-gnu
arm-unknown-linux-gnueabihf
armv7-unknown-linux-gnueabi
aarch64-unknown-linux-gnu
powerpc-unknown-linux-gnu
powerpc64-unknown-linux-gnu
powerpc64le-unknown-linux-gnu
s390x-unknown-linux-gnu
sparc64-unknown-linux-gnu
thumbv7neon-unknown-linux-gnueabihf
MacOSX build run
x86_64-apple-darwin
Android build run
x86_64-linux-android
armv7-linux-androideabi
aarch64-linux-android
thumbv7neon-linux-androideabi
iOS build run
x86_64-apple-ios
aarch64-apple-ios

Machine code verification

The verify/ crate tests disassembles the portable packed vector APIs at run-time and compares the generated machine code against the desired one to make sure that this crate remains efficient.

License

This project is licensed under either of

at your option.

Contributing

We welcome all people who want to contribute. Please see the contributing instructions for more information.

Contributions in any form (issues, pull requests, etc.) to this project must adhere to Rust's Code of Conduct.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in packed_simd by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.5–2.4MB
~37K SLoC