You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to create a new crate. Finally write this in `src/main.rs`:
38
28
```rust
39
29
#![feature(portable_simd)]
40
-
usecore_simd::*;
30
+
usestd::simd::f32x4;
41
31
fnmain() {
42
32
leta=f32x4::splat(10.0);
43
33
letb=f32x4::from_array([1.0, 2.0, 3.0, 4.0]);
44
34
println!("{:?}", a+b);
45
35
}
46
36
```
47
37
48
-
Explanation: We import all the bindings from the crate with the first line. Then, we construct our SIMD vectors with methods like `splat` or `from_array`. Finally, we can use operators on them like `+` and the appropriate SIMD instructions will be carried out. When we run `cargo run` you should get `[11.0, 12.0, 13.0, 14.0]`.
49
-
50
-
## Code Organization
38
+
Explanation: We construct our SIMD vectors with methods like `splat` or `from_array`. Next, we can use operators like `+` on them, and the appropriate SIMD instructions will be carried out. When we run `cargo run` you should get `[11.0, 12.0, 13.0, 14.0]`.
51
39
52
-
Currently the crate is organized so that each element type is a file, and then the 64-bit, 128-bit, 256-bit, and 512-bit vectors using those types are contained in said file.
40
+
## Supported vectors
53
41
54
-
All types are then exported as a single, flat module.
42
+
Currently, vectors may have up to 64 elements, but aliases are provided only up to 512-bit vectors.
55
43
56
44
Depending on the size of the primitive type, the number of lanes the vector will have varies. For example, 128-bit vectors have four `f32` lanes and two `f64` lanes.
***Masks:**8-bit, 16-bit, 32-bit, 64-bit, and `usize`-sized masks
63
51
64
52
Floating point, signed integers, and unsigned integers are the [primitive types](https://doc.rust-lang.org/core/primitive/index.html) you're already used to.
65
-
The `mask` types are "truthy" values, but they use the number of bits in their name instead of just 1 bit like a normal `bool` uses.
53
+
The mask types have elements that are "truthy" values, like `bool`, but have an unspecified layout because different architectures prefer different layouts for mask types.
0 commit comments