NFFT  3.3.0
nfft/simple_test_threads.c
1 /*
2  * Copyright (c) 2002, 2015 Jens Keiner, Stefan Kunis, Daniel Potts
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 /* $Id$ */
20 #include <stdio.h>
21 #include <math.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <omp.h>
25 
26 #include <sys/time.h>
27 
28 #define NFFT_PRECISION_DOUBLE
29 
30 #include "nfft3mp.h"
31 
32 int main(void)
33 {
34  NFFT(plan) p;
35  const int N = 1000000;
36  const int M = 1000000;
37  NFFT_R t0, t1;
38 
39  printf("nthreads = %td\n", NFFT(get_num_threads)());
40 
41  /* init */
42  FFTW(init_threads)();
43  NFFT(init_1d)(&p,N,M);
44 
45  /* pseudo random nodes */
46  NFFT(vrand_shifted_unit_double)(p.x,p.M_total);
47 
48  /* precompute psi, that is, the entries of the matrix B */
49  t0 = NFFT(clock_gettime_seconds)();
50  if(p.flags & PRE_ONE_PSI)
51  NFFT(precompute_one_psi)(&p);
52  t1 = NFFT(clock_gettime_seconds)();
53  fprintf(stderr,"precompute elapsed time: %.3" NFFT__FIS__ " seconds\n",t1-t0);
54 
55  /* pseudo random Fourier coefficients */
56  NFFT(vrand_unit_complex)(p.f_hat,p.N_total);
57 
58  /* transformation */
59  t0 = NFFT(clock_gettime_seconds)();
60  NFFT(trafo)(&p);
61  t1 = NFFT(clock_gettime_seconds)();
62  fprintf(stderr,"compute elapsed time: %.3" NFFT__FIS__ " seconds\n",t1-t0);
63  fflush(stderr);
64 
65  /* cleanup */
66  NFFT(finalize)(&p);
67  FFTW(cleanup_threads)();
68 
69  return EXIT_SUCCESS;
70 }