3 ms·
Pretty cool, I like these kinds of articles. > An interesting feature where coefficients were pre-aligned to mod-8 widths to presumably allow for SIMD optimisa
by rdtsc 11y ago
Pretty cool, I like these kinds of articles.
> An interesting feature where coefficients were pre-aligned to mod-8 widths to presumably allow for SIMD optimisations
I have seen protocols implemented in such a way that when described on paper, they look convoluted, especially how they specify alginment "this will have this much padding, this one will be aligned on this boundary. Little endian encoding for integer values...".
However I quickly realized they basically picked a particular memory layout in a C struct generated on x86-64 architecture, by a particular compler (gcc 4), and particular OS (Linux). I imagine at some point someone implemented it like that, then they went back and wrote into a standard. It would have been nice to at least mention that in the docs footnote ("Encode these as C structs on this combination of arch/compiler/os and cast binary blobs to the struct to serialize/deserialize data in this format)
- greglindahl 11y agoPlatforms (arch+os) usually have ABI documents that all compilers follow. If you get far enough away from C things might vary, but not C. With C++ on x86, there's a fair amount of effort to try to be compatible, even though the ABI changes pretty quickly. Elsewise, things can vary quite a lot.
- deleted 11y ago[deleted]
- JoshTriplett 11y ago> I imagine at some point someone implemented it like that, then they went back and wrote into a standard. It would have been nice to at least mention that in the docs footnote ("Encode these as C structs on this combination of arch/compiler/os and cast binary blobs to the struct to serialize/deserialize data in this format) That footnote could cause multiple problems. Someone might just use that C struct and expect the layout to match, which would introduce portability problems (such as if using a different target OS, as Windows and Linux have different struct layout rules). Or, conversely, someone might see that line in a proposed standard and reject it as non-portable, whereas a precise description of memory layout would not come across as such. (In particular, the memory layout of structs by GCC on x86-64 Linux matches the memory layout of structs by any compatible compiler targeting several different 64-bit architectures on several POSIXy platforms.)
- rdtsc 11y ago> Or, conversely, someone might see that line in a proposed standard and reject it as non-portable, whereas a precise description of memory layout would not come across as such. Yap that makes sense, I din't think of it that way first but that probably explains it.