|
|
Bugzilla Link |
2 |
Created on |
Mar 05, 2003 09:53 |
Resolution |
FIXED |
Resolved on |
Mar 05, 2003 18:51 |
Version |
1.00beta |
OS |
Linux |
Architecture |
PC |
Extended Description
Hallo allerseits,
bei einem erneuten Versuch, die FFT mithilfe der WLS eleganter zu
implementieren, bemerkte ich, dass das anghängte (stark verkürzte)
Beispielprogramm fft_cpx.sac mit der Einstellung -wls_aggressive falsche
Ergebnisse liefert. Da ich offen gestanden nicht weiß, wo der Fehler liegen
könnte, bitte ich um eure Hilfe.
Eine genauere Untersuchung ergab, dass das Fehlverhalten in der Funktion
FFT1d_Slice zu finden ist.
Nach der Compilerphase -b14 sieht alles so aus, wie ich es von der aggressiven
WLS erwarten würde:
_MAIN:cpx[16,16,16] _MAIN:FFT1d_Slice( _MAIN:cpx[16,16,16] a)
/*
* FFT1d_Slice :: */
{
double _wls_78;
int _wls_77;
int _wls_76;
int _wls_75_16_2__;
_MAIN:cpx[16,16,16] result;
_MAIN:cpx[16] slice;
_MAIN:cpx[16] _flat_24;
int _type_45;
int _type_44;
int[2] _flat_23_iv:VECT:$;
int[4] _wls_79:VECT:$;
result = with ([ 0, 0, 0, 0 ] <= _wls_79=[_type_44, _type_45, _wls_77, _wls_76]
< [ 16, 16, 16, 2 ])
{
_flat_23_iv:VECT:$ = [ _type_44, _type_45 ];
_wls_75_16_2__:IDX(_MAIN:cpx[16]):$ = ((_wls_77 * 2) + _wls_76);
_flat_24 = _MAIN:sel( _flat_23_iv, a);
slice = _MAIN:add( _flat_24);
_wls_78 = idx_sel( _wls_75_16_2__, slice);
}
modarray( a, dummy, _wls_78);
return( result);
}
Breche ich den Vorgang jedoch nach Phase 15 ab, ist von der gesamten With-Loop
nichts mehr zu sehen und das eingegebene Array wird unverändert zurückgegeben:
_MAIN:cpx[16,16,16] _MAIN:FFT1d_Slice( _MAIN:cpx[16,16,16] a)
/*
* FFT1d_Slice :: */
{
double _wls_78;
int _wls_77;
int _wls_76;
int _wls_75_16_2__;
_MAIN:cpx[16,16,16] result;
_MAIN:cpx[16] slice;
_MAIN:cpx[16] _flat_24;
int _type_45;
int _type_44;
int[2] _flat_23_iv;
int[4] _wls_79;
result = a;
return( result);
}
Interessant ist auch, dass ein ähnliches Programm mit Doubles statt Complex
perfekt übersetzt wird (nobug.sac).
Könnt ihr mir weiterhelfen?
Kai
--- nobug.sac ---
import Array:all;
import StdIO:all;
double[+] test(double[+] a)
{
return(a+1d);
}
double[+] hallo(double[+] A)
{
res = with([0,0] <= iv < [shape(A)[[0]],shape(A)[[1]]]) {
vi = test(A[iv]);
}
modarray(A,iv,vi);
return(res);
}
int main()
{
U = genarray([16,16,16,2],0d);
V = hallo(U);
/* print 1 if U==V */
print(with (0*shape(U) <= iv < shape(U)) fold(&&,true,V[iv]==U[iv]));
return (0);
}
--- fft_cpx.sac ---
import Array: all;
import StdIO: all;
import Math: all;
import ArrayIO: all;
typedef double[2] cpx;
/**** complex *****/
inline
double[2] cpx2dbl(cpx c)
{
return((:double[2]) c);
}
inline
double[+] cpx2dbl(cpx[+] c)
{
return((:double[+]) c);
}
inline
cpx dbl2cpx(double[2] d)
{
return((:cpx) d);
}
inline
cpx[+] dbl2cpx(double[+] d)
{
return((:cpx[+]) d);
}
inline cpx + (cpx a, cpx b)
{
res = with(. <= iv <= .)
genarray([2], a[iv] + b[iv]);
return(res);
}
inline cpx[+] + (cpx[+] X1, cpx X2)
{
res = with (. <= iv <= .)
genarray( drop([-1],shape(X1)), ((:cpx)((:double[+])X1)[iv]) + X2);
return(res);
}
cpx[+] sel(int[+] iv, cpx[+] a)
{
ad = cpx2dbl(a);
rd = ad[iv];
return( dbl2cpx(rd));
}
/*** FFT core ***/
cpx[+] add(cpx[+] v)
{
return( v+((:cpx)[1d,0d]));
}
/* slices array in direction (k), calculates fft(), */
/* reassebles slices to array */
cpx[+] FFT1d_Slice(cpx[+] a)
{
result = with( [0,0] <= iv < [shape(a)[[0]],shape(a)[[1]]] )
{
slice = add(a[iv]);
}
modarray( a, iv, slice);
return( result);
}
/*** MAIN ***/
int main()
{
U = dbl2cpx(genarray([16,16,16,2],0d));
V = FFT1d_Slice(U);
/* print 1 if U==V */
print(with (0*shape(U) <= iv < shape(U))
fold(&&,true,((:double[+])V)[iv]==((:double[+])U)[iv]));
return(0);
}