void bench_openmp_readfile(FILE *infile, int *trafo_adjoint, int *N, int *M, double **x, C **f_hat, C **f) { double re,im; int k, n, j, t; nfsft_plan plan; fscanf(infile, "%d %d %d", trafo_adjoint, N, M); *x = (double *)nfft_malloc(2*(*M)*sizeof(double)); *f_hat = (C*)nfft_malloc((2*(*N)+2) * (2*(*N)+2) * sizeof(C)); *f = (C*)nfft_malloc((*M)*sizeof(C)); memset(*f_hat,0U,(2*(*N)+2) * (2*(*N)+2) * sizeof(C)); memset(*f,0U,(*M)*sizeof(C)); #ifdef _OPENMP fftw_import_wisdom_from_filename("nfsft_benchomp_detail_threads.plan"); #else fftw_import_wisdom_from_filename("nfsft_benchomp_detail_single.plan"); #endif nfsft_init_guru(&plan, *N, *M, NFSFT_MALLOC_X | NFSFT_MALLOC_F | NFSFT_MALLOC_F_HAT | NFSFT_NORMALIZED | NFSFT_PRESERVE_F_HAT, PRE_PHI_HUT | FFTW_INIT | FFT_OUT_OF_PLACE, 6); #ifdef _OPENMP fftw_export_wisdom_to_filename("nfsft_benchomp_detail_threads.plan"); #else fftw_export_wisdom_to_filename("nfsft_benchomp_detail_single.plan"); #endif for (j=0; j < *M; j++) for (t=0; t < 2; t++) fscanf(infile, "%lg", (*x)+2*j+t); if (trafo_adjoint==0) { for (k = 0; k <= *N; k++) for (n = -k; n <= k; n++) { fscanf(infile, "%lg %lg", &re, &im); (*f_hat)[NFSFT_INDEX(k,n,&plan)] = re + _Complex_I * im; } } else { for (j=0; j < *M; j++) { fscanf(infile, "%lg %lg", &re, &im); (*f)[j] = re + _Complex_I * im; } } nfsft_finalize(&plan); }
void bench_openmp(FILE *infile, int m, int psi_flag) { nfft_plan p; int *N; int *n; int M, d, trafo_adjoint; int t, j; double re,im; ticks t0, t1; double tt_total, tt_preonepsi; fscanf(infile, "%d %d", &d, &trafo_adjoint); N = malloc(d*sizeof(int)); n = malloc(d*sizeof(int)); for (t=0; t<d; t++) fscanf(infile, "%d", N+t); for (t=0; t<d; t++) fscanf(infile, "%d", n+t); fscanf(infile, "%d", &M); #ifdef _OPENMP fftw_import_wisdom_from_filename("nfft_benchomp_detail_threads.plan"); #else fftw_import_wisdom_from_filename("nfft_benchomp_detail_single.plan"); #endif /** init an d-dimensional plan */ nfft_init_guru(&p, d, N, M, n, m, PRE_PHI_HUT| psi_flag | MALLOC_X | MALLOC_F_HAT| MALLOC_F| FFTW_INIT | FFT_OUT_OF_PLACE, FFTW_MEASURE| FFTW_DESTROY_INPUT); #ifdef _OPENMP fftw_export_wisdom_to_filename("nfft_benchomp_detail_threads.plan"); #else fftw_export_wisdom_to_filename("nfft_benchomp_detail_single.plan"); #endif for (j=0; j < p.M_total; j++) { for (t=0; t < p.d; t++) fscanf(infile, "%lg", p.x+p.d*j+t); } if (trafo_adjoint==0) { for (j=0; j < p.N_total; j++) { fscanf(infile, "%lg %lg", &re, &im); p.f_hat[j] = re + _Complex_I * im; } } else { for (j=0; j < p.M_total; j++) { fscanf(infile, "%lg %lg", &re, &im); p.f[j] = re + _Complex_I * im; } } t0 = getticks(); /** precompute psi, the entries of the matrix B */ if(p.nfft_flags & PRE_ONE_PSI) nfft_precompute_one_psi(&p); t1 = getticks(); tt_preonepsi = nfft_elapsed_seconds(t1,t0); if (trafo_adjoint==0) nfft_trafo(&p); else nfft_adjoint(&p); t1 = getticks(); tt_total = nfft_elapsed_seconds(t1,t0); #ifndef MEASURE_TIME p.MEASURE_TIME_t[0] = 0.0; p.MEASURE_TIME_t[2] = 0.0; #endif #ifndef MEASURE_TIME_FFTW p.MEASURE_TIME_t[1] = 0.0; #endif printf("%.6e %.6e %6e %.6e %.6e %.6e\n", tt_preonepsi, p.MEASURE_TIME_t[0], p.MEASURE_TIME_t[1], p.MEASURE_TIME_t[2], tt_total-tt_preonepsi-p.MEASURE_TIME_t[0]-p.MEASURE_TIME_t[1]-p.MEASURE_TIME_t[2], tt_total); // printf("%.6e\n", tt); free(N); free(n); /** finalise the one dimensional plan */ nfft_finalize(&p); }