[issue30150] raw debug allocators to not return malloc alignment

2017-05-24 Thread Julian Taylor

Julian Taylor added the comment:

The largest type is usually the long double. Its alignment ranges from 4 bytes 
(i386) to 16 bytes (sparc).
So Py_MAX (sizeof (size_t), 8) should indeed do it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30150] raw debug allocators to not return malloc alignment

2017-05-23 Thread STINNER Victor

STINNER Victor added the comment:

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?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30150] raw debug allocators to not return malloc alignment

2017-05-23 Thread Julian Taylor

Julian Taylor added the comment:

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.
But it is also minor bug/documentation issue in Python itself.

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.
It is a very minor issue as to my knowledge none of the platforms with 
alignment requirement has the properties of x32 and x32 doesn't actually care 
about alignment either.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30150] raw debug allocators to not return malloc alignment

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

Is this issue related to this numpy issue: "ENH: add support for python3.6 
memory tracing"?
https://github.com/numpy/numpy/pull/8885

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30150] raw debug allocators to not return malloc alignment

2017-04-25 Thread STINNER Victor

STINNER Victor added the comment:

> On for example x32 malloc returns 16 byte aligned memory but size_t is 4 
> bytes.

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.


> How it cause problem?

numpy uses SIMD instructions which require strict memory alignement.

Note: There was also an issue #18835 to "Add aligned memory variants to the 
suite of PyMem functions/macros", but it was rejected.

--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30150] raw debug allocators to not return malloc alignment

2017-04-25 Thread INADA Naoki

INADA Naoki added the comment:

How it cause problem?
I think you should use `malloc()` instead of `PyMem_Malloc()` or other Python 
memory allocator when you need strict `malloc()` alignment.

--
nosy: +inada.naoki

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30150] raw debug allocators to not return malloc alignment

2017-04-24 Thread Mattia Rizzolo

Changes by Mattia Rizzolo :


--
nosy: +mapreri

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30150] raw debug allocators to not return malloc alignment

2017-04-23 Thread Julian Taylor

New submission from Julian Taylor:

The debug raw allocator do not return the same alignment as malloc. See  
_PyMem_DebugRawAlloc:
https://github.com/python/cpython/blob/master/Objects/obmalloc.c#L1873

The line
return p + 2*SST

adds 2 * sizeof(size_t) to the pointer returned by malloc.
On for example x32 malloc returns 16 byte aligned memory but size_t is 4 bytes.
This makes all memory returned by the debug allocators not aligned the what the 
system assumes on such platforms.

--
components: Interpreter Core
messages: 292187
nosy: jtaylor
priority: normal
severity: normal
status: open
title: raw debug allocators to not return malloc alignment
versions: Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com