NFFT Logo 3.2.2
nfft_benchomp_detail.c
00001 /*
00002  * Copyright (c) 2002, 2012 Jens Keiner, Stefan Kunis, Daniel Potts
00003  *
00004  * This program is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU General Public License as published by the Free Software
00006  * Foundation; either version 2 of the License, or (at your option) any later
00007  * version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00012  * details.
00013  *
00014  * You should have received a copy of the GNU General Public License along with
00015  * this program; if not, write to the Free Software Foundation, Inc., 51
00016  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 /* $Id: simple_test.c 3372 2009-10-21 06:04:05Z skunis $ */
00020 
00021 #include <stdio.h>
00022 #include <math.h>
00023 #include <string.h>
00024 #include <stdlib.h>
00025 #include <complex.h>
00026 
00027 #include "nfft3util.h"
00028 #include "nfft3.h"
00029 #include "infft.h"
00030 #ifdef _OPENMP
00031 #include <omp.h>
00032 #endif
00033 
00034 void bench_openmp(FILE *infile, int m, int psi_flag)
00035 {
00036   nfft_plan p;
00037   int *N;
00038   int *n;
00039   int M, d, trafo_adjoint;
00040   int t, j;
00041   double re,im;
00042   ticks t0, t1;
00043   double tt_total, tt_preonepsi;
00044 
00045   fscanf(infile, "%d %d", &d, &trafo_adjoint);
00046 
00047   N = malloc(d*sizeof(int));
00048   n = malloc(d*sizeof(int));
00049 
00050   for (t=0; t<d; t++)
00051     fscanf(infile, "%d", N+t);
00052 
00053   for (t=0; t<d; t++)
00054     fscanf(infile, "%d", n+t);
00055 
00056   fscanf(infile, "%d", &M);
00057 
00058 #ifdef _OPENMP
00059   fftw_import_wisdom_from_filename("nfft_benchomp_detail_threads.plan");
00060 #else
00061   fftw_import_wisdom_from_filename("nfft_benchomp_detail_single.plan");
00062 #endif
00063 
00065   nfft_init_guru(&p, d, N, M, n, m,
00066                    PRE_PHI_HUT| psi_flag | MALLOC_X | MALLOC_F_HAT| MALLOC_F| FFTW_INIT | FFT_OUT_OF_PLACE,
00067                    FFTW_MEASURE| FFTW_DESTROY_INPUT);
00068 
00069 #ifdef _OPENMP
00070   fftw_export_wisdom_to_filename("nfft_benchomp_detail_threads.plan");
00071 #else
00072   fftw_export_wisdom_to_filename("nfft_benchomp_detail_single.plan");
00073 #endif
00074 
00075   for (j=0; j < p.M_total; j++)
00076   {
00077     for (t=0; t < p.d; t++)
00078       fscanf(infile, "%lg", p.x+p.d*j+t);
00079   }
00080 
00081   if (trafo_adjoint==0)
00082   {
00083     for (j=0; j < p.N_total; j++)
00084     {
00085       fscanf(infile, "%lg %lg", &re, &im);
00086       p.f_hat[j] = re + _Complex_I * im;
00087     }
00088   }
00089   else
00090   {
00091     for (j=0; j < p.M_total; j++)
00092     {
00093       fscanf(infile, "%lg %lg", &re, &im);
00094       p.f[j] = re + _Complex_I * im;
00095     }
00096   }
00097 
00098   t0 = getticks();
00100   if(p.nfft_flags & PRE_ONE_PSI)
00101       nfft_precompute_one_psi(&p);
00102   t1 = getticks();
00103   tt_preonepsi = nfft_elapsed_seconds(t1,t0);
00104 
00105   if (trafo_adjoint==0)
00106     nfft_trafo(&p);
00107   else
00108     nfft_adjoint(&p);
00109   t1 = getticks();
00110   tt_total = nfft_elapsed_seconds(t1,t0);
00111 
00112 #ifndef MEASURE_TIME
00113   p.MEASURE_TIME_t[0] = 0.0;
00114   p.MEASURE_TIME_t[2] = 0.0;
00115 #endif
00116 
00117 #ifndef MEASURE_TIME_FFTW
00118   p.MEASURE_TIME_t[1] = 0.0;
00119 #endif
00120 
00121   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);
00122 //  printf("%.6e\n", tt);
00123 
00124   free(N);
00125   free(n);
00126 
00128   nfft_finalize(&p);
00129 }
00130 
00131 int main(int argc, char **argv)
00132 {
00133   int m, psi_flag;
00134 #ifdef _OPENMP
00135   int nthreads;
00136 
00137   if (argc != 4)
00138     return 1;
00139 
00140   nthreads = atoi(argv[3]);
00141   fftw_init_threads();
00142   omp_set_num_threads(nthreads);
00143 #else
00144   if (argc != 3)
00145     return 1;
00146 #endif
00147 
00148   m = atoi(argv[1]);
00149   psi_flag = atoi(argv[2]);
00150 
00151   bench_openmp(stdin, m, psi_flag);
00152 
00153   return 0;
00154 }

Generated on Fri Oct 12 2012 by Doxygen 1.8.0-20120409