Document memory layout of vector types - #330
Conversation
|
Thanks! I like the tests. We might even enforce stronger layout guarantees later, since we do align 512-bit vectors to 512 bits on all platforms AFAIK. Doesn't have to happen as part of this PR though. It would also be nice to document that the layout of masks varies between platforms and shouldn't be relied upon. I don't recall if our vectors are repr(C) right now, we might want to make them if they aren't (and see if that alters the layout in any way). |
| //! It benefited from conversations with Luca Versari, though he is not responsible for any of the mistakes or bad decisions. | ||
| //! | ||
| //! [`pulp`]: https://crates.io/crates/pulp | ||
| //! [libm]: https://crates.io/crates/libm |
There was a problem hiding this comment.
Welcome!
For awareness, our docs are intended to be built with all features enabled. If you look at https://docs.rs/fearless_simd/latest/fearless_simd/#feature-flags for example, you will see that this link is resolved.
In the past, we've fixed this with a conditional compilation approach:
https://docs.rs/color/latest/src/color/lib.rs.html#75
I'm not going to die on this hill though.
If you are going to apply this fix as-is, you need to remove the duplicate link in README.md (once you've regenned it)
There was a problem hiding this comment.
Aah, I see. In that case, since it was a random unrelated change to this PR anyway, I'll just drop out that doc change. I'll send a followup that fixes this with a conditional, and does it properly with cargo-rdme. Thanks for the pointers!
a14bea4 to
337aa26
Compare
|
I had a brain fart when I first wrote the PR, and got my bits and bytes confused. After looking again: yes, the vector types are all I've corrected the doc description, and changed the alignment tests to check that I was going to change the docs of the mask types as well, but it turns out they already document that the layout is opaque and not guaranteed:
|
Alignment larger than the size would be wasteful: if the vectors laid out sequentially in memory, in an array, half the memory would just be wasted on padding. So I'm comfortable making a call that this is never going to happen. I've checked and no SIMD architecture or ABI does this today. |
337aa26 to
4ffdb84
Compare
|
Sounds good. Updated the docs to say that the alignment is exactly size_of bytes, and updated the tests to reflect that. |
Fixes linebender#327 Signed-off-by: David Anderson <dave@natulte.net>
…inebender#333) Checked that `cargo doc` with and without the libm feature builds without warnings. The README.md didn't change when regenerated by `cargo rdme`, which surprised me slightly. But looking at the readme, it has a block of explicit links outside of the generated section that fixes up libm references already, so no change needed there. (extracted from linebender#330 after feedback from @DJMcNab, thank you!) Signed-off-by: David Anderson <dave@natulte.net>
4ffdb84 to
bbf30ce
Compare
Fixes #327