mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 19:29:02 +08:00
added benchmark for unscaled and half-spectrum FFTs
This commit is contained in:
parent
f1a025185a
commit
7a6cb2a39c
@ -54,7 +54,7 @@ template <> string nameof<long double>() {return "long double";}
|
|||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void bench(int nfft,bool fwd)
|
void bench(int nfft,bool fwd,bool unscaled=false, bool halfspec=false)
|
||||||
{
|
{
|
||||||
typedef typename NumTraits<T>::Real Scalar;
|
typedef typename NumTraits<T>::Real Scalar;
|
||||||
typedef typename std::complex<Scalar> Complex;
|
typedef typename std::complex<Scalar> Complex;
|
||||||
@ -63,16 +63,28 @@ void bench(int nfft,bool fwd)
|
|||||||
vector<Complex > outbuf(nfft);
|
vector<Complex > outbuf(nfft);
|
||||||
FFT< Scalar > fft;
|
FFT< Scalar > fft;
|
||||||
|
|
||||||
|
if (unscaled) {
|
||||||
|
fft.SetFlag(fft.Unscaled);
|
||||||
|
cout << "unscaled ";
|
||||||
|
}
|
||||||
|
if (halfspec) {
|
||||||
|
fft.SetFlag(fft.HalfSpectrum);
|
||||||
|
cout << "halfspec ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::fill(inbuf.begin(),inbuf.end(),0);
|
||||||
fft.fwd( outbuf , inbuf);
|
fft.fwd( outbuf , inbuf);
|
||||||
|
|
||||||
BenchTimer timer;
|
BenchTimer timer;
|
||||||
timer.reset();
|
timer.reset();
|
||||||
for (int k=0;k<8;++k) {
|
for (int k=0;k<8;++k) {
|
||||||
timer.start();
|
timer.start();
|
||||||
for(int i = 0; i < nits; i++)
|
if (fwd)
|
||||||
if (fwd)
|
for(int i = 0; i < nits; i++)
|
||||||
fft.fwd( outbuf , inbuf);
|
fft.fwd( outbuf , inbuf);
|
||||||
else
|
else
|
||||||
|
for(int i = 0; i < nits; i++)
|
||||||
fft.inv(inbuf,outbuf);
|
fft.inv(inbuf,outbuf);
|
||||||
timer.stop();
|
timer.stop();
|
||||||
}
|
}
|
||||||
@ -86,6 +98,7 @@ void bench(int nfft,bool fwd)
|
|||||||
mflops /= 2;
|
mflops /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fwd)
|
if (fwd)
|
||||||
cout << " fwd";
|
cout << " fwd";
|
||||||
else
|
else
|
||||||
@ -100,6 +113,9 @@ int main(int argc,char ** argv)
|
|||||||
bench<complex<float> >(NFFT,false);
|
bench<complex<float> >(NFFT,false);
|
||||||
bench<float>(NFFT,true);
|
bench<float>(NFFT,true);
|
||||||
bench<float>(NFFT,false);
|
bench<float>(NFFT,false);
|
||||||
|
bench<float>(NFFT,false,true);
|
||||||
|
bench<float>(NFFT,false,true,true);
|
||||||
|
|
||||||
bench<complex<double> >(NFFT,true);
|
bench<complex<double> >(NFFT,true);
|
||||||
bench<complex<double> >(NFFT,false);
|
bench<complex<double> >(NFFT,false);
|
||||||
bench<double>(NFFT,true);
|
bench<double>(NFFT,true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user