xref: /aosp_15_r20/external/pytorch/c10/core/alignment.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <cstddef>
4 
5 namespace c10 {
6 
7 #ifdef C10_MOBILE
8 // Use 16-byte alignment on mobile
9 // - ARM NEON AArch32 and AArch64
10 // - x86[-64] < AVX
11 constexpr size_t gAlignment = 16;
12 #else
13 // Use 64-byte alignment should be enough for computation up to AVX512.
14 constexpr size_t gAlignment = 64;
15 #endif
16 
17 constexpr size_t gPagesize = 4096;
18 // since the default thp pagesize is 2MB, enable thp only
19 // for buffers of size 2MB or larger to avoid memory bloating
20 constexpr size_t gAlloc_threshold_thp = static_cast<size_t>(2) * 1024 * 1024;
21 } // namespace c10
22