New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raw debug allocators to not return malloc alignment #74336
Comments
The debug raw allocator do not return the same alignment as malloc. See _PyMem_DebugRawAlloc: The line adds 2 * sizeof(size_t) to the pointer returned by malloc. |
How it cause problem? |
x32 is a strange platform :-( Does numpy support it? I'm not sure that Python works on such platform. I suggest to hardcode 16 or 32 bytes in _PyMem_DebugRawAlloc instead of relying on sizeof(size_t). pymalloc aligns memory allocations to 8 bytes if I recall correctly.
numpy uses SIMD instructions which require strict memory alignement. Note: There was also an issue bpo-18835 to "Add aligned memory variants to the suite of PyMem functions/macros", but it was rejected. |
Is this issue related to this numpy issue: "ENH: add support for python3.6 memory tracing"? |
no in numpy it is just a case of using the wrong allocator in a certain spot, an issue that can be fixed in numpy. Alignment isn't very important for SIMD any more but there are architectures where alignment is still mandatory so numpy is sprinkled with asserts checking alignment which triggered on x32. |
Maybe we can use Py_MAX (sizeof (size_t), 8) for SST? If I recall correctly, pymalloc uses 8 bytes for the alignement. Somewhere I read that malloc uses sizeof (double), the largest C type. Well, what do you suggest Julian? Do you want to write a PR? |
The largest type is usually the long double. Its alignment ranges from 4 bytes (i386) to 16 bytes (sparc). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: