Skip to content

Commit c2fbead

Browse files
rust-lang/portable-simd#272: Standardize documentation for SIMD vector and mask types
This is a documentation-only patch that standardizes the presentation of vector types like `u32x4` and mask types like `mask32x16`. The reasoning behind the patch was as follows: 1. Standardized terminology should be preferred, so `element` instead of `value` and `SIMD vector` instead of `vector`. These terms appear in the rest of the documentation and tutorials. 2. Try to avoid situations where two numbers are next to each other. So `16 elements of 32 bits` instead of `16 32-bit elements`. 4. Try to anticipate what readers are looking for -- so state the full bit-width directly. ### Vector Types - Before: Vector of 32 `i8` values - After: A 256-bit SIMD vector with 32 elements of type `i8`. ### Mask Types - Before: Vector of 16 16-bit masks - After: A mask for SIMD vectors with 16 elements of 32 bits.
2 parents 0711e11 + 8cd9325 commit c2fbead

File tree

4 files changed

+67
-65
lines changed

4 files changed

+67
-65
lines changed

crates/core_simd/src/masks.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ impl_element! { isize }
7777

7878
/// A SIMD vector mask for `LANES` elements of width specified by `Element`.
7979
///
80+
/// Masks represent boolean inclusion/exclusion on a per-lane basis.
81+
///
8082
/// The layout of this type is unspecified.
8183
#[repr(transparent)]
8284
pub struct Mask<T, const LANES: usize>(mask_impl::Mask<T, LANES>)
@@ -507,58 +509,58 @@ where
507509
}
508510
}
509511

510-
/// Vector of eight 8-bit masks
512+
/// A mask for SIMD vectors with eight elements of 8 bits.
511513
pub type mask8x8 = Mask<i8, 8>;
512514

513-
/// Vector of 16 8-bit masks
515+
/// A mask for SIMD vectors with 16 elements of 8 bits.
514516
pub type mask8x16 = Mask<i8, 16>;
515517

516-
/// Vector of 32 8-bit masks
518+
/// A mask for SIMD vectors with 32 elements of 8 bits.
517519
pub type mask8x32 = Mask<i8, 32>;
518520

519-
/// Vector of 16 8-bit masks
521+
/// A mask for SIMD vectors with 64 elements of 8 bits.
520522
pub type mask8x64 = Mask<i8, 64>;
521523

522-
/// Vector of four 16-bit masks
524+
/// A mask for SIMD vectors with four elements of 16 bits.
523525
pub type mask16x4 = Mask<i16, 4>;
524526

525-
/// Vector of eight 16-bit masks
527+
/// A mask for SIMD vectors with eight elements of 16 bits.
526528
pub type mask16x8 = Mask<i16, 8>;
527529

528-
/// Vector of 16 16-bit masks
530+
/// A mask for SIMD vectors with 16 elements of 16 bits.
529531
pub type mask16x16 = Mask<i16, 16>;
530532

531-
/// Vector of 32 16-bit masks
533+
/// A mask for SIMD vectors with 32 elements of 16 bits.
532534
pub type mask16x32 = Mask<i16, 32>;
533535

534-
/// Vector of two 32-bit masks
536+
/// A mask for SIMD vectors with two elements of 32 bits.
535537
pub type mask32x2 = Mask<i32, 2>;
536538

537-
/// Vector of four 32-bit masks
539+
/// A mask for SIMD vectors with four elements of 32 bits.
538540
pub type mask32x4 = Mask<i32, 4>;
539541

540-
/// Vector of eight 32-bit masks
542+
/// A mask for SIMD vectors with eight elements of 32 bits.
541543
pub type mask32x8 = Mask<i32, 8>;
542544

543-
/// Vector of 16 32-bit masks
545+
/// A mask for SIMD vectors with 16 elements of 32 bits.
544546
pub type mask32x16 = Mask<i32, 16>;
545547

546-
/// Vector of two 64-bit masks
548+
/// A mask for SIMD vectors with two elements of 64 bits.
547549
pub type mask64x2 = Mask<i64, 2>;
548550

549-
/// Vector of four 64-bit masks
551+
/// A mask for SIMD vectors with four elements of 64 bits.
550552
pub type mask64x4 = Mask<i64, 4>;
551553

552-
/// Vector of eight 64-bit masks
554+
/// A mask for SIMD vectors with eight elements of 64 bits.
553555
pub type mask64x8 = Mask<i64, 8>;
554556

555-
/// Vector of two pointer-width masks
557+
/// A mask for SIMD vectors with two elements of pointer width.
556558
pub type masksizex2 = Mask<isize, 2>;
557559

558-
/// Vector of four pointer-width masks
560+
/// A mask for SIMD vectors with four elements of pointer width.
559561
pub type masksizex4 = Mask<isize, 4>;
560562

561-
/// Vector of eight pointer-width masks
563+
/// A mask for SIMD vectors with eight elements of pointer width.
562564
pub type masksizex8 = Mask<isize, 8>;
563565

564566
macro_rules! impl_from {

crates/core_simd/src/vector/float.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,23 @@ macro_rules! impl_float_vector {
177177
impl_float_vector! { f32, u32, i32 }
178178
impl_float_vector! { f64, u64, i64 }
179179

180-
/// Vector of two `f32` values
180+
/// A 64-bit SIMD vector with two elements of type `f32`.
181181
pub type f32x2 = Simd<f32, 2>;
182182

183-
/// Vector of four `f32` values
183+
/// A 128-bit SIMD vector with four elements of type `f32`.
184184
pub type f32x4 = Simd<f32, 4>;
185185

186-
/// Vector of eight `f32` values
186+
/// A 256-bit SIMD vector with eight elements of type `f32`.
187187
pub type f32x8 = Simd<f32, 8>;
188188

189-
/// Vector of 16 `f32` values
189+
/// A 512-bit SIMD vector with 16 elements of type `f32`.
190190
pub type f32x16 = Simd<f32, 16>;
191191

192-
/// Vector of two `f64` values
192+
/// A 128-bit SIMD vector with two elements of type `f64`.
193193
pub type f64x2 = Simd<f64, 2>;
194194

195-
/// Vector of four `f64` values
195+
/// A 256-bit SIMD vector with four elements of type `f64`.
196196
pub type f64x4 = Simd<f64, 4>;
197197

198-
/// Vector of eight `f64` values
198+
/// A 512-bit SIMD vector with eight elements of type `f64`.
199199
pub type f64x8 = Simd<f64, 8>;

crates/core_simd/src/vector/int.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,62 +42,62 @@ impl_integer_vector! { i32 }
4242
impl_integer_vector! { i64 }
4343
impl_integer_vector! { i8 }
4444

45-
/// Vector of two `isize` values
45+
/// A SIMD vector with two elements of type `isize`.
4646
pub type isizex2 = Simd<isize, 2>;
4747

48-
/// Vector of four `isize` values
48+
/// A SIMD vector with four elements of type `isize`.
4949
pub type isizex4 = Simd<isize, 4>;
5050

51-
/// Vector of eight `isize` values
51+
/// A SIMD vector with eight elements of type `isize`.
5252
pub type isizex8 = Simd<isize, 8>;
5353

54-
/// Vector of two `i16` values
54+
/// A 32-bit SIMD vector with two elements of type `i16`.
5555
pub type i16x2 = Simd<i16, 2>;
5656

57-
/// Vector of four `i16` values
57+
/// A 64-bit SIMD vector with four elements of type `i16`.
5858
pub type i16x4 = Simd<i16, 4>;
5959

60-
/// Vector of eight `i16` values
60+
/// A 128-bit SIMD vector with eight elements of type `i16`.
6161
pub type i16x8 = Simd<i16, 8>;
6262

63-
/// Vector of 16 `i16` values
63+
/// A 256-bit SIMD vector with 16 elements of type `i16`.
6464
pub type i16x16 = Simd<i16, 16>;
6565

66-
/// Vector of 32 `i16` values
66+
/// A 512-bit SIMD vector with 32 elements of type `i16`.
6767
pub type i16x32 = Simd<i16, 32>;
6868

69-
/// Vector of two `i32` values
69+
/// A 64-bit SIMD vector with two elements of type `i32`.
7070
pub type i32x2 = Simd<i32, 2>;
7171

72-
/// Vector of four `i32` values
72+
/// A 128-bit SIMD vector with four elements of type `i32`.
7373
pub type i32x4 = Simd<i32, 4>;
7474

75-
/// Vector of eight `i32` values
75+
/// A 256-bit SIMD vector with eight elements of type `i32`.
7676
pub type i32x8 = Simd<i32, 8>;
7777

78-
/// Vector of 16 `i32` values
78+
/// A 512-bit SIMD vector with 16 elements of type `i32`.
7979
pub type i32x16 = Simd<i32, 16>;
8080

81-
/// Vector of two `i64` values
81+
/// A 128-bit SIMD vector with two elements of type `i64`.
8282
pub type i64x2 = Simd<i64, 2>;
8383

84-
/// Vector of four `i64` values
84+
/// A 256-bit SIMD vector with four elements of type `i64`.
8585
pub type i64x4 = Simd<i64, 4>;
8686

87-
/// Vector of eight `i64` values
87+
/// A 512-bit SIMD vector with eight elements of type `i64`.
8888
pub type i64x8 = Simd<i64, 8>;
8989

90-
/// Vector of four `i8` values
90+
/// A 32-bit SIMD vector with four elements of type `i8`.
9191
pub type i8x4 = Simd<i8, 4>;
9292

93-
/// Vector of eight `i8` values
93+
/// A 64-bit SIMD vector with eight elements of type `i8`.
9494
pub type i8x8 = Simd<i8, 8>;
9595

96-
/// Vector of 16 `i8` values
96+
/// A 128-bit SIMD vector with 16 elements of type `i8`.
9797
pub type i8x16 = Simd<i8, 16>;
9898

99-
/// Vector of 32 `i8` values
99+
/// A 256-bit SIMD vector with 32 elements of type `i8`.
100100
pub type i8x32 = Simd<i8, 32>;
101101

102-
/// Vector of 64 `i8` values
102+
/// A 512-bit SIMD vector with 64 elements of type `i8`.
103103
pub type i8x64 = Simd<i8, 64>;

crates/core_simd/src/vector/uint.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,62 @@
22

33
use crate::simd::Simd;
44

5-
/// Vector of two `usize` values
5+
/// A SIMD vector with two elements of type `usize`.
66
pub type usizex2 = Simd<usize, 2>;
77

8-
/// Vector of four `usize` values
8+
/// A SIMD vector with four elements of type `usize`.
99
pub type usizex4 = Simd<usize, 4>;
1010

11-
/// Vector of eight `usize` values
11+
/// A SIMD vector with eight elements of type `usize`.
1212
pub type usizex8 = Simd<usize, 8>;
1313

14-
/// Vector of two `u16` values
14+
/// A 32-bit SIMD vector with two elements of type `u16`.
1515
pub type u16x2 = Simd<u16, 2>;
1616

17-
/// Vector of four `u16` values
17+
/// A 64-bit SIMD vector with four elements of type `u16`.
1818
pub type u16x4 = Simd<u16, 4>;
1919

20-
/// Vector of eight `u16` values
20+
/// A 128-bit SIMD vector with eight elements of type `u16`.
2121
pub type u16x8 = Simd<u16, 8>;
2222

23-
/// Vector of 16 `u16` values
23+
/// A 256-bit SIMD vector with 16 elements of type `u16`.
2424
pub type u16x16 = Simd<u16, 16>;
2525

26-
/// Vector of 32 `u16` values
26+
/// A 512-bit SIMD vector with 32 elements of type `u16`.
2727
pub type u16x32 = Simd<u16, 32>;
2828

29-
/// Vector of two `u32` values
29+
/// A 64-bit SIMD vector with two elements of type `u32`.
3030
pub type u32x2 = Simd<u32, 2>;
3131

32-
/// Vector of four `u32` values
32+
/// A 128-bit SIMD vector with four elements of type `u32`.
3333
pub type u32x4 = Simd<u32, 4>;
3434

35-
/// Vector of eight `u32` values
35+
/// A 256-bit SIMD vector with eight elements of type `u32`.
3636
pub type u32x8 = Simd<u32, 8>;
3737

38-
/// Vector of 16 `u32` values
38+
/// A 512-bit SIMD vector with 16 elements of type `u32`.
3939
pub type u32x16 = Simd<u32, 16>;
4040

41-
/// Vector of two `u64` values
41+
/// A 128-bit SIMD vector with two elements of type `u64`.
4242
pub type u64x2 = Simd<u64, 2>;
4343

44-
/// Vector of four `u64` values
44+
/// A 256-bit SIMD vector with four elements of type `u64`.
4545
pub type u64x4 = Simd<u64, 4>;
4646

47-
/// Vector of eight `u64` values
47+
/// A 512-bit SIMD vector with eight elements of type `u64`.
4848
pub type u64x8 = Simd<u64, 8>;
4949

50-
/// Vector of four `u8` values
50+
/// A 32-bit SIMD vector with four elements of type `u8`.
5151
pub type u8x4 = Simd<u8, 4>;
5252

53-
/// Vector of eight `u8` values
53+
/// A 64-bit SIMD vector with eight elements of type `u8`.
5454
pub type u8x8 = Simd<u8, 8>;
5555

56-
/// Vector of 16 `u8` values
56+
/// A 128-bit SIMD vector with 16 elements of type `u8`.
5757
pub type u8x16 = Simd<u8, 16>;
5858

59-
/// Vector of 32 `u8` values
59+
/// A 256-bit SIMD vector with 32 elements of type `u8`.
6060
pub type u8x32 = Simd<u8, 32>;
6161

62-
/// Vector of 64 `u8` values
62+
/// A 512-bit SIMD vector with 64 elements of type `u8`.
6363
pub type u8x64 = Simd<u8, 64>;

0 commit comments

Comments
 (0)