Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make code generation for multiple types happen in complexity order.
Related to SF.net patch #84 from Debian (reproducibile-build.patch)
but instead of sorting the keys of PDL datatypes lexigraphically,
using PDL::Types::typesrtkeys() sorts them in order of complexity.
Satisfies the goals of reproducible builds but does it in a way
that makes more sense for PDL in this case.
  • Loading branch information
d-lamb committed Sep 13, 2016
1 parent eabda05 commit dcf3a23
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Basic/Core/Dev.pm
Expand Up @@ -311,7 +311,7 @@ sub flushgeneric { # Construct the generic code switch

print $indent,"switch ($loopvar) {\n\n";

for $case (keys %PDL_DATATYPES) {
for $case (PDL::Types::typesrtkeys()){

$type = $PDL_DATATYPES{$case};

Expand Down
7 changes: 4 additions & 3 deletions Basic/Core/pdlconv.c.PL
Expand Up @@ -9,6 +9,7 @@ use File::Basename qw(&basename &dirname);

require 'Dev.pm'; PDL::Core::Dev->import;
use vars qw( %PDL_DATATYPES );
require 'Types.pm'; #for typesrtkeys

# This forces PL files to create target in same directory as PL file.
# This is so that make depend always knows where to find PL derivatives.
Expand Down Expand Up @@ -73,7 +74,7 @@ void pdl_${name}(pdl *a) {

##### Generate code for each data type #####

for my $in ( keys %PDL_DATATYPES ) {
for my $in ( PDL::Types::typesrtkeys() ) {

my $intype = $PDL_DATATYPES{$in};
print OUT <<"!WITH!SUBS!";
Expand Down Expand Up @@ -191,7 +192,7 @@ void pdl_converttype( pdl** aa, int targtype, Logical changePerl ) {

##### Generate code for each pair of data types #####

for my $in ( keys %PDL_DATATYPES ) {
for my $in ( PDL::Types::typesrtkeys() ) {

my $intype = $PDL_DATATYPES{$in};

Expand All @@ -204,7 +205,7 @@ for my $in ( keys %PDL_DATATYPES ) {
switch ( targtype ) {
!WITH!SUBS!

for my $targ ( keys %PDL_DATATYPES ) {
for my $targ ( PDL::Types::typesrtkeys() ) {

next if $in eq $targ; # Skip duplicates
my $targtype = $PDL_DATATYPES{$targ};
Expand Down
6 changes: 3 additions & 3 deletions Basic/Core/pdlcore.c.PL
Expand Up @@ -971,7 +971,7 @@ pdl* pdl_from_array(AV* av, AV* dims, int type, pdl* p)
# Perl snippet autogenerates switch statement to distribute
# pdl_setav calls...
#
for my $type(sort keys %PDL_DATATYPES){
for my $type(typesrtkeys()){
my $t2 = $PDL_DATATYPES{$type};
$t2 =~ s/PDL_//;
print OUT <<"!WITH!SUBS!";
Expand Down Expand Up @@ -1032,7 +1032,7 @@ pdl* pdl_from_array(AV* av, AV* dims, int type, pdl* p)
*/
!NO!SUBS!

for my $in ( keys %PDL_DATATYPES ) {
for my $in ( typesrtkeys() ) {

(my $type = $PDL_DATATYPES{$in}) =~ s/^PDL_//;

Expand Down Expand Up @@ -1092,7 +1092,7 @@ PDL_Indx pdl_kludge_copy_$type(PDL_Indx poff, // Offset into the dest data array
# the source PDL, switch_type gets the Perl name, ppsym gets
# the symbol need to retrieve from a PDL_Anyval, and type_usenan is a
# boolean indicating whether this type handles NaNs.
foreach my $switch_type (keys %PDL::Types::typehash) {
foreach my $switch_type ( typesrtkeys() ) {

my $ctype = $PDL::Types::typehash{$switch_type}{ctype};
my $stype = $PDL::Types::typehash{$switch_type}{ctype};
Expand Down
4 changes: 2 additions & 2 deletions Basic/Core/pdlcore.h.PL
Expand Up @@ -148,7 +148,7 @@ pdl* pdl_from_array(AV* av, AV* dims, int type, pdl* p);
!NO!SUBS!

for my $in ( keys %PDL_DATATYPES ) {
for my $in ( PDL::Types::typesrtkeys() ) {

(my $type = $PDL_DATATYPES{$in}) =~ s/^PDL_//;
print OUT <<"!WITH!SUBS!";
Expand Down Expand Up @@ -351,7 +351,7 @@ double NaN_double;
# file
require "Types.pm"; # ie PDL::Types

for (keys %PDL::Types::typehash) {
for (PDL::Types::typesrtkeys()) {
my $ctype = $PDL::Types::typehash{$_}{ctype};
my $ppsym = $PDL::Types::typehash{$_}{ppsym};

Expand Down
2 changes: 1 addition & 1 deletion Basic/Slices/slices.pd
Expand Up @@ -2899,7 +2899,7 @@ $sliceb_data_kludge = <<'KLUDGE';
switch( p->datatype ) {
KLUDGE

for my $type(keys %PDL::Types::typehash) {
for my $type( PDL::Types::typesrtkeys()) {
$sliceb_data_kludge .=
" case $type: nn = *( ($PDL::Types::typehash{$type}->{realctype} *)(p->data) ); break;\n";
}
Expand Down
5 changes: 2 additions & 3 deletions Basic/Ufunc/ufunc.pd
Expand Up @@ -438,7 +438,7 @@ EOD
# note: we export them to the PDL Core structure for use in
# other modules (eg Image2D)

for (keys %PDL::Types::typehash) {
for ( PDL::Types::typesrtkeys() ) {
my $ctype = $PDL::Types::typehash{$_}{ctype};
my $ppsym = $PDL::Types::typehash{$_}{ppsym};

Expand Down Expand Up @@ -1262,8 +1262,7 @@ Vectors with bad components should be moved to the end of the array:
sub generic_qsortvec_ind {
my $pdl = shift;
my $ndim = shift;
return '$TBSULNQFD(pdl_qsortvec_ind_B,pdl_qsortvec_ind_S,pdl_qsortvec_ind_U,
pdl_qsortvec_ind_L,pdl_qsortvec_ind_N,pdl_qsortvec_ind_Q,pdl_qsortvec_ind_F,pdl_qsortvec_ind_D) ($P(' . $pdl . '), $P(indx), '. $ndim.', 0, nn);';
return '$TBSULNQFD(pdl_qsortvec_ind_B,pdl_qsortvec_ind_S,pdl_qsortvec_ind_U,pdl_qsortvec_ind_L,pdl_qsortvec_ind_N,pdl_qsortvec_ind_Q,pdl_qsortvec_ind_F,pdl_qsortvec_ind_D) ($P(' . $pdl . '), $P(indx), '. $ndim.', 0, nn);';
}

pp_def(
Expand Down
2 changes: 1 addition & 1 deletion Lib/Image2D/image2d.pd
Expand Up @@ -193,7 +193,7 @@ pp_addhdr('
');

for (keys %PDL::Types::typehash) {
for ( PDL::Types::typesrtkeys() ) {
my $ctype = $PDL::Types::typehash{$_}{ctype};
my $ppsym = $PDL::Types::typehash{$_}{ppsym};

Expand Down

0 comments on commit dcf3a23

Please sign in to comment.