I'm trying to determine the processing time required to perform a FFT of length 500,000 on a Raspberry Pi in C/C++. I have had difficulty finding any information that would be useful for determining this. How would I go about doing this?
1 Answer
Since you care about the time it takes, you'll want to use an optimized FFT implementation. That would be FFTw or FFTS, realistically. Historically, FFTw is way dominant in software (I mean, even Matlab uses that), but FFTS works really well on ARM, so might be the better choice for your Pi.
Then you'd just write a minimal C++ program that
- creates an
fftw_plan
/ffts_plan_t
- generates random data (
std::uniform_real_distribution
is your friend in generating real and imaginary parts of numbers) - uses
using sc = std::chrono; auto start = sc::steady_clock::now();
as a "start" timer, fftw_execute
/ffts_execute
the plan on your random dataauto finished = sc::steady_clock::now();
, andauto ms = sc::duration_cast<sc::duration<double>>(finished-start).count()*1000;
to get the execution time in milliseconds.
You might want to run the actual plan multiple times (maybe even modifying the data in between) and divide the total time by the number of executions, to reduce the measurement error.
A note on the raspberry Pi: If you're using a modern RPi, don't use 32 bit operating systems, but go for an Aarch64 OS. In my experience, not having the SIMD instructions available in 64 bit mode really really hurts numeric throughput performance. (For an FFT, the better loop performance of aarch64 compilers might also help significantly; haven't benchmarked that.)
N=5e5
it takes about 53 ms forfftw_execute
to finish. $\endgroup$