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
I've had a quick try at removing it, and the indirection from this scheme seems to cause something like a 20% performance loss, for a toy example doing memoryview slicing in a loop.
My view is that:
__pyx_atomic_int should already be aligned appropriately within the __pyx_memoryview struct (because I'm pretty sure the C compiler guarantees this).
The allocated __pyx_memoryview should be aligned appropriately because
malloc guarantees this (by allocating to the maximum alignment the system requires)
Although Python itself will be responsible for the positioning of the struct within allocated memory,
it's pretty much got to be right, otherwise it'd break a lot of code (especially on platforms that require alignment)
Therefore, I think this scheme is an unnecessary pessimization. I've tried putting in an assert to check the alignment and can't get it to trip locally (which doesn't prove it's right, but suggests it might be at least on some platforms).
Am I missing anything?
The text was updated successfully, but these errors were encountered:
Describe your issue
We have a slightly complicated scheme to make sure memoryview atomics are aligned:
cython/Cython/Utility/MemoryView.pyx
Lines 353 to 356 in 90e9f6a
cython/Cython/Utility/MemoryView.pyx
Lines 386 to 387 in 90e9f6a
I've had a quick try at removing it, and the indirection from this scheme seems to cause something like a 20% performance loss, for a toy example doing memoryview slicing in a loop.
My view is that:
__pyx_atomic_int
should already be aligned appropriately within the__pyx_memoryview
struct (because I'm pretty sure the C compiler guarantees this).__pyx_memoryview
should be aligned appropriately becausemalloc
guarantees this (by allocating to the maximum alignment the system requires)it's pretty much got to be right, otherwise it'd break a lot of code (especially on platforms that require alignment)
Therefore, I think this scheme is an unnecessary pessimization. I've tried putting in an assert to check the alignment and can't get it to trip locally (which doesn't prove it's right, but suggests it might be at least on some platforms).
Am I missing anything?
The text was updated successfully, but these errors were encountered: