[Numpy-discussion] object array alignment issues
Fri Oct 16 07:02:03 CDT 2009
On Fri, Oct 16, 2009 at 8:53 PM, Pauli Virtanen <firstname.lastname@example.org> wrote:
> Fri, 16 Oct 2009 12:07:10 +0200, Francesc Alted wrote:
>> IMO, NumPy can be improved for unaligned data handling. For example,
>> Numexpr is using this small snippet:
>> from cpuinfo import cpu
>> if cpu.is_AMD() or cpu.is_Intel():
>> is_cpu_amd_intel = True
>> is_cpu_amd_intel = False
>> for detecting AMD/Intel architectures and allowing the code to avoid
>> memcpy() calls for the unaligned arrays.
>> The above code uses the excellent ``cpuinfo.py`` module from Pearu
>> Peterson, which is distributed under NumPy, so it should not be too
>> difficult to take advantage of this for avoiding unnecessary copies in
>> this scenario.
> I suppose this kind of check is easiest to do at compile-time, and
> defining a -DFORCE_ALIGNED? This wouldn't cause performance penalties for
> those architectures for which they are not necessary.
I wonder whether we could switch at runtime (import time) - it could
be useful for testing.
That being said, I agree that the cpu checks should be done at compile
time - we had quite a few problems with cpuinfo in the past with new
cpu/unhandled cpu, I think a compilation-based method is much more
robust (and simpler) here. There are things where C is just much
easier than python :)
More information about the NumPy-Discussion