Skip to content

Standardize documentation for SIMD vector and mask types #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sstangl
Copy link
Contributor

@sstangl sstangl commented Apr 3, 2022

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.
  3. 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.

Copy link
Member

@calebzulawski calebzulawski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like an improvement to me, thanks!

@calebzulawski
Copy link
Member

It's worth noting that the masks might not actually be the same size as their corresponding vector on some targets, but I'm not sure that the old comments were indicative of that either.

@workingjubilee
Copy link
Member

workingjubilee commented Apr 3, 2022

Correct, the Mask type is intended to denote a type that "matches with" a given vector element size and count. The exact repr that is used to store Masks is something the hardware decides... it's only "no less than 1 bit per element and no more than the size of the vector type it masks".

@programmerjake
Copy link
Member

Correct, the Mask type is intended to denote a type that "matches with" a given vector element size and count. The exact repr that is used to store Masks is something the hardware decides... it's only "no less than 1 bit per element and no more than the size of the vector type it masks".

there isn't an upper limit on mask sizes, some architecture could say all masks have 64-bit elements, and it would still work correctly.

@sstangl
Copy link
Contributor Author

sstangl commented Apr 3, 2022

OK, updated with more accurate wording, thanks everyone. I had to be a little terse, because rustdoc's search feature has a fairly low maximum column count -- exceeding that makes all entries look roughly identical, with trailing ellipses.

I also added the line "Masks represent boolean inclusion/exclusion on a per-lane basis." to the Mask documentation.

@sstangl sstangl requested a review from programmerjake April 3, 2022 22:24
Copy link
Member

@programmerjake programmerjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@workingjubilee workingjubilee merged commit c2fbead into rust-lang:master Apr 3, 2022
@sstangl sstangl deleted the sstangl/2022-04-03/minor-doc-cleanup branch April 3, 2022 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants