[PATCH] c++: implement C++17 hardware interference size
Matthias Kretz
m.kretz@gsi.de
Fri Jul 16 19:26:11 GMT 2021
On Friday, 16 July 2021 18:54:30 CEST Jonathan Wakely wrote:
> On Fri, 16 Jul 2021 at 16:33, Jason Merrill wrote:
> > Adjusting them based on tuning would certainly simplify a significant use
> > case, perhaps the only reasonable use. Cases more concerned with ABI
> > stability probably shouldn't use them at all. And that would mean not
> > needing to worry about the impossible task of finding the right values for
> > an entire architecture.
>
> But it would be quite a significant change in behaviour if -mtune
> started affecting ABI, wouldn't it?
For existing code -mtune still doesn't affect ABI. The users who write
struct keep_apart {
alignas(std::hardware_destructive_interference_size) std::atomic<int> cat;
alignas(std::hardware_destructive_interference_size) std::atomic<int> dog;
};
*want* to have different sizeof(keep_apart) depending on the CPU the code is
compiled for. I.e. they *ask* for getting their ABI broken. If they wanted to
specify the value themselves on the command line they'd written:
struct keep_apart {
alignas(SOME_MACRO) std::atomic<int> cat;
alignas(SOME_MACRO) std::atomic<int> dog;
};
I would be very disappointed if std::hardware_destructive_interference_size
and std::hardware_constructive_interference_size turn into a glorified macro.
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
std::experimental::simd https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────
More information about the Libstdc++
mailing list