pytorch/cmake/public
Yu, Guangye c9eabadc5e Suppress std::hardware_destructive_interference_size warning on GCC 13+ (#166297)
# Motivation
In https://github.com/pytorch/pytorch/pull/145591, `std::hardware_destructive_interference_size` was introduced in CUDACachingAllocator. Later, https://github.com/pytorch/pytorch/pull/160067 moved it to `c10/core/alignment.h` for code reuse.
However, on **GCC 13+** using `std::hardware_destructive_interference_size` triggers the following warning:
```bash
warning: use of ‘std::hardware_destructive_interference_size’ [-Winterference-size]
/home/pt-gpu/4T-4652/guangyey/stock-pytorch/aten/src/ATen/core/CachingHostAllocator.h:42:16: note: its value can vary between compiler versions or with different ‘-mtune’ or ‘-mcpu’ flags
/home/pt-gpu/4T-4652/guangyey/stock-pytorch/aten/src/ATen/core/CachingHostAllocator.h:42:16: note: if this use is part of a public ABI, change it to instead use a constant variable you define
/home/pt-gpu/4T-4652/guangyey/stock-pytorch/aten/src/ATen/core/CachingHostAllocator.h:42:16: note: the default value for the current CPU tuning is 64 bytes
/home/pt-gpu/4T-4652/guangyey/stock-pytorch/aten/src/ATen/core/CachingHostAllocator.h:42:16: note: you can stabilize this value with ‘--param hardware_destructive_interference_size=64’, or disable this warning with ‘-Wno-interference-size’
```

# Solution
- Solution 1: Replace `c10::hardware_destructive_interference_size` with a constant 64.
```cpp
constexpr std::size_t hardware_destructive_interference_size = 64;
```

- Solution 2: adding `-Wno-interference-size’ to 8d4e48831e/cmake/public/utils.cmake (L386) to suppress the warning.

# Additional Context
The current implementation uses the second approach. If the reviewers prefer the first approach, I am happy to update it accordingly.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/166297
Approved by: https://github.com/ezyang
2025-10-29 02:57:46 +00:00
..
ComputeLibrary.cmake Add SVE implementation of embedding_lookup_idx (#133995) 2024-10-15 18:52:44 +00:00
cuda.cmake [CD] Add cuda 13.0 libtorch builds, remove CUDA 12.9 builds (#161916) 2025-09-05 07:47:54 +00:00
gflags.cmake
glog.cmake
LoadHIP.cmake [ROCm][Windows] Fix LoadHIP handling of environment variable paths on Windows. (#159080) 2025-08-12 00:18:19 +00:00
mkl.cmake Convert MKL symbols from global to local (#122284) 2024-04-12 15:36:47 +00:00
mkldnn.cmake
protobuf.cmake
utils.cmake Suppress std::hardware_destructive_interference_size warning on GCC 13+ (#166297) 2025-10-29 02:57:46 +00:00
xpu.cmake [CMake] Move xpu flag to xpu.cmake (#158542) 2025-07-21 17:19:59 +00:00