Thread Subject: why is IFFT2 3x slower than FFT2 for complex 2d arrays?

Subject: why is IFFT2 3x slower than FFT2 for complex 2d arrays?

From: Bas

Date: 18 Apr, 2011 09:43:27

Message: 1 of 2

Hi group,

I was profiling my code and noticed that IFFT2 is about 3-4 times slower than FFT2. See the following test code:

%%%%%%%%%%

n = 128;
m = 1000;
x = randn(n,n) + 1j * randn(n,n);
dummy = 0;
for k = 1:m
    y = fft2(x);
    dummy = dummy + y(1,1); %pretend we are using y
end
for k = 1:m
    y = ifft2(x);
    dummy = dummy + y(1,1); %pretend we are using y
end

%%%%%%%%%%%%

I played a bit with calling (fftw('planner', 'exhaustive'), substiting FFT2/ITTF2 by FFTN/IFFTN and using fft2(..., 'nonsymmetric'), but with pretty similar results. I only found one similar discussion in this group [1], but in that case they were using real vectors as inputs, in my case it is always 2D complex matrices.

The goal of this exercise is to speed up my simulation that can take up to a day and whose inner loop consists of
Y{r} = ifft2(P{p} .* fft2(X{q}));
where all matrices are complex and have size around 100x100. The P{q} are constants, while X{q} changes on every loop. My platform is 32-bit Linux (RedHat clone).

Thanks,
Bas


[1] https://groups.google.com/d/topic/comp.soft-sys.matlab/lpfm5AQGFzI/discussion

Subject: why is IFFT2 3x slower than FFT2 for complex 2d arrays?

From: Matt J

Date: 18 Apr, 2011 13:43:05

Message: 2 of 2

Bas <wegwerp@gmail.com> wrote in message <b04fa477-e34b-4771-b2c6-8903970e5f3a@glegroupsg2000goo.googlegroups.com>...
> Hi group,
>
> I was profiling my code and noticed that IFFT2 is about 3-4 times slower than FFT2. See the following test code:
================

I can't reproduce this, I'm afriad (on R2010b, at least). When I run your code, I get similar timings to within a few percent.


n = 128;
m = 1000;
x = randn(n,n) + 1j * randn(n,n);
dummy = 0;

tic;
for k = 1:m
    y = fft2(x);
    dummy = dummy + y(1,1); %pretend we are using y
end
toc;
%Elapsed time is 0.600586 seconds.

tic;
for k = 1:m
    y = ifft2(x);
    dummy = dummy + y(1,1); %pretend we are using y
end
toc;
%Elapsed time is 0.592721 seconds.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com