Skip to content

Commit 2742430

Browse files
authored
Improve docs for SIMD level tokens (linebender#222)
As requested in linebender#216 (review)
1 parent a6ed0e4 commit 2742430

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

fearless_simd/src/lib.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,10 @@ impl Level {
414414
///
415415
/// This method should be preferred over matching against the `Neon` variant of self,
416416
/// because if Fearless SIMD gets support for an instruction set which is a superset of Neon,
417-
/// this method will return a value even if that "better" instruction set is available.
417+
/// this method will return the Neon token even if that "better" instruction set is available.
418418
///
419+
/// This can be used in combination with the [kernel] macro to safely access level-specific
420+
/// SIMD intrinsics.
419421
#[cfg(target_arch = "aarch64")]
420422
#[inline]
421423
pub fn as_neon(self) -> Option<Neon> {
@@ -433,8 +435,10 @@ impl Level {
433435
///
434436
/// This method should be preferred over matching against the `WasmSimd128` variant of self,
435437
/// because if Fearless SIMD gets support for an instruction set which is a superset of SIMD 128,
436-
/// this method will return a value even if that "better" instruction set is available.
438+
/// this method will return the SIMD 128 token even if that "better" instruction set is available.
437439
///
440+
/// This can be used in combination with the [kernel] macro to safely access level-specific
441+
/// SIMD intrinsics.
438442
#[cfg(all(target_arch = "wasm32", target_feature = "simd128"))]
439443
#[inline]
440444
pub fn as_wasm_simd128(self) -> Option<WasmSimd128> {
@@ -448,12 +452,17 @@ impl Level {
448452
}
449453
}
450454

451-
/// If this is a proof that SSE4.2 (or better) is available, access that instruction set.
455+
/// If this is a proof that x86-64-v2 feature set (or better) is available, access that
456+
/// instruction set.
457+
///
458+
/// See [`Sse4_2::new_unchecked`] for the exact list of CPU features this token enables.
452459
///
453460
/// This method should be preferred over matching against the `Sse4_2` variant of self,
454-
/// because if Fearless SIMD gets support for an instruction set which is a superset of SSE4.2,
455-
/// this method will return a value even if that "better" instruction set is available.
461+
/// because if the CPU supports a superset of SSE4.2 (e.g. AVX2 or AVX-512),
462+
/// this method will return the SSE4.2 token even if that "better" instruction set is available.
456463
///
464+
/// This can be used in combination with the [kernel] macro to safely access level-specific
465+
/// SIMD intrinsics.
457466
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
458467
#[inline]
459468
pub fn as_sse4_2(self) -> Option<Sse4_2> {
@@ -485,10 +494,14 @@ impl Level {
485494
/// If this is a proof that the x86-64-v3 feature set (or better) is available, access that
486495
/// instruction set.
487496
///
488-
/// This method should be preferred over matching against the `AVX2` variant of self,
489-
/// because if Fearless SIMD gets support for an instruction set which is a superset of AVX2,
490-
/// this method will return a value even if that "better" instruction set is available.
497+
/// See [`Avx2::new_unchecked`] for the exact list of CPU features this token enables.
498+
///
499+
/// This method should be preferred over matching against the `Avx2` variant of self,
500+
/// because if the CPU supports a superset of AVX2 (e.g. AVX-512),
501+
/// this method will return the AVX2 token even if that "better" instruction set is available.
491502
///
503+
/// This can be used in combination with the [kernel] macro to safely access level-specific
504+
/// SIMD intrinsics.
492505
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
493506
#[inline]
494507
pub fn as_avx2(self) -> Option<Avx2> {

0 commit comments

Comments
 (0)