On Mon, Sep 10, 2012 at 12:41 PM, Luis Mochan <[email protected]> wrote:
> I just wanted to be sure I understood what to expect from the
> different ways to share information between perl and pdl. I didn't
> find this information in the PDL-Book (yet) so I guess it should be
> included, maybe as a footnote such as 'note: upd_data doesn't work on
> slices'. As I understand, the $P macro from PDL::PP does work for
> slices. This surprised me, as $P yields contiguous memory locations,
> while slices may refer to non-contiguous data in the parent pdl, so I
> guess $P copies data back and forth.
> Regards,
> Luis

I'm actually not exactly sure how $P() works, but I do know that data
accesses in PDL::PP, i.e. "$my_piddle(n => 5, m => 3)", are translated
into direct array offset statements, ala "array[5 * off1 + 3]" (except
that the translation is much more complex than what I just wrote).
This means that data from slices *must* be copied to a temporary
buffer just before entering the threadloop. This also explains why you
might have seen discussion in the docs about affine slices, such as mv
and xchg, which basically end up changing the values of "off1" in the
example that I already gave. In other words, affine slices are slices
that do not need to copy the data into a temporary buffer.

At any rate, if a slice gets modified by PDL::PP code, there is
machinery to flow those changes both to the slice's parent and to any
of the slice's children. I had assumed that the data-flow machinery
behind the $P() macro access in PDL::PP was the same as the stuff
behind upd_data, just as you had, but clearly we were both wrong. This
smells like a bug to me and something worth investigating whenever
core diving happens.

David

-- 
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to