breadsimd
is a library for SIMD (Single Instruction Multiple Data) operations on arrays of number values. The main idea with breadsimd
is that, in Rust, it should be possible to have your cake and eat it, too. Types in breadsimd
are generic over the type, meaning that they can contain any number value. However, using specialization, breadsimd
can also provide optimized implementations for specific types, such as f32
and i64
.
If the unstable-exclusive nightly
feature is enabled, the crate enables SIMD optimizations, through the currently-unstable portable-simd
and specialization
features. If not, it falls back to a naive implementation.
use breadsimd::Double;
use core::num::Wrapping;
// At the time of writing, `Wrapping<u32>` is not optimized using SIMD.
let mut a = Double::new([Wrapping(1), Wrapping(2)]);
a += Double::new([Wrapping(3), Wrapping(4)]);
assert_eq!(a, Double::new([Wrapping(4), Wrapping(6)]));
// However, `u32` is optimized using SIMD.
let mut b = Double::<u32>::new([1, 2]);
b += Double::new([3, 4]);
assert_eq!(b, Double::new([4, 6]));
std
(enabled by default) - Enables the usage oflibstd
withinbreadsimd
. This does not affect the external API, but implementssqrt
in a more efficient way.nightly
(requires a nightly compiler) - Enables certain generic types to be replaced with SIMD primitives. This is currently only supported on nightly, as it requires theportable-simd
andspecialization
features.bytemuck
- Implementsbytemuck::Pod
andbytemuck::Zeroable
forDouble
andQuad
.
Legend: Italics indicate an optional dependency, while bold indicates a public dependency.
bytemuck
(version 1.12 or later) - ProvidesPod
andZeroable
implementations forDouble
andQuad
. This is only enabled when thebytemuck
feature is enabled.cfg-if
(version 1.0 or later) - Providescfg_if!
macro, which is used to conditionally compile code based on thenightly
feature.num-traits
(version 0.2 or later) - Provides numerical traits likeReal
orSigned
, which provide for generic functionality over number types.
This crate will not release its 1.0.0 version until the specialization
and portable_simd
features in the standard library are stable.
This crate is dual licensed under the Boost Software License (LICENSE-BOOST
) and the Apache 2.0 License (LICENSE-APACHE
), at your option. See LICENSE-APACHE
and LICENSE-BOOST
for details.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.