void cSystem::stopNthreadsFFTW(void) { fftw_cleanup_threads(); fftwf_cleanup_threads(); std::cout << "FFTW multithreading is turned off\n\n"; }
void fft2_finalize() /*< clean up fftw >*/ { /* make sure everything is back to its pristine state */ #ifdef SF_HAS_FFTW #ifdef _OPENMP fftwf_cleanup_threads(); #endif fftwf_destroy_plan(cfg); fftwf_destroy_plan(icfg); fftwf_cleanup(); cfg=NULL; icfg=NULL; #else if (NULL != cfg) { free(cfg); cfg=NULL; } if (NULL != icfg) { free(icfg); icfg=NULL; } if (NULL != cfg1) { free(cfg1); cfg1=NULL; } if (NULL != icfg1) { free(icfg1); icfg1=NULL; } if (NULL != cfg2) { free(cfg2); cfg2=NULL; } if (NULL != icfg2) { free(icfg2); icfg2=NULL; } if (NULL != tmp) { free(*tmp); free(tmp); tmp=NULL; } if (NULL != trace2) { free(trace2); trace2=NULL; } #endif if (cmplx) { if (NULL != cc) { free(*cc); free(cc); cc=NULL; } } else { if (NULL != ff) { free(*ff); free(ff); ff=NULL; } } if (NULL != dd) { free(dd); dd=NULL; } }
void cfft3_finalize() /*< clean up fftw >*/ { #ifdef SF_HAS_FFTW #ifdef _OPENMP fftwf_cleanup_threads(); #endif fftwf_destroy_plan(cfg); fftwf_destroy_plan(icfg); fftwf_cleanup(); cfg=NULL; icfg=NULL; #else free(cfg1); cfg1=NULL; free(icfg1); icfg1=NULL; free(cfg2); cfg2=NULL; free(icfg2); icfg2=NULL; free(cfg3); cfg3=NULL; free(icfg3); icfg3=NULL; #endif free(**cc); free(*cc); free(cc); }
void cfft2_finalize() /*< clean up fftw >*/ { /* make sure everything is back to its pristine state */ #ifdef SF_HAS_FFTW #ifdef _OPENMP fftwf_cleanup_threads(); #endif fftwf_destroy_plan(cfg); fftwf_destroy_plan(icfg); fftwf_cleanup(); cfg=NULL; icfg=NULL; #else free(cfg1); cfg1=NULL; free(icfg1); icfg1=NULL; free(cfg2); cfg2=NULL; free(icfg2); icfg2=NULL; #endif free(*cc); free(cc); free(*dd); free(dd); }
void cleanup_threads() { fftw_cleanup_threads(); fftwf_cleanup_threads(); fftwl_cleanup_threads(); # ifdef FFTWQ_REAL fftwq_cleanup_threads(); # endif //FFTWQ_REAL }
int main(){ int nthreads = 4; omp_set_num_threads(nthreads); #pragma omp parallel fprintf(stderr,"nthreads %d \n", omp_get_num_threads()); int n3 = 128; int n2 = 128; int n1 = 128; // float ***array = sf_floatalloc3(n1,n2,n3); float *array = fftwf_alloc_real(n3*n2*n1); fftwf_complex* cout = fftwf_alloc_complex(n3*n2*n1); int err = fftwf_init_threads(); if (err == 0) { fprintf(stderr,"something went wrong with fftw\n"); } fprintf(stderr,"Got here\n"); double start,end; start = omp_get_wtime()*omp_get_wtick(); fftwf_plan_with_nthreads(nthreads); fftwf_plan plan = fftwf_plan_dft_r2c_3d( n1,n2,n3, array,cout, FFTW_MEASURE); end = omp_get_wtime()*omp_get_wtick(); fprintf(stderr,"elapsed time: %f %f %f\n",end,start,end-start); for(int i = 0; i < n3*n2*n1; ++i) array[i] = rand()/RAND_MAX; //float start = clock()/CLOCKS_PER_SEC; start = omp_get_wtime(); for(int i=0; i < 1001; ++i) fftwf_execute(plan); //float end = clock()/CLOCKS_PER_SEC; end = omp_get_wtime(); fprintf(stderr,"elapsed time: %f time/calc %f\n", end-start,(end-start)/100.0); fftwf_cleanup_threads(); fftwf_cleanup(); fftwf_destroy_plan(plan); fftwf_free(cout); fftwf_free(array); //free(**array); free(*array); free(array); return 0; }
static void cleanup_threads(){ fftwf_cleanup_threads(); }
void Fft::CleanupFft(){ fftwf_cleanup_threads(); fftwf_cleanup(); }