/* * Allocate FFT buffers for a given grid. * This must be called before FFT can be carried out * (called automatically, users don't need to call this) * * grid = 3D grid for which the FFT allocation is to be done (rgrid3d *). * * Notes: * - This uses c2r transformation since it is much faster than r2r. * * No return value. * */ EXPORT void rgrid3d_fftw_periodic_alloc(rgrid3d *grid) { long s; double *plan_temp; s = 2 * grid->nx * grid->ny * (grid->nz/2 + 1); if(!(plan_temp = fftw_malloc(sizeof(double) * s))) { fprintf(stderr, "libgrid: Out of memory in rgrid3d_fft().\n"); return; } memcpy(plan_temp, grid->value, sizeof(double) * s); if(s > temp_len) { if(temp) free(temp); if(!(temp = fftw_malloc(sizeof(double) * s))) { fprintf(stderr, "libgrid: Out of memory in rgrid3d_fft().\n"); return; } temp_len = s; temp2 = (double complex *) temp; } fftw_plan_with_nthreads(grid_threads()); grid->plan = fftw_plan_dft_r2c_3d(grid->nx, grid->ny, grid->nz, grid->value, temp2, GRID_FFTW_PLAN | FFTW_DESTROY_INPUT); fftw_plan_with_nthreads(grid_threads()); grid->iplan = fftw_plan_dft_c2r_3d(grid->nx, grid->ny, grid->nz, grid->cint->value, temp, GRID_FFTW_PLAN | FFTW_DESTROY_INPUT); grid->fft_norm = 1.0 / (grid->nx * grid->ny * grid->nz); memcpy(grid->value, plan_temp, sizeof(double) * s); free(plan_temp); }
void init_gfft() { int n_size2D_ZXY[] = {NX,NY}; #ifdef _OPENMP fftw_plan_with_nthreads( nthreads ); #endif r2cfft_mpi_t = fftw_mpi_plan_dft_r2c_3d( NY, NX, NZ, wr1, w1, MPI_COMM_WORLD, FFT_PLANNING | FFTW_MPI_TRANSPOSED_OUT); if (r2cfft_mpi_t == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW R2C_T plan creation failed"); r2cfft_mpi = fftw_mpi_plan_dft_r2c_3d( NX, NY, NZ, wr1, w1, MPI_COMM_WORLD, FFT_PLANNING); if (r2cfft_mpi == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW R2C plan creation failed"); c2rfft_mpi_t = fftw_mpi_plan_dft_c2r_3d( NY, NX, NZ, w1, wr1, MPI_COMM_WORLD, FFT_PLANNING | FFTW_MPI_TRANSPOSED_IN); if (c2rfft_mpi_t == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW C2R_T plan creation failed"); c2rfft_mpi = fftw_mpi_plan_dft_c2r_3d( NX, NY, NZ, w1, wr1, MPI_COMM_WORLD, FFT_PLANNING); if (c2rfft_mpi == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW C2R plan creation failed"); r2cfft_2Dslice = fftw_plan_dft_r2c_2d(NX,NY,wrh3,wh3,FFT_PLANNING); if (r2cfft_2Dslice == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW r2c slice plan creation failed"); // init transpose routines (These are used by remap routines) init_transpose(); fft_timer=0.0; return; }
DeconvolutionTool::DeconvolutionTool(QObject* parent):QObject(parent) { // Init MultiThreading threadsCount = QThread::idealThreadCount() > 0 ? QThread::idealThreadCount() : 2; qDebug("Init Multi-Threading with threads count: %d", threadsCount); fftw_plan_with_nthreads(threadsCount); tvIterationsCount = 500; previewMethod = 0; inputImageMatrix = NULL; outputImageMatrix = NULL; kernelMatrix = NULL; laplacianMatrix = NULL; outLaplacianMatrix = NULL; inputImageFFT = NULL; outputImageFFT = NULL; kernelFFT = NULL; kernelTempFFT = NULL; laplacianMatrixFFT = NULL; realForwardPlan = NULL; realForwardKernelPlan = NULL; realBackwardPlan = NULL; forwardLaplacianPlan = NULL; backwardLaplacianPlan = NULL; }
void dct(int N, double *in, double *out){ // compute variables int ii; fftw_plan my_plan; fftw_init_threads(); // define plan fftw_plan_with_nthreads(omp_get_max_threads()); my_plan = fftw_plan_r2r_1d(N, in, out, FFTW_REDFT00, FFTW_ESTIMATE); //execute plan fftw_execute(my_plan); // scale output for(ii=0; ii < N; ii++){ if(ii == 0 || ii == N-1){ out[ii] = out[ii]/(double)(N-1)/2.0; } else{ out[ii] = out[ii]/(double)(N-1); } } // destroy plan fftw_destroy_plan(my_plan); fftw_cleanup_threads(); }
/** * Initializes the library. * @param nthreads The number of OpenMP threads to use for execution of local FFT. * @return 0 if successful */ int accfft_init(int nthreads){ int threads_ok=1; if (threads_ok) threads_ok = fftw_init_threads(); if (threads_ok) fftw_plan_with_nthreads(nthreads); return (!threads_ok); }
///Initialize FFTW void FFTInit(int threads) { #ifdef FFTW_WITH_THREADS fftw_init_threads(); fftw_plan_with_nthreads(threads); #endif }
convolution_plan::convolution_plan(int width, int height, int kw, int mode, int threadMaxCount) { switch (mode) { case 0: this->width = width; this->height = height; break; case 1: this->width = width + kw - 1; this->height = height + kw - 1; break; default: throw std::invalid_argument("Warning: 2d convolution plan: Invalid mode"); } if (threadMaxCount > 1) { fftw_init_threads(); // This MUST come before all other fftw calls fftw_plan_with_nthreads(threadMaxCount); } this->depth = 1; this->dim = 2; this->kw = kw; this->threadMaxCount = threadMaxCount; fftw_complex* benchmarkArray1 = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * this->width * this->height); fftw_complex* benchmarkArray2 = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * this->width * this->height); this->forwardPlan = fftw_plan_dft_2d(this->height, this->width, benchmarkArray1, benchmarkArray2, FFTW_FORWARD, FFTW_MEASURE); this->backwardPlan = fftw_plan_dft_2d(this->height, this->width, benchmarkArray1, benchmarkArray2, FFTW_BACKWARD, FFTW_MEASURE); fftw_free(benchmarkArray1); fftw_free(benchmarkArray2); this->staticKernel = NULL; }
EXPORT void cgrid2d_fftw_alloc(cgrid2d *grid) { double complex *temp; long size = sizeof(double complex) * grid->nx * grid->ny; temp = fftw_malloc(size); memcpy(temp, grid->value, size); fftw_plan_with_nthreads(grid_threads()); grid->plan = fftw_plan_dft_2d(grid->nx, grid->ny, grid->value, grid->value, FFTW_FORWARD, GRID_FFTW_PLAN); fftw_plan_with_nthreads(grid_threads()); grid->iplan = fftw_plan_dft_2d(grid->nx, grid->ny, grid->value, grid->value, FFTW_BACKWARD, GRID_FFTW_PLAN); memcpy(grid->value, temp, size); fftw_free(temp); }
void plan_fftw( Search_settings *sett, Command_line_opts *opts, FFTW_plans *plans, FFTW_arrays *fftw_arr, Aux_arrays *aux_arr) { char hostname[512], wfilename[512]; FILE *wisdom; /* Imports a "wisdom file" containing information * (previous tests) about how to optimally compute Fourier * transforms on a given machine. If wisdom file is not present, * it will be created after the test (measure) runs * of the fft_plans are performed below * (see http://www.fftw.org/fftw3_doc/Wisdom.html) */ fftw_init_threads(); gethostname(hostname, 512); sprintf (wfilename, "wisdom-%s.dat", hostname); if((wisdom = fopen (wfilename, "r")) != NULL) { fftw_import_wisdom_from_file(wisdom); fclose (wisdom); } sett->Ninterp = sett->interpftpad*sett->nfft; // array length (xa, xb) is max{fftpad*nfft, Ninterp} fftw_arr->arr_len = (sett->fftpad*sett->nfft > sett->Ninterp ? sett->fftpad*sett->nfft : sett->Ninterp); // fftw_arr->xa = fftw_malloc(2*fftw_arr->arr_len*sizeof(fftw_complex)); //fftw_arr->xb = fftw_arr->xa + fftw_arr->arr_len; fftw_arr->xa = fftw_malloc(fftw_arr->arr_len*sizeof(fftw_complex)); fftw_arr->xb = fftw_malloc(fftw_arr->arr_len*sizeof(fftw_complex)); sett->nfftf = sett->fftpad*sett->nfft; // Change FFTW_MEASURE to FFTW_PATIENT for more optimized plan // (takes more time to generate the wisdom file) plans->plan = fftw_plan_dft_1d(sett->nfftf, fftw_arr->xa, fftw_arr->xa, FFTW_FORWARD, FFTW_MEASURE); fftw_plan_with_nthreads(omp_get_max_threads()); plans->pl_int = fftw_plan_dft_1d(sett->nfft, fftw_arr->xa, fftw_arr->xa, FFTW_FORWARD, FFTW_MEASURE); plans->pl_inv = fftw_plan_dft_1d(sett->Ninterp, fftw_arr->xa, fftw_arr->xa, FFTW_BACKWARD, FFTW_MEASURE); // Generates a wisdom FFT file if there is none if((wisdom = fopen(wfilename, "r")) == NULL) { wisdom = fopen(wfilename, "w"); fftw_export_wisdom_to_file(wisdom); } fclose (wisdom); } // end of FFT plans
void set_num_threads(int nr) { num_threads = nr; omp_set_num_threads(nr); int ret = fftw_init_threads(); if (ret == 0) {cout << "error" << endl; exit(1);} fftw_plan_with_nthreads(nr); }
void init_output_vtk() { double complex *w2d; const int n_size1D[1] = {NY}; #ifdef WITH_SHEAR w2d = (double complex *) fftw_malloc( sizeof(double complex) * (NY/2+1) * NZ ); if (w2d == NULL) ERROR_HANDLER( ERROR_CRITICAL, "No memory for w2d allocation"); // FFT plans (we use dummy arrays since we use the "guru" interface of fft3 in the code) // The in place/ out of place will be set automatically at this stage // The Following Fourier transforms takes an array of size ( NX+1, NY+1, NZ+1) but consider only the "included" array // of size ( NX+1, NY, NZ+1) and transforms it in y, in an array of size (NX+1, NY/2+1, NZ+1). The j=NY plane is therefore // not modified by these calls #ifdef _OPENMP fftw_plan_with_nthreads( 1 ); #endif #ifdef WITH_2D fft_1d_forward = fftw_plan_many_dft_r2c(1, n_size1D, 1, wr1, NULL, 1, 1, w2d, NULL, 1, 1, FFT_PLANNING || FFTW_UNALIGNED); #else fft_1d_forward = fftw_plan_many_dft_r2c(1, n_size1D, NZ, wr1, NULL, NZ+2, 1, w2d, NULL, NZ, 1, FFT_PLANNING || FFTW_UNALIGNED); #endif if (fft_1d_forward == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW 1D forward plan creation failed"); #ifdef WITH_2D fft_1d_backward = fftw_plan_many_dft_c2r(1, n_size1D, 1, w2d, NULL, 1, 1, wr1, NULL, 1, 1, FFT_PLANNING || FFTW_UNALIGNED); #else fft_1d_backward = fftw_plan_many_dft_c2r(1, n_size1D, NZ, w2d, NULL, NZ, 1, wr1, NULL, NZ+2, 1, FFT_PLANNING || FFTW_UNALIGNED); #endif if (fft_1d_backward == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW 1D backward plan creation failed"); fftw_free(w2d); #endif }
FFT::FFT(size_t threads) : forward_plans(), backward_plans() { if (!fftw_init_threads()) { std::cerr << "Unable to init threads in fftw\n"; throw 1; } fftw_plan_with_nthreads(threads); }
void cSystem::startNthreadsFFTW(void) { require( fftw_init_threads() != 0, "void cSystem::startNthreadsFFTW(void)"); require(fftwf_init_threads() != 0, "void cSystem::startNthreadsFFTW(void)"); fftw_plan_with_nthreads(getNumProcessors()); fftwf_plan_with_nthreads(getNumProcessors()); std::cout << "FFTW multithreading is turned on: " << getNumProcessors() << " threads\n\n"; }
JNIEXPORT void JNICALL Java_br_usp_ime_dspbenchmarking_algorithms_fftw_FFTW_removeThreadsJNI(JNIEnv *pEnv, jobject pObj) { if (!threads_initialized) { char buff[150]; sprintf(buff, "Threads weren't initialized"); (*pEnv)->ThrowNew(pEnv, (*pEnv)->FindClass(pEnv, "java/lang/Exception"), buff); } else { fftw_plan_with_nthreads(1); threads_enabled = 0; __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Threads disabled"); } }
static void plan_with_threads(int nthreads = -1, double timelimit=FFTW_NO_TIMELIMIT){ int av_procs = std::thread::hardware_concurrency(); if(nthreads<1 || nthreads>av_procs) nthreads = av_procs; fftw_plan_with_nthreads(nthreads); fftw_set_timelimit(timelimit); }
JNIEXPORT void JNICALL Java_br_usp_ime_dspbenchmarking_algorithms_fftw_FFTW_initThreadsJNI(JNIEnv *pEnv, jobject pObj, jint num_of_threads) { if (!threads_initialized && !fftw_init_threads()) { char buff[150]; sprintf(buff, "Failed to initialize thread"); (*pEnv)->ThrowNew(pEnv, (*pEnv)->FindClass(pEnv, "java/lang/Exception"), buff); } else { fftw_plan_with_nthreads(num_of_threads); threads_enabled = 1; threads_initialized = 1; __android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Threads enabled"); } }
/* The use of REDFT00 is prefered over REDFT01 because * REDFT00 starts at x=0 and REDFT01 at x=0.5*step. This makes * REDFT00 a better choice to reproduce the * coarse-graining and Lennard-Jones kernels. * With REDFT00 their integral (or their k=0 FT) is closer * to 1 and -b respectively. * * Note the normalization depends on the plan used: * REDFT00 -> 1/(2*nx-1) * REDFT01 -> 1/(2*nx) * */ EXPORT void rgrid3d_fftw_nonperiodic_alloc(rgrid3d *grid) { long s = grid-> nx * grid->ny * grid-> nz ; double *temp ; temp = malloc( sizeof(double)*s ) ; memcpy(temp, grid->value, sizeof(double)*s ) ; fftw_plan_with_nthreads(grid_threads()); grid->plan = fftw_plan_r2r_3d(grid->nx, grid->ny, grid->nz, grid->value, grid->value, FFTW_REDFT10 , FFTW_REDFT10 , FFTW_REDFT10 , GRID_FFTW_PLAN | FFTW_DESTROY_INPUT); fftw_plan_with_nthreads(grid_threads()); grid->iplan = fftw_plan_r2r_3d(grid->nx, grid->ny, grid->nz, grid->value, grid->value, FFTW_REDFT01 , FFTW_REDFT01 , FFTW_REDFT01 , GRID_FFTW_PLAN | FFTW_DESTROY_INPUT); grid->fft_norm = 1.0 / (2 * (grid->nx ) * 2 * (grid->ny ) * 2 * (grid->nz )); memcpy(grid->value, temp, sizeof(double)*s ); free(temp); }
void fftInitThreading() { #ifdef _OPENMP #ifdef INTEL_MKL_VERSION // NOTE: Using Intel MKL (and threading particularly) // could require a lot of additional setup fftw3_mkl.number_of_user_threads = omp_get_max_threads(); #else fftw_init_threads(); fftw_plan_with_nthreads(omp_get_max_threads()); #endif #endif }
void fft_init() { fftw_init_threads(); fftw_plan_with_nthreads(6); int i; for(i=0;i<2;i++){ fft_in[i] = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width[i]*height[i]); fft_out[i] = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width[i]*height[i]); fft_plan[i]=fftw_plan_dft_2d(height[i],width[i],fft_in[i],fft_out[i], FFTW_FORWARD, FFTW_ESTIMATE); } }
void FFTHandler::init(long arg_n){ //#ifndef DEBUG fftw_init_threads(); fftw_plan_with_nthreads(omp_get_max_threads()); //#endif n = arg_n; leased=0; //fprintf(stderr, "Initializing fft plan of size [%ld]\n", n); memoryPool.resize(1); memoryPool[0] = (double*)fftw_malloc(sizeof(double)*2*(n/2+1)); fftForwardPlan = fftw_plan_dft_r2c_1d(n, memoryPool[0], (fftw_complex*)memoryPool[0],FFTW_MEASURE); fftReversePlan = fftw_plan_dft_c2r_1d(n, (fftw_complex*)memoryPool[0], memoryPool[0],FFTW_MEASURE); }
int cfft2_init(int pad1 /* padding on the first axis */, int nx, int ny /* input data size */, int *nx2, int *ny2 /* padded data size */) /*< initialize >*/ { #ifdef SF_HAS_FFTW #ifdef _OPENMP fftw_init_threads(); sf_warning("Using threaded FFTW3! \n"); fftw_plan_with_nthreads(omp_get_max_threads()); #endif #endif #ifndef SF_HAS_FFTW int i2; #endif nk = n1 = kiss_fft_next_fast_size(nx*pad1); #ifndef SF_HAS_FFTW cfg1 = kiss_fft_alloc(n1,0,NULL,NULL); icfg1 = kiss_fft_alloc(n1,1,NULL,NULL); #endif n2 = kiss_fft_next_fast_size(ny); cc = sf_complexalloc2(n1,n2); dd = sf_complexalloc2(nk,n2); #ifndef SF_HAS_FFTW cfg2 = kiss_fft_alloc(n2,0,NULL,NULL); icfg2 = kiss_fft_alloc(n2,1,NULL,NULL); tmp = (kiss_fft_cpx **) sf_alloc(n2,sizeof(*tmp)); tmp[0] = (kiss_fft_cpx *) sf_alloc(nk*n2,sizeof(kiss_fft_cpx)); for (i2=0; i2 < n2; i2++) { tmp[i2] = tmp[0]+i2*nk; } trace2 = sf_complexalloc(n2); ctrace2 = (kiss_fft_cpx *) trace2; #endif *nx2 = n1; *ny2 = n2; wt = 1.0/(n1*n2); return (nk*n2); }
/****** fft_init ************************************************************ PROTO void fft_init(void) PURPOSE Initialize the FFT routines INPUT -. OUTPUT -. NOTES Global preferences are used for multhreading. AUTHOR E. Bertin (IAP) VERSION 29/11/2006 ***/ void fft_init(void) { if (!firsttimeflag) { #ifdef USE_THREADS if (!fftw_init_threads()) error(EXIT_FAILURE, "*Error*: thread initialization failed in ", "FFTW"); fftw_plan_with_nthreads(prefs.nthreads); QPTHREAD_MUTEX_INIT(&fftmutex, NULL); #endif firsttimeflag = 1; } return; }
Space_trans::Space_trans(const Config & configSettings):Data(configSettings) { fftw_iodim dims[DIM], howmany_dims[1]; int rank = DIM; int howmany_rank = 1; if(DIM == 1){ dims[0].n = m[0]; dims[0].is = n3; dims[0].os = n3; } if(DIM == 2){ dims[0].n = m[0]; dims[0].is = n3; dims[0].os = n3; dims[1].n = m[1]; dims[1].is = n3*m[0]; dims[1].os = n3*m[0]; } howmany_dims[0].n = n3; howmany_dims[0].is = 1; howmany_dims[0].os = 1; fftw_init_threads(); fftw_plan_with_nthreads(NUM_THREADS); pf = fftw_plan_guru_dft( rank, dims, howmany_rank, howmany_dims, realdata, realdata, FFTW_FORWARD, FFTW_ESTIMATE ); pi = fftw_plan_guru_dft( rank, dims, howmany_rank, howmany_dims, realdata, realdata, FFTW_BACKWARD, FFTW_ESTIMATE ); fftw_plan_with_nthreads(1); }
void FourierTransformer::setThreadsNumber(int tNumber) { if (tNumber != 1) { threadsSetOn = true; nthreads = tNumber; pthread_mutex_lock(&fftw_plan_mutex); if (fftw_init_threads() == 0) { REPORT_ERROR("FFTW cannot init threads (setThreadsNumber)"); } fftw_plan_with_nthreads(nthreads); pthread_mutex_unlock(&fftw_plan_mutex); } }
void FFTWInterface::create_fftw_plan(int &has_plan, fftw_plan &plan, const int fftw_direction, const int fftw_flag) { if(has_plan) return; assert(f); fftw_plan_with_nthreads(omp_get_max_threads()); double *f_copy = 0; if(n && !m) { // 1d f_copy = new double [2*n]; assert(f_copy); memcpy(f_copy, f, 2*n*sizeof(double)); } else if(n && m) { // 2d case f_copy = new double [2*m*n]; assert(f_copy); memcpy(f_copy, f, 2*m*n*sizeof(double)); } assert(f_copy); if(n && !m) { plan = fftw_plan_dft_1d(n, reinterpret_cast <fftw_complex *> (f), reinterpret_cast <fftw_complex *> (f), fftw_direction, fftw_flag); memcpy(f, f_copy, 2*n*sizeof(double)); } else if(m && n) { int row = column_major ? n : m; int col = column_major ? m : n; plan = fftw_plan_dft_2d(row, col, reinterpret_cast <fftw_complex *> (f), reinterpret_cast <fftw_complex *> (f), fftw_direction, fftw_flag); memcpy(f, f_copy, 2*m*n*sizeof(double)); } if(f_copy) { delete [] f_copy; f_copy = 0; } has_plan = 1; }
// have a look for parallel ffts int parallel_ffts( void ) { // initialise parallel fft ? #ifdef OMP_FFTW if( fftw_init_threads() == 0 ) { return GLU_FAILURE ; } else { // in here I set the number of fftw threads to be the same // as the usual number of parallel threads .. fftw_plan_with_nthreads( Latt.Nthreads ) ; fprintf( stdout , "[PAR] FFTW using %d thread(s) \n" , Latt.Nthreads ) ; } #endif return GLU_SUCCESS ; }
void ini() { LogLevel = 2; fftw_init_threads(); //<-- Desini aufrufen fftw_plan_with_nthreads(1); iniTools(5517+Parameter_SD_Selector*12345); physicalScale = NaN; physicalScaleError = NaN; GoldstoneRenormFactor = 1.0; GoldstoneRenormFactorError = 0.0; GoldstoneRenormFactorDetermined = false; xmlOutput_Tag = new char*[10000]; xmlOutput_Description = new char*[10000]; xmlOutput_Value = new double[10000]; xmlOutput_ValueError = new double[10000]; xmlOutput_Count = 0; }
// have a look for parallel ffts static int parallel_ffts( void ) { // initialise parallel fft ? #ifdef OMP_FFTW if( fftw_init_threads( ) == 0 ) { return FAILURE ; } else { // in here I set the number of fftw threads to be the same // as the usual number of parallel threads .. #pragma omp parallel { nthreads = omp_get_num_threads( ) ; } // set nthreads } fftw_plan_with_nthreads( nthreads ) ; printf("[PAR] FFTW using %d thread(s) \n" , nthreads ) ; #endif return SUCCESS ; }
/*! this is a straight forward main function, that does the following - load lua config file - get configuration table from config - contruct a preferences class from them - start simulation according to the preferences - dump the result as precified in preferences */ int main(int argc, char * argv[argc]) { fftw_init_threads(); fftw_plan_with_nthreads(4); if (argc != 3) { fprintf(stderr, "usage: %s config.lua result.dat\n", argv[0]); return -1; } lua_State * L = luaL_newstate(); luaL_openlibs(L); preferences_t * prefs = preferences_new(); if (luaL_dofile(L, argv[1])) { fprintf(stderr, "could not load '%s' : %s\n", argv[1], lua_tostring(L, 1)); } else { // get config table lua_getfield(L, LUA_GLOBALSINDEX, "config"); if (lua_isnil(L, -1)) { fprintf(stderr, "table config undefined\n"); } else { // ref config table, so we can access it in preferences_read() prefs->config = luaL_ref(L, LUA_REGISTRYINDEX); if (!preferences_read(L, prefs)) { if (!start_simulation(prefs)) { FILE * fp = fopen(argv[2], "wb"); assert(fp); dump_results(prefs, fp); fclose(fp); } } } } preferences_free(prefs); lua_close(L); fftw_cleanup(); fftw_cleanup_threads(); pthread_exit(NULL); }
void init_gfft() { double complex *wi1; double *wir1; DEBUG_START_FUNC; wi1 = (double complex *) fftw_malloc( sizeof(double complex) * NTOTAL_COMPLEX); if (wi1 == NULL) ERROR_HANDLER( ERROR_CRITICAL, "No memory for wi1 allocation"); wir1 = (double *) wi1; #ifdef _OPENMP fftw_plan_with_nthreads( nthreads ); #endif #ifdef WITH_2D r2cfft = fftw_plan_dft_r2c_2d( NX, NY, wr1, w1, FFT_PLANNING); if (r2cfft == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW R2C plan creation failed"); c2rfft = fftw_plan_dft_c2r_2d( NX, NY, w1, wr1, FFT_PLANNING); if (c2rfft == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW C2R plan creation failed"); #else r2cfft = fftw_plan_dft_r2c_3d( NX, NY, NZ, wr1, w1, FFT_PLANNING); if (r2cfft == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW R2C plan creation failed"); c2rfft = fftw_plan_dft_c2r_3d( NX, NY, NZ, w1, wr1, FFT_PLANNING); if (c2rfft == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW C2R plan creation failed"); r2cfft_2Dslice = fftw_plan_dft_r2c_2d(NX,NY,wrh3,wh3,FFT_PLANNING); if (r2cfft_2Dslice == NULL) ERROR_HANDLER( ERROR_CRITICAL, "FFTW r2c slice plan creation failed"); #endif fftw_free(wi1); fft_timer=0.0; DEBUG_END_FUNC; return; }