Skip to content
Snippets Groups Projects
Commit 0a3d88b4 authored by Ger van Diepen's avatar Ger van Diepen
Browse files

Task #3198 Added timers for parallel FFTW

parent 92ab0094
No related branches found
No related tags found
No related merge requests found
...@@ -501,9 +501,65 @@ void timeFlip(int sz) ...@@ -501,9 +501,65 @@ void timeFlip(int sz)
timer.show ("oldflip"); timer.show ("oldflip");
} }
void timeParallel(int direction, int sz=128, int nthread=1, bool show=false, int align=0)
{
if (show) cout <<"fftw size=" << sz << " dir=" << direction
<< " align=" << align
<< " nthread=" << nthread << endl;
Complex* ptr = static_cast<Complex*>(fftw_malloc ((sz*sz+1)*sizeof(Complex)));
Matrix<Complex> arr(IPosition(2,sz,sz), ptr+align, SHARE);
if (show) cout << ptr << ' ' << arr.data() << endl;
fftwf_init_threads();
fftwf_plan_with_nthreads (nthread);
Timer timer;
fftwf_plan plan = fftwf_plan_dft_2d(sz, sz,
reinterpret_cast<fftwf_complex*>(arr.data()),
reinterpret_cast<fftwf_complex*>(arr.data()),
direction, FFTW_ESTIMATE);
if (show) timer.show ("plan ");
init (arr);
if (direction == FFTW_FORWARD) {
if (sz%4 == 0) {
timer.mark();
preflip(arr);
if (show) timer.show ("preflip");
timer.mark();
fftwf_execute (plan);
if (show) timer.show ("exec ");
} else {
timer.mark();
flip(arr);
if (show) timer.show ("flip1 ");
timer.mark();
fftwf_execute (plan);
if (show) timer.show ("exec ");
timer.mark();
flip (arr);
if (show) timer.show ("flip2 ");
}
} else {
timer.mark();
flip(arr);
if (show) timer.show ("flip1 ");
timer.mark();
fftwf_execute (plan);
if (show) timer.show ("exec ");
timer.mark();
scaleflip (arr);
if (show) timer.show ("scalefl");
}
fftwf_destroy_plan (plan);
}
int main (int argc, char* []) int main (int argc, char* [])
{ {
cout << "Testing parallel FFTW ..." << endl;
timeParallel (FFTW_FORWARD, 4096, 1, true);
timeParallel (FFTW_FORWARD, 4096, 2, true);
timeParallel (FFTW_FORWARD, 4096, 4, true);
timeParallel (FFTW_FORWARD, 4096, 8, true);
return 0;
/// testvec(); /// testvec();
checkFlip(5); checkFlip(5);
timeFlip (2048); timeFlip (2048);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment