Skip to content

Commit

Permalink
use par_realdims instead of RANK, drop gnu99
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 28, 2024
1 parent b9d5c0f commit 6c2f2e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ my @package = (qw(fftw3.pd FFTW3 PDL::FFTW3), undef, 1);
my %descriptor = pdlpp_stdargs(\@package);

$descriptor{VERSION_FROM} = 'fftw3.pd';
$descriptor{OPTIMIZE} = ($Config{ccname} =~ m/gcc/) ? '-O2' : $Config{optimize};
$descriptor{CCFLAGS} .= ( ($Config{ccname} =~ m/gcc/) ? '--std=gnu99 ' : '' ) . $Config{ccflags};

# I support single and double precision FFTW calls, so both fftw and fftw3f
push @{$descriptor{LIBS} }, $libs;
Expand Down
6 changes: 3 additions & 3 deletions fftw3.pd
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ $TFD(fftwf_,fftw_)plan plan = INT2PTR($TFD(fftwf_,fftw_)plan, $COMP(plan));
$TFD(fftwf_,fftw_)execute_dft_r2c(plan, (void*)$P(real), (void*)$P(complexv));
EOF
my $TEMPLATE_REAL_C2R = <<'EOF';
// RANK is replaced with the rank of this transform
// make sure the PDL data type I'm using matches the FFTW data type
static_assert_fftw(sizeof($GENERIC()) == sizeof($TGC(fftwf_,fftw_)complex));
$TGC(fftwf_,fftw_)plan plan = INT2PTR($TGC(fftwf_,fftw_)plan, $COMP(plan));
// FFTW inverse real transforms clobber their input. I thus make a new
// buffer and transform from there
unsigned long nelem = 1;
for( int i=0; i<=RANK; i++ )
PDL_Indx i, rank = $PRIV(vtable)->par_realdims[0];
for( i=0; i<rank; i++ )
nelem *= $PDL(complexv)->dims[i];
unsigned long elem_scale = sizeof($GENERIC()) / sizeof( $TGC(float,double) ); /* native complex */
void *input_copy = $TGC(fftwf_,fftw_)alloc_real( nelem * elem_scale );
Expand Down Expand Up @@ -760,7 +760,7 @@ if( $PDL(real)->dims[0] <= 0 )
$SIZE(n1) = 2*$PDL(complexv)->dims[0] - 2;
EOF
$pp_def{Pars} = "complexv($dims_complex_string); real [o]real($dims_real_string);";
$pp_def{Code} = $TEMPLATE_REAL_C2R =~ s/RANK/$rank-1/gre;
$pp_def{Code} = $TEMPLATE_REAL_C2R;
$pp_def{GenericTypes} = [qw(G C)];
pp_def( "__irNfft$rank", %pp_def );
}
Expand Down

0 comments on commit 6c2f2e9

Please sign in to comment.