in reply to Re^2: Which pdl orientation saves memory
in thread Which pdl orientation saves memory
The important thing is which dimension will you be iterating with the greatest frequency?
PDL applies operations to whole piddles at a time. If you arrange your matrix so that the longest dimension is its first (leftmost) dimension, then the loop code at the assembler level is likely to be able to use auto-incrementing addressing modes, because the fastest changing dimension will be consecutive addresses. This will be faster, often much faster than if it has to add a large offset to calculate the next address each time. It will also likely benefit from greater cache coherency which again can have a significant impact upon performance.
So if all else is equal to your algorithm, make the first (leftmost) dimension of your piddle the largest. See also the documentation of PDL implicit and explicit 'threading'. It goes right over my head, but seems to be applicable to this discussion.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Which pdl orientation saves memory
by dogz007 (Scribe) on Aug 22, 2007 at 16:42 UTC | |
by BrowserUk (Patriarch) on Aug 22, 2007 at 17:03 UTC |