merge and fixes for RedHat 5.5 gcc 64bit

This commit is contained in:
Mark Borgerding
2012-07-18 00:19:37 -04:00
10 changed files with 56 additions and 44 deletions

View File

@ -7,7 +7,7 @@ CFLAGS=-O3 -I.. -I../tools $(WARNINGS)
CFLAGS+=-ffast-math -fomit-frame-pointer
#CFLAGS+=-funroll-loops
#CFLAGS+=-march=prescott
CFLAGS+= -mtune=native
#CFLAGS+= -mtune=native
# TIP: try adding -openmp or -fopenmp to enable OPENMP directives and use of multiple cores
#CFLAGS+=-fopenmp
CFLAGS+= $(CFLAGADD)
@ -66,20 +66,20 @@ tools:
$(SELFTEST): $(SELFTESTSRC) $(SRCFILES)
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) -lm $+
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm
$(TESTKFC): $(SRCFILES)
$(CC) -o $@ $(CFLAGS) -DKFC_TEST $(TYPEFLAGS) -lm $+
$(CC) -o $@ $(CFLAGS) -DKFC_TEST $(TYPEFLAGS) $+ -lm
$(TESTREAL): test_real.c $(SRCFILES)
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) -lm $+
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm
$(BENCHKISS): benchkiss.c $(SRCFILES)
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) -lm $+
$(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) $+ -lm
$(BENCHFFTW): benchfftw.c pstats.c
@echo "======attempting to build FFTW benchmark"
@$(CC) -o $@ $(CFLAGS) -DDATATYPE$(DATATYPE) $+ -lm $(FFTWLIB) $(FFTWLIBDIR) || echo "FFTW not available for comparison"
@$(CC) -o $@ $(CFLAGS) -DDATATYPE$(DATATYPE) $+ $(FFTWLIB) $(FFTWLIBDIR) -lm || echo "FFTW not available for comparison"
test: all
@./$(TESTKFC)
@ -101,7 +101,7 @@ selftest_short.c:
CXXFLAGS=-O3 -ffast-math -fomit-frame-pointer -I.. -I../tools -W -Wall
testcpp: testcpp.cc ../kissfft.hh
$(CXX) -o $@ $(CXXFLAGS) -lm testcpp.cc
$(CXX) -o $@ $(CXXFLAGS) testcpp.cc -lm
clean:

View File

@ -7,8 +7,7 @@ import random
import struct
import popen2
import getopt
import Numeric
import FFT
import numpy
pi=math.pi
e=math.e
@ -26,7 +25,7 @@ elif datatype=='int16_t':
fmt='h'
minsnr=10
elif datatype=='int32_t':
fmt='l'
fmt='i'
elif datatype=='simd':
fmt='4f'
sys.stderr.write('testkiss.py does not yet test simd')
@ -39,21 +38,21 @@ else:
def dopack(x,cpx=1):
x = Numeric.reshape( x, ( Numeric.size(x),) )
x = numpy.reshape( x, ( numpy.size(x),) )
if cpx:
s = ''.join( [ struct.pack(fmt*2,c.real,c.imag) for c in x ] )
else:
s = ''.join( [ struct.pack(fmt,c) for c in x ] )
s = ''.join( [ struct.pack(fmt,c.real) for c in x ] )
return s
def dounpack(x,cpx):
uf = fmt * ( len(x) / struct.calcsize(fmt) )
s = struct.unpack(uf,x)
if cpx:
return Numeric.array(s[::2]) + Numeric.array( s[1::2] )*j
return numpy.array(s[::2]) + numpy.array( s[1::2] )*j
else:
return Numeric.array(s )
return numpy.array(s )
def make_random(dims=[1]):
res = []
@ -67,11 +66,11 @@ def make_random(dims=[1]):
res.append( complex(r,i) )
else:
res.append( make_random( dims[1:] ) )
return Numeric.array(res)
return numpy.array(res)
def flatten(x):
ntotal = Numeric.product(Numeric.shape(x))
return Numeric.reshape(x,(ntotal,))
ntotal = numpy.size(x)
return numpy.reshape(x,(ntotal,))
def randmat( ndims ):
dims=[]
@ -85,20 +84,20 @@ def randmat( ndims ):
def test_fft(ndims):
x=randmat( ndims )
print 'dimensions=%s' % str( Numeric.shape(x) ),
if doreal:
xver = FFT.real_fftnd(x)
xver = numpy.fft.rfftn(x)
else:
xver = FFT.fftnd(x)
xver = numpy.fft.fftn(x)
open('/tmp/fftexp.dat','w').write(dopack( flatten(xver) , True ) )
x2=dofft(x)
x2=dofft(x,doreal)
err = xver - x2
errf = flatten(err)
xverf = flatten(xver)
errpow = Numeric.vdot(errf,errf)+1e-10
sigpow = Numeric.vdot(xverf,xverf)+1e-10
errpow = numpy.vdot(errf,errf)+1e-10
sigpow = numpy.vdot(xverf,xverf)+1e-10
snr = 10*math.log10(abs(sigpow/errpow) )
print 'SNR (compared to NumPy) : %.1fdB' % float(snr)
@ -108,10 +107,9 @@ def test_fft(ndims):
print 'err',err
sys.exit(1)
def dofft(x):
dims=list( Numeric.shape(x) )
def dofft(x,isreal):
dims=list( numpy.shape(x) )
x = flatten(x)
iscomp = (type(x[0]) == complex)
scale=1
if datatype=='int16_t':
@ -126,11 +124,12 @@ def dofft(x):
if doreal:
cmd += ' -R '
print cmd
p = popen2.Popen3(cmd )
open('/tmp/fftin.dat','w').write(dopack( x , iscomp ) )
open('/tmp/fftin.dat','w').write(dopack( x , isreal==False ) )
p.tochild.write( dopack( x , iscomp ) )
p.tochild.write( dopack( x , isreal==False ) )
p.tochild.close()
res = dounpack( p.fromchild.read() , 1 )
@ -141,7 +140,7 @@ def dofft(x):
res = scale * res
p.wait()
return Numeric.reshape(res,dims)
return numpy.reshape(res,dims)
def main():
opts,args = getopt.getopt(sys.argv[1:],'r')

View File

@ -89,6 +89,6 @@ int main(int argc,char ** argv)
if (snr>maxsnr) maxsnr=snr;
printf("TwoToneTest: snr ranges from %ddB to %ddB\n",(int)minsnr,(int)maxsnr);
printf("sizeof(kiss_fft_scalar) = %d\n",sizeof(kiss_fft_scalar) );
printf("sizeof(kiss_fft_scalar) = %d\n",(int)sizeof(kiss_fft_scalar) );
return 0;
}