PDL::Internals - description of the current internals
This document explains various aspects of the current implementation of PDL. If you just want to use PDL for something, you definitely do not need to read this. Even if you want to interface your C routines to PDL or create new PDL::PP functions, you do not need to read this (though it may be informative). This document is primarily intended for people interested in debugging or changing the internals of PDL. To read this, a good understanding of the C language and programming and data structures in general is required, as well as some perl understanding. If you read through this document and understand all of it and are able to point what any part of this document refers to in the PDL core sources and additionally struggle to understand PDL::PP, you will be awarded the title ``PDL Guru'' (of course, the current version of this document is so incomplete that this is not yet the case).
Warning: If it seems that this document has gotten out of date, please inform the PerlDL developers email list (address in the README file) about it. This may well happen.
Currently, a pdl data object is a hash ref which contains the element
PDL, which is a pointer to a pdl structure, as well as some other fields.
The file Core.pm
uses some of these fields and the file pdlhash.c
converts
these to C when necessary.
The pdl struct is defined in pdl.h
and the meanings of the fields
are
$a = pdl 2,3,4; $b = pdl 4,5,6; $c = $a + $b; # Note: no dataflow (not asked for)
here, the trans field in $c
contains a pointer to a transformation.
Only when $a
or $b
is changed, is the transformation destroyed and
the field cleared. To see whether data is flowing, check the flags
field of the trans struct.
pdlapi.c
for the code handling this.
Also, slices.pd
defines some things with / for this.
threadids[0]-1
, the thread dimensions with id 0 extend from
threadids[0]
to threadids[1]-1
and the thread dimensions with the last id
extend from threadids[nthreadids-1]
to threadids[nthreadids]-1
.
For example, if a pdl has dimensions (2,3,4,5)
(= 120 elements)
and nthreadids==2
and threadids={1,3,4}
, there is one ``real'' dimensions
with size 2, two dimensions with threadid 0 (3 and 4) and the dimensions
with size 5 has threadid 1.
Each transformation has a virtual table which contains various information about that transformation. Usually transformations are generated with PDL::PP so it's better to see that documentation.
Currently, not much is freed, especially when dataflow is done. This is bound to change pretty soon.
The file pdlthread.c
handles most of the threading matters.
The threading is encapsulated in the structure pdlthread.h
.
Copyright(C)
1997 Tuomas J. Lukka (lukka@fas.harvard.edu)
Redistribution in the same form is allowed but reprinting requires
a permission from the author.