microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
10.06k stars 1.48k forks source link

<xmemory>: Consider updating the overalignment for large allocations #2215

Open CaseyCarter opened 2 years ago

CaseyCarter commented 2 years ago

In the _Allocate function (the backend used by std::allocator::allocate):

https://github.com/microsoft/STL/blob/d6f9987d7ec694b8599fe21e87e3653c36566223/stl/inc/xmemory#L219-L238

we have some magic to manually overalign "large" allocations:

https://github.com/microsoft/STL/blob/d6f9987d7ec694b8599fe21e87e3653c36566223/stl/inc/xmemory#L228-L230

with the goal of helping compilers to effectively autovectorize. The current value of _Big_allocation_alignment is 32:

https://github.com/microsoft/STL/blob/d6f9987d7ec694b8599fe21e87e3653c36566223/stl/inc/xmemory#L108

which is an excellent choice for SSE and AVX, but it appears that AVX512 would prefer 64-byte alignment. See the discussion in #2104. We should consider "bumping" the value of _Big_allocation_alignment in vNext to better accommodate future processors.


vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

AlexGuteniev commented 2 years ago

By the time vNext starts, need to check if something like AVX-1024 is on the roadmap.

CaseyCarter commented 2 years ago

By the time vNext starts, need to check if something like AVX-1024 is on the roadmap.

Clearly this will be a problem for future generations, not for us.