You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce ET_ALIGN_ALLOC for portable aligned alloc (pytorch#10660)
Summary:
Pull Request resolved: pytorch#10660
Issue with aligned buffers: P1800967583
The alignment requested is 16, and std::max_align_t is also 16. This means we do not need to pad the size to meet any alignment.
However, the buffer we get from malloc is aligned to 8, not 16. When we try to align the buffer, we overflow and error out.
Seems like malloc is not guaranteed to return 8 or 16 byte-aligned buffers, so also a bit hard to test definitively. So far we've only seen this when the buffer size is small (size 2, 4)
```
The malloc(), calloc(), realloc(), and reallocarray() functions
return a pointer to the allocated memory, which is suitably
aligned for any type that fits into the requested size or less.
```
Use std::aligned_alloc (C++17) to ensure buffer is aligned.
Reviewed By: larryliu0820, mcr229
Differential Revision: D74041198
0 commit comments