[clang] [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (PR #89446)
Ulrich Weigand via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 22 07:02:11 PDT 2024
uweigand wrote:
> > For SystemZ the correct value is 256.
>
> Thanks! Double-checking: for both constructive and destructive?
Yes, for both. Every SystemZ model (supported by GCC/LLVM) has a L1 cache line size of 256 bytes.
> > In general I agree it makes sense to look at the GCC implementation as a source of reasonable values. Also, I think there probably should be no generic default value at all - it there is no platform-specific value known, it seems better to not define those values rather than define them to some incorrect value ...
>
> On the one hand, I agree. But then libc++ will still have to pick default values to expose (these are `constexpr size_t` variables in libc++ rather than macros or `std::optional` values), so that just moves the problem elsewhere. Also, as best I can tell, that doesn't seem to be how GCC behaves (at least, from trying various GCC flavors on Compiler Explorer).
Looks like GCC's libstdc++ will simply not provide those variables either if GCC does not know those values for the current target:
```
#ifdef __cpp_lib_hardware_interference_size // C++ >= 17 && defined(gcc_dest_sz)
inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE;
inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE;
#endif // __cpp_lib_hardware_interference_size
```
https://github.com/llvm/llvm-project/pull/89446
More information about the cfe-commits
mailing list