NFFT 3.6.0
nfft/simple_test_threads.c
1/*
2 * Copyright (c) 2002, 2017 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#include <stdio.h>
19#include <math.h>
20#include <string.h>
21#include <stdlib.h>
22#include <omp.h>
23
24#include <sys/time.h>
25
26#define NFFT_PRECISION_DOUBLE
27
28#include "nfft3mp.h"
29
30int main(void)
31{
32 NFFT(plan) p;
33 const int N = 1000000;
34 const int M = 1000000;
35 NFFT_R t0, t1;
36
37 printf("nthreads = " NFFT__D__ "\n", NFFT(get_num_threads)());
38
39 /* init */
40 #ifdef HAVE_FFTW_THREADS
41 FFTW(init_threads)();
42 #endif
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 #ifdef HAVE_FFTW_THREADS
68 FFTW(cleanup_threads)();
69 #endif
70
71 return EXIT_SUCCESS;
72}
#define PRE_ONE_PSI
Definition nfft3.h:200