3 ms·
If the uint64s are aligned, wouldn't it be better to use alignas (to make the buffer aligned as soon as it's allocated)? As far as I see that way you get a long
by nsajko 6y ago
If the uint64s are aligned, wouldn't it be better to use alignas (to make the buffer aligned as soon as it's allocated)? As far as I see that way you get a longer buffer only when necessary (you never waste memory), plus you could get autovectorized code if the compiler decides that makes sense.
- asdfasgasdgasdg 6y agoThe buffer is allocated in general library code, unfortunately. It's not something I can easily adjust.
- fefe23 6y agoIf you mean malloc() by that: malloc will return aligned memory so that you can store all data types, i.e. it is 64-bit aligned at least (so you can store double) but probably has even higher granularity. It's the downside of malloc not knowing the type you want and returning void*. It has to assume the worst alignment requirements. Which actually happen to be 128 bytes for SSE instructions.
- midjji 6y agoIs this guaranteed by the standard? worst seems platform dependent, does that mean it will vary with platform? what about x86 vs amd64? could it ever be more than 128 bytes?
- asdfasgasdgasdg 6y agoI don't mean malloc. I mean that the memory is allocated inside the database sdk we are using.