![]() |
NFFT
3.3.2
|
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 00019 #include <stdio.h> 00020 #include <math.h> 00021 #include <string.h> 00022 #include <stdlib.h> 00023 #include <complex.h> 00024 00025 #include "nfft3.h" 00026 #include "infft.h" 00027 #include "fastsum.h" 00028 #include "kernels.h" 00029 #ifdef _OPENMP 00030 #include <omp.h> 00031 #endif 00032 00033 int bench_openmp(FILE *infile, int n, int m, int p, 00034 C (*kernel)(R, int, const R *), R c, R eps_I, R eps_B) 00035 { 00036 fastsum_plan my_fastsum_plan; 00037 int d, L, M; 00038 int t, j; 00039 R re, im; 00040 R r_max = K(0.25) - my_fastsum_plan.eps_B / K(2.0); 00041 ticks t0, t1; 00042 R tt_total; 00043 00044 fscanf(infile, "%d %d %d", &d, &L, &M); 00045 00046 #ifdef _OPENMP 00047 FFTW(import_wisdom_from_filename)("fastsum_benchomp_detail_threads.plan"); 00048 #else 00049 FFTW(import_wisdom_from_filename)("fastsum_benchomp_detail_single.plan"); 00050 #endif 00051 00052 fastsum_init_guru(&my_fastsum_plan, d, L, M, kernel, &c, NEARFIELD_BOXES, n, 00053 m, p, eps_I, eps_B); 00054 00055 #ifdef _OPENMP 00056 FFTW(export_wisdom_to_filename)("fastsum_benchomp_detail_threads.plan"); 00057 #else 00058 FFTW(export_wisdom_to_filename)("fastsum_benchomp_detail_single.plan"); 00059 #endif 00060 00061 for (j = 0; j < L; j++) 00062 { 00063 for (t = 0; t < d; t++) 00064 { 00065 R v; 00066 fscanf(infile, __FR__, &v); 00067 my_fastsum_plan.x[d * j + t] = v * r_max; 00068 } 00069 } 00070 00071 for (j = 0; j < L; j++) 00072 { 00073 fscanf(infile, __FR__ " " __FR__, &re, &im); 00074 my_fastsum_plan.alpha[j] = re + II * im; 00075 } 00076 00077 for (j = 0; j < M; j++) 00078 { 00079 for (t = 0; t < d; t++) 00080 { 00081 R v; 00082 fscanf(infile, __FR__, &v); 00083 my_fastsum_plan.y[d * j + t] = v * r_max; 00084 } 00085 } 00086 00088 t0 = getticks(); 00089 fastsum_precompute(&my_fastsum_plan); 00090 00092 fastsum_trafo(&my_fastsum_plan); 00093 t1 = getticks(); 00094 tt_total = NFFT(elapsed_seconds)(t1, t0); 00095 00096 #ifndef MEASURE_TIME 00097 my_fastsum_plan.MEASURE_TIME_t[0] = K(0.0); 00098 my_fastsum_plan.MEASURE_TIME_t[1] = K(0.0); 00099 my_fastsum_plan.MEASURE_TIME_t[2] = K(0.0); 00100 my_fastsum_plan.MEASURE_TIME_t[3] = K(0.0); 00101 my_fastsum_plan.MEASURE_TIME_t[4] = K(0.0); 00102 my_fastsum_plan.MEASURE_TIME_t[5] = K(0.0); 00103 my_fastsum_plan.MEASURE_TIME_t[6] = K(0.0); 00104 my_fastsum_plan.MEASURE_TIME_t[7] = K(0.0); 00105 my_fastsum_plan.mv1.MEASURE_TIME_t[0] = K(0.0); 00106 my_fastsum_plan.mv1.MEASURE_TIME_t[2] = K(0.0); 00107 my_fastsum_plan.mv2.MEASURE_TIME_t[0] = K(0.0); 00108 my_fastsum_plan.mv2.MEASURE_TIME_t[2] = K(0.0); 00109 #endif 00110 #ifndef MEASURE_TIME_FFTW 00111 my_fastsum_plan.mv1.MEASURE_TIME_t[1] = K(0.0); 00112 my_fastsum_plan.mv2.MEASURE_TIME_t[1] = K(0.0); 00113 #endif 00114 00115 printf( 00116 "%.6" __FES__ " %.6" __FES__ " %.6" __FES__ " %6" __FES__ " %.6" __FES__ " %.6" __FES__ " %.6" __FES__ " %.6" __FES__ " %.6" __FES__ " %6" __FES__ " %.6" __FES__ " %.6" __FES__ " %6" __FES__ " %.6" __FES__ " %.6" __FES__ " %6" __FES__ "\n", 00117 my_fastsum_plan.MEASURE_TIME_t[0], my_fastsum_plan.MEASURE_TIME_t[1], 00118 my_fastsum_plan.MEASURE_TIME_t[2], my_fastsum_plan.MEASURE_TIME_t[3], 00119 my_fastsum_plan.MEASURE_TIME_t[4], my_fastsum_plan.MEASURE_TIME_t[5], 00120 my_fastsum_plan.MEASURE_TIME_t[6], my_fastsum_plan.MEASURE_TIME_t[7], 00121 tt_total - my_fastsum_plan.MEASURE_TIME_t[0] 00122 - my_fastsum_plan.MEASURE_TIME_t[1] 00123 - my_fastsum_plan.MEASURE_TIME_t[2] 00124 - my_fastsum_plan.MEASURE_TIME_t[3] 00125 - my_fastsum_plan.MEASURE_TIME_t[4] 00126 - my_fastsum_plan.MEASURE_TIME_t[5] 00127 - my_fastsum_plan.MEASURE_TIME_t[6] 00128 - my_fastsum_plan.MEASURE_TIME_t[7], tt_total, 00129 my_fastsum_plan.mv1.MEASURE_TIME_t[0], 00130 my_fastsum_plan.mv1.MEASURE_TIME_t[1], 00131 my_fastsum_plan.mv1.MEASURE_TIME_t[2], 00132 my_fastsum_plan.mv2.MEASURE_TIME_t[0], 00133 my_fastsum_plan.mv2.MEASURE_TIME_t[1], 00134 my_fastsum_plan.mv2.MEASURE_TIME_t[2]); 00135 00136 fastsum_finalize(&my_fastsum_plan); 00137 00138 return 0; 00139 } 00140 00141 int main(int argc, char **argv) 00142 { 00143 int n; 00144 int m; 00145 int p; 00146 char *s; 00147 C (*kernel)(R, int, const R *); 00148 R c; 00149 R eps_I; 00150 R eps_B; 00152 #ifdef _OPENMP 00153 int nthreads; 00154 00155 if (argc != 9) 00156 return EXIT_FAILURE; 00157 00158 nthreads = atoi(argv[8]); 00159 FFTW(init_threads)(); 00160 omp_set_num_threads(nthreads); 00161 #else 00162 if (argc != 8) 00163 return EXIT_FAILURE; 00164 #endif 00165 00166 n = atoi(argv[1]); 00167 m = atoi(argv[2]); 00168 p = atoi(argv[3]); 00169 s = argv[4]; 00170 c = atof(argv[5]); 00171 eps_I = (R)(atof(argv[6])); 00172 eps_B = (R)(atof(argv[7])); 00173 if (strcmp(s, "gaussian") == 0) 00174 kernel = gaussian; 00175 else if (strcmp(s, "multiquadric") == 0) 00176 kernel = multiquadric; 00177 else if (strcmp(s, "inverse_multiquadric") == 0) 00178 kernel = inverse_multiquadric; 00179 else if (strcmp(s, "logarithm") == 0) 00180 kernel = logarithm; 00181 else if (strcmp(s, "thinplate_spline") == 0) 00182 kernel = thinplate_spline; 00183 else if (strcmp(s, "one_over_square") == 0) 00184 kernel = one_over_square; 00185 else if (strcmp(s, "one_over_modulus") == 0) 00186 kernel = one_over_modulus; 00187 else if (strcmp(s, "one_over_x") == 0) 00188 kernel = one_over_x; 00189 else if (strcmp(s, "inverse_multiquadric3") == 0) 00190 kernel = inverse_multiquadric3; 00191 else if (strcmp(s, "sinc_kernel") == 0) 00192 kernel = sinc_kernel; 00193 else if (strcmp(s, "cosc") == 0) 00194 kernel = cosc; 00195 else if (strcmp(s, "cot") == 0) 00196 kernel = kcot; 00197 else 00198 { 00199 s = "multiquadric"; 00200 kernel = multiquadric; 00201 } 00202 00203 bench_openmp(stdin, n, m, p, kernel, c, eps_I, eps_B); 00204 00205 return EXIT_SUCCESS; 00206 } 00207