NFFT  3.3.1
simple_test_threads.c
00001 /*
00002  * Copyright (c) 2002, 2016 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 #include <stdio.h>
00019 #include <math.h>
00020 #include <string.h>
00021 #include <stdlib.h>
00022 #include <omp.h>
00023 
00024 #include <sys/time.h>
00025 
00026 #define NFFT_PRECISION_DOUBLE
00027 
00028 #include "nfft3mp.h"
00029 
00030 int main(void)
00031 {
00032   NFFT(plan) p;
00033   const int N = 1000000;
00034   const int M = 1000000;
00035   NFFT_R t0, t1;
00036 
00037   printf("nthreads = " NFFT__D__ "\n", NFFT(get_num_threads)());
00038 
00039   /* init */
00040   FFTW(init_threads)();
00041   NFFT(init_1d)(&p,N,M);
00042 
00043   /* pseudo random nodes */
00044   NFFT(vrand_shifted_unit_double)(p.x,p.M_total);
00045 
00046   /* precompute psi, that is, the entries of the matrix B */
00047   t0 = NFFT(clock_gettime_seconds)();
00048   if(p.flags & PRE_ONE_PSI)
00049       NFFT(precompute_one_psi)(&p);
00050   t1 = NFFT(clock_gettime_seconds)();
00051   fprintf(stderr,"precompute elapsed time: %.3" NFFT__FIS__ " seconds\n",t1-t0);
00052 
00053   /* pseudo random Fourier coefficients */
00054   NFFT(vrand_unit_complex)(p.f_hat,p.N_total);
00055 
00056   /* transformation */
00057   t0 = NFFT(clock_gettime_seconds)();
00058   NFFT(trafo)(&p);
00059   t1 = NFFT(clock_gettime_seconds)();
00060   fprintf(stderr,"compute    elapsed time: %.3" NFFT__FIS__ " seconds\n",t1-t0);
00061   fflush(stderr);
00062 
00063   /* cleanup */
00064   NFFT(finalize)(&p);
00065   FFTW(cleanup_threads)();
00066 
00067   return EXIT_SUCCESS;
00068 }