Discussion:
[Pdl-porters] More verbose thread mismatch error message
Craig DeForest
2013-12-05 08:35:13 UTC
Permalink
In the core-cleanup branch I just pushed a mod that prints a more helpful error message if thread dim reconciliation fails. It's a little old-skool but seems to work okay. Chris, would this have helped you debug the last issue?



pdl> ########## The simplest case (two scalar operators, 1 thread dim)
pdl> $a = sequence(5)
pdl> p $a+pdl(2,3)
PDL: PDL::Ops::plus(a,b,c): Parameter 'b':
Mismatched implicit thread dimension 0: size 5 vs. 2
There are 3 PDLs in the expression; 1 thread dim.
PDL IN EXPR. THREAD DIMS
# 0 (normal): 5
# 1 (normal): 2
# 2 (null)

.. at /usr/local/src/PDL/blib/lib/PDL/Complex.pm line 1260, <FOO> line 173.


pdl> ########## An example with index()
pdl> $a = sequence(5,3);
pdl> $b = sequence(2);
pdl> print $a->index($b);
Stringizing problem: PDL: PDL::Slices::index(a,ind,c): Parameter 'ind':
Mismatched implicit thread dimension 0: size 3 vs. 2
There are 3 PDLs in the expression; 2 thread dims.
PDL IN EXPR. ACTIVE DIMS | THREAD DIMS
# 0 (normal): 5 | 3 2
# 1 (normal): | 2
# 2 (null)

... eval {...} called at Basic/Core/Core.pm.PL (i.e. PDL::Core.pm) line 2957



pdl> ########## Chris's recent example with indadd()
pdl> $N = sequence(5);
pdl> $sum = zeroes(5,2);
pdl> $ind = floor(4*random(5))->long;
pdl> indadd $N(:,*2), $ind(:,*2), $sum;
PDL: PDL::Primitive::indadd(a,ind,sum): Parameter 'sum':
Mismatched implicit thread dimension 0: size 5 vs. 2
There are 3 PDLs in the expression; 2 thread dims.
PDL IN EXPR. ACTIVE DIMS | THREAD DIMS
# 0 (normal): | 5 2
# 1 (normal): | 5 2
# 2 (normal): 5 | 2

.. at (eval 109) line 4, <FOO> line 173.
Craig DeForest
2013-12-05 08:50:59 UTC
Permalink
(whoops: in the second example, that should be "sequence(5,3,2)" -- cut-and-pasted the wrong line.)
Post by Craig DeForest
In the core-cleanup branch I just pushed a mod that prints a more helpful error message if thread dim reconciliation fails. It's a little old-skool but seems to work okay. Chris, would this have helped you debug the last issue?
pdl> ########## The simplest case (two scalar operators, 1 thread dim)
pdl> $a = sequence(5)
pdl> p $a+pdl(2,3)
Mismatched implicit thread dimension 0: size 5 vs. 2
There are 3 PDLs in the expression; 1 thread dim.
PDL IN EXPR. THREAD DIMS
# 0 (normal): 5
# 1 (normal): 2
# 2 (null)
.. at /usr/local/src/PDL/blib/lib/PDL/Complex.pm line 1260, <FOO> line 173.
pdl> ########## An example with index()
pdl> $a = sequence(5,3);
pdl> $b = sequence(2);
pdl> print $a->index($b);
Mismatched implicit thread dimension 0: size 3 vs. 2
There are 3 PDLs in the expression; 2 thread dims.
PDL IN EXPR. ACTIVE DIMS | THREAD DIMS
# 0 (normal): 5 | 3 2
# 1 (normal): | 2
# 2 (null)
... eval {...} called at Basic/Core/Core.pm.PL (i.e. PDL::Core.pm) line 2957
pdl> ########## Chris's recent example with indadd()
pdl> $N = sequence(5);
pdl> $sum = zeroes(5,2);
pdl> $ind = floor(4*random(5))->long;
pdl> indadd $N(:,*2), $ind(:,*2), $sum;
Mismatched implicit thread dimension 0: size 5 vs. 2
There are 3 PDLs in the expression; 2 thread dims.
PDL IN EXPR. ACTIVE DIMS | THREAD DIMS
# 0 (normal): | 5 2
# 1 (normal): | 5 2
# 2 (normal): 5 | 2
.. at (eval 109) line 4, <FOO> line 173.
Chris Marshall
2013-12-05 11:57:43 UTC
Permalink
Post by Craig DeForest
In the core-cleanup branch I just pushed a mod that prints a more
helpful error message if thread dim reconciliation fails. It's a little
old-skool but seems to work okay.
Chris, would this have helped you debug the last issue?
Yes, that would have immediately told me whatwas the
problem---I could try different options as well.

Nice and thanks!
Chris
Post by Craig DeForest
pdl> ########## Chris's recent example with indadd()
pdl> $N = sequence(5);
pdl> $sum = zeroes(5,2);
pdl> $ind = floor(4*random(5))->long;
pdl> indadd $N(:,*2), $ind(:,*2), $sum;
Mismatched implicit thread dimension 0: size 5 vs. 2
There are 3 PDLs in the expression; 2 thread dims.
PDL IN EXPR. ACTIVE DIMS | THREAD DIMS
# 0 (normal): | 5 2
# 1 (normal): | 5 2
# 2 (normal): 5 | 2
.. at (eval 109) line 4, <FOO> line 173.
Loading...