NFFT Logo 3.2.3
fastsum_benchomp_detail.c
1 /*
2  * Copyright (c) 2002, 2012 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: simple_test.c 3372 2009-10-21 06:04:05Z skunis $ */
20 
21 #include <stdio.h>
22 #include <math.h>
23 #include <string.h>
24 #include <stdlib.h>
25 #include <complex.h>
26 
27 #include "nfft3util.h"
28 #include "nfft3.h"
29 #include "infft.h"
30 #include "fastsum.h"
31 #include "kernels.h"
32 #ifdef _OPENMP
33 #include <omp.h>
34 #endif
35 
36 int bench_openmp(FILE *infile, int n, int m, int p, double _Complex (*kernel)(double , int , const double *), double c, double eps_I, double eps_B)
37 {
38  fastsum_plan my_fastsum_plan;
39  int d, L, M;
40  int t, j;
41  double re,im;
42  double r_max = 0.25 - my_fastsum_plan.eps_B/2.0;
43  ticks t0, t1;
44  double tt_total;
45 
46  fscanf(infile, "%d %d %d", &d, &L, &M);
47 
48 #ifdef _OPENMP
49  fftw_import_wisdom_from_filename("fastsum_benchomp_detail_threads.plan");
50 #else
51  fftw_import_wisdom_from_filename("fastsum_benchomp_detail_single.plan");
52 #endif
53 
54  fastsum_init_guru(&my_fastsum_plan, d, L, M, kernel, &c, NEARFIELD_BOXES, n, m, p, eps_I, eps_B);
55 
56 #ifdef _OPENMP
57  fftw_export_wisdom_to_filename("fastsum_benchomp_detail_threads.plan");
58 #else
59  fftw_export_wisdom_to_filename("fastsum_benchomp_detail_single.plan");
60 #endif
61 
62  for (j=0; j < L; j++)
63  {
64  for (t=0; t < d; t++)
65  {
66  double v;
67  fscanf(infile, "%lg", &v);
68  my_fastsum_plan.x[d*j+t] = v * r_max;
69  }
70  }
71 
72  for (j=0; j < L; j++)
73  {
74  fscanf(infile, "%lg %lg", &re, &im);
75  my_fastsum_plan.alpha[j] = re + _Complex_I * im;
76  }
77 
78  for (j=0; j < M; j++)
79  {
80  for (t=0; t < d; t++)
81  {
82  double v;
83  fscanf(infile, "%lg", &v);
84  my_fastsum_plan.y[d*j+t] = v * r_max;
85  }
86  }
87 
89  t0 = getticks();
90  fastsum_precompute(&my_fastsum_plan);
91 
93  fastsum_trafo(&my_fastsum_plan);
94  t1 = getticks();
95  tt_total = nfft_elapsed_seconds(t1,t0);
96 
97 #ifndef MEASURE_TIME
98  my_fastsum_plan.MEASURE_TIME_t[0] = 0.0;
99  my_fastsum_plan.MEASURE_TIME_t[1] = 0.0;
100  my_fastsum_plan.MEASURE_TIME_t[2] = 0.0;
101  my_fastsum_plan.MEASURE_TIME_t[3] = 0.0;
102  my_fastsum_plan.MEASURE_TIME_t[4] = 0.0;
103  my_fastsum_plan.MEASURE_TIME_t[5] = 0.0;
104  my_fastsum_plan.MEASURE_TIME_t[6] = 0.0;
105  my_fastsum_plan.MEASURE_TIME_t[7] = 0.0;
106  my_fastsum_plan.mv1.MEASURE_TIME_t[0] = 0.0;
107  my_fastsum_plan.mv1.MEASURE_TIME_t[2] = 0.0;
108  my_fastsum_plan.mv2.MEASURE_TIME_t[0] = 0.0;
109  my_fastsum_plan.mv2.MEASURE_TIME_t[2] = 0.0;
110 #endif
111 #ifndef MEASURE_TIME_FFTW
112  my_fastsum_plan.mv1.MEASURE_TIME_t[1] = 0.0;
113  my_fastsum_plan.mv2.MEASURE_TIME_t[1] = 0.0;
114 #endif
115 
116  printf("%.6e %.6e %.6e %6e %.6e %.6e %.6e %.6e %.6e %6e %.6e %.6e %6e %.6e %.6e %6e\n", my_fastsum_plan.MEASURE_TIME_t[0], my_fastsum_plan.MEASURE_TIME_t[1], my_fastsum_plan.MEASURE_TIME_t[2], my_fastsum_plan.MEASURE_TIME_t[3], my_fastsum_plan.MEASURE_TIME_t[4], my_fastsum_plan.MEASURE_TIME_t[5], my_fastsum_plan.MEASURE_TIME_t[6], my_fastsum_plan.MEASURE_TIME_t[7], tt_total-my_fastsum_plan.MEASURE_TIME_t[0]-my_fastsum_plan.MEASURE_TIME_t[1]-my_fastsum_plan.MEASURE_TIME_t[2]-my_fastsum_plan.MEASURE_TIME_t[3]-my_fastsum_plan.MEASURE_TIME_t[4]-my_fastsum_plan.MEASURE_TIME_t[5]-my_fastsum_plan.MEASURE_TIME_t[6]-my_fastsum_plan.MEASURE_TIME_t[7], tt_total, my_fastsum_plan.mv1.MEASURE_TIME_t[0], my_fastsum_plan.mv1.MEASURE_TIME_t[1], my_fastsum_plan.mv1.MEASURE_TIME_t[2], my_fastsum_plan.mv2.MEASURE_TIME_t[0], my_fastsum_plan.mv2.MEASURE_TIME_t[1], my_fastsum_plan.mv2.MEASURE_TIME_t[2]);
117 
118  fastsum_finalize(&my_fastsum_plan);
119 
120  return 0;
121 }
122 
123 int main(int argc, char **argv)
124 {
125  int n;
126  int m;
127  int p;
128  char *s;
129  double _Complex (*kernel)(double , int , const double *);
130  double c;
131  double eps_I;
132  double eps_B;
135 #ifdef _OPENMP
136  int nthreads;
137 
138  if (argc != 9)
139  return 1;
140 
141  nthreads = atoi(argv[8]);
142  fftw_init_threads();
143  omp_set_num_threads(nthreads);
144 #else
145  if (argc != 8)
146  return 1;
147 #endif
148 
149  n=atoi(argv[1]);
150  m=atoi(argv[2]);
151  p=atoi(argv[3]);
152  s=argv[4];
153  c=atof(argv[5]);
154  eps_I=atof(argv[6]);
155  eps_B=atof(argv[7]);
156  if (strcmp(s,"gaussian")==0)
157  kernel = gaussian;
158  else if (strcmp(s,"multiquadric")==0)
159  kernel = multiquadric;
160  else if (strcmp(s,"inverse_multiquadric")==0)
161  kernel = inverse_multiquadric;
162  else if (strcmp(s,"logarithm")==0)
163  kernel = logarithm;
164  else if (strcmp(s,"thinplate_spline")==0)
165  kernel = thinplate_spline;
166  else if (strcmp(s,"one_over_square")==0)
167  kernel = one_over_square;
168  else if (strcmp(s,"one_over_modulus")==0)
169  kernel = one_over_modulus;
170  else if (strcmp(s,"one_over_x")==0)
171  kernel = one_over_x;
172  else if (strcmp(s,"inverse_multiquadric3")==0)
173  kernel = inverse_multiquadric3;
174  else if (strcmp(s,"sinc_kernel")==0)
175  kernel = sinc_kernel;
176  else if (strcmp(s,"cosc")==0)
177  kernel = cosc;
178  else if (strcmp(s,"cot")==0)
179  kernel = kcot;
180  else
181  {
182  s="multiquadric";
183  kernel = multiquadric;
184  }
185 
186  bench_openmp(stdin, n, m, p, kernel, c, eps_I, eps_B);
187 
188  return 0;
189 }
190 

Generated on Tue Apr 30 2013 by Doxygen 1.8.1