fastsum_benchomp_detail.c
/*
* Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <complex.h>
#include "nfft3.h"
#include "infft.h"
#include "fastsum.h"
#include "kernels.h"
#ifdef _OPENMP
#include <omp.h>
#endif
int bench_openmp(FILE *infile, int n, int m, int p,
C (*kernel)(R, int, const R *), R c, R eps_I, R eps_B)
{
fastsum_plan my_fastsum_plan;
int d, L, M;
int t, j;
R re, im;
R r_max = K(0.25) - my_fastsum_plan.eps_B / K(2.0);
ticks t0, t1;
R tt_total;
fscanf(infile, "%d %d %d", &d, &L, &M);
#ifdef _OPENMP
FFTW(import_wisdom_from_filename)("fastsum_benchomp_detail_threads.plan");
#else
FFTW(import_wisdom_from_filename)("fastsum_benchomp_detail_single.plan");
#endif
fastsum_init_guru(&my_fastsum_plan, d, L, M, kernel, &c, NEARFIELD_BOXES, n,
m, p, eps_I, eps_B);
#ifdef _OPENMP
FFTW(export_wisdom_to_filename)("fastsum_benchomp_detail_threads.plan");
#else
FFTW(export_wisdom_to_filename)("fastsum_benchomp_detail_single.plan");
#endif
for (j = 0; j < L; j++)
{
for (t = 0; t < d; t++)
{
R v;
fscanf(infile, __FR__, &v);
my_fastsum_plan.x[d * j + t] = v * r_max;
}
}
for (j = 0; j < L; j++)
{
fscanf(infile, __FR__ " " __FR__, &re, &im);
my_fastsum_plan.alpha[j] = re + II * im;
}
for (j = 0; j < M; j++)
{
for (t = 0; t < d; t++)
{
R v;
fscanf(infile, __FR__, &v);
my_fastsum_plan.y[d * j + t] = v * r_max;
}
}
t0 = getticks();
fastsum_precompute(&my_fastsum_plan);
fastsum_trafo(&my_fastsum_plan);
t1 = getticks();
tt_total = NFFT(elapsed_seconds)(t1, t0);
#ifndef MEASURE_TIME
my_fastsum_plan.MEASURE_TIME_t[0] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[1] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[2] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[3] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[4] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[5] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[6] = K(0.0);
my_fastsum_plan.MEASURE_TIME_t[7] = K(0.0);
my_fastsum_plan.mv1.MEASURE_TIME_t[0] = K(0.0);
my_fastsum_plan.mv1.MEASURE_TIME_t[2] = K(0.0);
my_fastsum_plan.mv2.MEASURE_TIME_t[0] = K(0.0);
my_fastsum_plan.mv2.MEASURE_TIME_t[2] = K(0.0);
#endif
#ifndef MEASURE_TIME_FFTW
my_fastsum_plan.mv1.MEASURE_TIME_t[1] = K(0.0);
my_fastsum_plan.mv2.MEASURE_TIME_t[1] = K(0.0);
#endif
printf(
"%.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",
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]);
fastsum_finalize(&my_fastsum_plan);
return 0;
}
int main(int argc, char **argv)
{
int n;
int m;
int p;
char *s;
C (*kernel)(R, int, const R *);
R c;
R eps_I;
R eps_B;
#ifdef _OPENMP
int nthreads;
if (argc != 9)
return EXIT_FAILURE;
nthreads = atoi(argv[8]);
FFTW(init_threads)();
omp_set_num_threads(nthreads);
#else
if (argc != 8)
return EXIT_FAILURE;
#endif
n = atoi(argv[1]);
m = atoi(argv[2]);
p = atoi(argv[3]);
s = argv[4];
c = atof(argv[5]);
eps_I = (R)(atof(argv[6]));
eps_B = (R)(atof(argv[7]));
if (strcmp(s, "gaussian") == 0)
kernel = gaussian;
else if (strcmp(s, "multiquadric") == 0)
kernel = multiquadric;
else if (strcmp(s, "inverse_multiquadric") == 0)
kernel = inverse_multiquadric;
else if (strcmp(s, "logarithm") == 0)
kernel = logarithm;
else if (strcmp(s, "thinplate_spline") == 0)
kernel = thinplate_spline;
else if (strcmp(s, "one_over_square") == 0)
kernel = one_over_square;
else if (strcmp(s, "one_over_modulus") == 0)
kernel = one_over_modulus;
else if (strcmp(s, "one_over_x") == 0)
kernel = one_over_x;
else if (strcmp(s, "inverse_multiquadric3") == 0)
kernel = inverse_multiquadric3;
else if (strcmp(s, "sinc_kernel") == 0)
kernel = sinc_kernel;
else if (strcmp(s, "cosc") == 0)
kernel = cosc;
else if (strcmp(s, "cot") == 0)
kernel = kcot;
else if (strcmp(s, "one_over_cube") == 0)
kernel = one_over_cube;
else if (strcmp(s, "log_sin") == 0)
kernel = log_sin;
else
{
s = "multiquadric";
kernel = multiquadric;
}
bench_openmp(stdin, n, m, p, kernel, c, eps_I, eps_B);
return EXIT_SUCCESS;
}
inverse_multiquadric3
C inverse_multiquadric3(R x, int der, const R *param)
K(x) = 1/sqrt(x^2+c^2)^3.
Definition: kernels.c:261
one_over_cube
C one_over_cube(R x, int der, const R *param)
K(x) = 1/x^3.
Definition: kernels.c:374
fastsum_plan_::eps_B
R eps_B
outer boundary
Definition: fastsum.h:114
gaussian
C gaussian(R x, int der, const R *param)
K(x)=exp(-x^2/c^2)
Definition: kernels.c:38
kernels.h
Header file with predefined kernels for the fast summation algorithm.
cosc
C cosc(R x, int der, const R *param)
K(x) = cos(cx)/x.
Definition: kernels.c:314
one_over_x
C one_over_x(R x, int der, const R *param)
K(x) = 1/x.
Definition: kernels.c:233
thinplate_spline
C thinplate_spline(R x, int der, const R *param)
K(x) = x^2 log |x|.
Definition: kernels.c:149
sinc_kernel
C sinc_kernel(R x, int der, const R *param)
K(x) = sin(cx)/x.
Definition: kernels.c:287
fastsum_plan_
plan for fast summation algorithm
Definition: fastsum.h:82
fastsum.h
Header file for the fast NFFT-based summation algorithm.
fastsum_plan_::alpha
C * alpha
source coefficients
Definition: fastsum.h:91
fastsum_trafo
void fastsum_trafo(fastsum_plan *ths)
fast NFFT-based summation
Definition: fastsum.c:1180
fastsum_precompute
void fastsum_precompute(fastsum_plan *ths)
precomputation for fastsum
Definition: fastsum.c:1173
one_over_square
C one_over_square(R x, int der, const R *param)
K(x) = 1/x^2.
Definition: kernels.c:177
one_over_modulus
C one_over_modulus(R x, int der, const R *param)
K(x) = 1/|x|.
Definition: kernels.c:205
fastsum_plan_::MEASURE_TIME_t
R MEASURE_TIME_t[8]
Measured time for each step if MEASURE_TIME is set.
Definition: fastsum.h:134
logarithm
C logarithm(R x, int der, const R *param)
K(x)=log |x|.
Definition: kernels.c:116
fastsum_init_guru
void fastsum_init_guru(fastsum_plan *ths, int d, int N_total, int M_total, kernel k, R *param, unsigned flags, int nn, int m, int p, R eps_I, R eps_B)
initialization of fastsum plan
Definition: fastsum.c:987
inverse_multiquadric
C inverse_multiquadric(R x, int der, const R *param)
K(x)=1/sqrt(x^2+c^2)
Definition: kernels.c:90
fastsum_plan_::y
R * y
target knots in d-ball with radius 1/4-eps_b/2
Definition: fastsum.h:95
kcot
C kcot(R x, int der, const R *param)
K(x) = cot(cx)
Definition: kernels.c:346
nfft3.h
Header file for the nfft3 library.
multiquadric
C multiquadric(R x, int der, const R *param)
K(x)=sqrt(x^2+c^2)
Definition: kernels.c:64
fastsum_finalize
void fastsum_finalize(fastsum_plan *ths)
finalization of fastsum plan
Definition: fastsum.c:1048
log_sin
C log_sin(R x, int der, const R *param)
K(x) = log(|sin(cx)|)
Definition: kernels.c:402
fastsum_plan_::x
R * x
source knots in d-ball with radius 1/4-eps_b/2
Definition: fastsum.h:94