Commit 2ad915e8 authored by Mert Burkay Çöteli's avatar Mert Burkay Çöteli
Browse files

AIM integration 220621

parent adc6521c
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
#include "rdft/rdft.h"
X(plan) X(plan_many_dft_r2c)(int rank, const int *n,
int howmany,
R *in, const int *inembed,
int istride, int idist,
C *out, const int *onembed,
int ostride, int odist, unsigned flags)
{
R *ro, *io;
int *nfi, *nfo;
int inplace;
X(plan) p;
if (!X(many_kosherp)(rank, n, howmany)) return 0;
EXTRACT_REIM(FFT_SIGN, out, &ro, &io);
inplace = in == ro;
p = X(mkapiplan)(
0, flags,
X(mkproblem_rdft2_d_3pointers)(
X(mktensor_rowmajor)(
rank, n,
X(rdft2_pad)(rank, n, inembed, inplace, 0, &nfi),
X(rdft2_pad)(rank, n, onembed, inplace, 1, &nfo),
istride, 2 * ostride),
X(mktensor_1d)(howmany, idist, 2 * odist),
TAINT_UNALIGNED(in, flags),
TAINT_UNALIGNED(ro, flags), TAINT_UNALIGNED(io, flags),
R2HC));
X(ifree0)(nfi);
X(ifree0)(nfo);
return p;
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
#include "dft/dft.h"
#define N0(nembed)((nembed) ? (nembed) : n)
X(plan) X(plan_many_dft)(int rank, const int *n,
int howmany,
C *in, const int *inembed,
int istride, int idist,
C *out, const int *onembed,
int ostride, int odist, int sign, unsigned flags)
{
R *ri, *ii, *ro, *io;
if (!X(many_kosherp)(rank, n, howmany)) return 0;
EXTRACT_REIM(sign, in, &ri, &ii);
EXTRACT_REIM(sign, out, &ro, &io);
return
X(mkapiplan)(sign, flags,
X(mkproblem_dft_d)(
X(mktensor_rowmajor)(rank, n,
N0(inembed), N0(onembed),
2 * istride, 2 * ostride),
X(mktensor_1d)(howmany, 2 * idist, 2 * odist),
TAINT_UNALIGNED(ri, flags),
TAINT_UNALIGNED(ii, flags),
TAINT_UNALIGNED(ro, flags),
TAINT_UNALIGNED(io, flags)));
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
#include "rdft/rdft.h"
#define N0(nembed)((nembed) ? (nembed) : n)
X(plan) X(plan_many_r2r)(int rank, const int *n,
int howmany,
R *in, const int *inembed,
int istride, int idist,
R *out, const int *onembed,
int ostride, int odist,
const X(r2r_kind) * kind, unsigned flags)
{
X(plan) p;
rdft_kind *k;
if (!X(many_kosherp)(rank, n, howmany)) return 0;
k = X(map_r2r_kind)(rank, kind);
p = X(mkapiplan)(
0, flags,
X(mkproblem_rdft_d)(X(mktensor_rowmajor)(rank, n,
N0(inembed), N0(onembed),
istride, ostride),
X(mktensor_1d)(howmany, idist, odist),
TAINT_UNALIGNED(in, flags),
TAINT_UNALIGNED(out, flags), k));
X(ifree0)(k);
return p;
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
X(plan) X(plan_r2r_1d)(int n, R *in, R *out, X(r2r_kind) kind, unsigned flags)
{
return X(plan_r2r)(1, &n, in, out, &kind, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
X(plan) X(plan_r2r_2d)(int nx, int ny, R *in, R *out,
X(r2r_kind) kindx, X(r2r_kind) kindy, unsigned flags)
{
int n[2];
X(r2r_kind) kind[2];
n[0] = nx;
n[1] = ny;
kind[0] = kindx;
kind[1] = kindy;
return X(plan_r2r)(2, n, in, out, kind, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
X(plan) X(plan_r2r_3d)(int nx, int ny, int nz,
R *in, R *out, X(r2r_kind) kindx,
X(r2r_kind) kindy, X(r2r_kind) kindz, unsigned flags)
{
int n[3];
X(r2r_kind) kind[3];
n[0] = nx;
n[1] = ny;
n[2] = nz;
kind[0] = kindx;
kind[1] = kindy;
kind[2] = kindz;
return X(plan_r2r)(3, n, in, out, kind, flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
X(plan) X(plan_r2r)(int rank, const int *n, R *in, R *out,
const X(r2r_kind) * kind, unsigned flags)
{
return X(plan_many_r2r)(rank, n, 1, in, 0, 1, 1, out, 0, 1, 1, kind,
flags);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
char *X(sprint_plan)(const X(plan) p)
{
size_t cnt;
char *s;
plan *pln = p->pln;
printer *pr = X(mkprinter_cnt)(&cnt);
pln->adt->print(pln, pr);
X(printer_destroy)(pr);
s = (char *) malloc(sizeof(char) * (cnt + 1));
if (s) {
pr = X(mkprinter_str)(s);
pln->adt->print(pln, pr);
X(printer_destroy)(pr);
}
return s;
}
void X(fprint_plan)(const X(plan) p, FILE *output_file)
{
printer *pr = X(mkprinter_file)(output_file);
plan *pln = p->pln;
pln->adt->print(pln, pr);
X(printer_destroy)(pr);
}
void X(print_plan)(const X(plan) p)
{
X(fprint_plan)(p, stdout);
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 <string.h>
#include "api/api.h"
const int *X(rdft2_pad)(int rnk, const int *n, const int *nembed,
int inplace, int cmplx, int **nfree)
{
A(FINITE_RNK(rnk));
*nfree = 0;
if (!nembed && rnk > 0) {
if (inplace || cmplx) {
int *np = (int *) MALLOC(sizeof(int) * (unsigned)rnk, PROBLEMS);
memcpy(np, n, sizeof(int) * (unsigned)rnk);
np[rnk - 1] = (n[rnk - 1] / 2 + 1) * (1 + !cmplx);
nembed = *nfree = np;
} else
nembed = n;
}
return nembed;
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
static planner *plnr = 0;
/* create the planner for the rest of the API */
planner *X(the_planner)(void)
{
if (!plnr) {
plnr = X(mkplanner)();
X(configure_planner)(plnr);
}
return plnr;
}
void X(cleanup)(void)
{
if (plnr) {
X(planner_destroy)(plnr);
plnr = 0;
}
}
void X(set_timelimit)(double tlim)
{
/* PLNR is not necessarily initialized when this function is
called, so use X(the_planner)() */
X(the_planner)()->timelimit = tlim;
}
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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 "api/api.h"
const char X(cc)[] = FFTW_CC;
/* fftw <= 3.2.2 had special compiler flags for codelets, which are
not used anymore. We keep this variable around because it is part
of the ABI */
const char X(codelet_optim)[] = "";
const char X(version)[] = PACKAGE "-" PACKAGE_VERSION
#if HAVE_FMA
"-fma"
#endif
#if HAVE_SSE2
"-sse2"
#endif
/* Earlier versions of FFTW only provided 256-bit AVX, which meant
* it was important to also enable sse2 for best performance for
* short transforms. Since some programs check for this and warn
* the user, we explicitly add avx_128 to the suffix to emphasize
* that this version is more capable.
*/
#if HAVE_AVX
"-avx"
#endif
#if HAVE_AVX_128_FMA
"-avx_128_fma"
#endif
#if HAVE_AVX2
"-avx2-avx2_128"
#endif
#if HAVE_AVX512
"-avx512"
#endif
#if HAVE_KCVI
"-kcvi"
#endif
#if HAVE_ALTIVEC
"-altivec"
#endif
#if HAVE_VSX
"-vsx"
#endif
#if HAVE_NEON
"-neon"
#endif
#if defined(HAVE_GENERIC_SIMD128)
"-generic_simd128"
#endif
#if defined(HAVE_GENERIC_SIMD256)
"-generic_simd256"
#endif
;
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
*
* 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
*
*/
/* Fortran-like (e.g. as in BLAS) type prefixes for F77 interface */
#if defined(FFTW_SINGLE)
# define x77(name) CONCAT(sfftw_, name)
# define X77(NAME) CONCAT(SFFTW_, NAME)
#elif defined(FFTW_LDOUBLE)
/* FIXME: what is best? BLAS uses D..._X, apparently. Ugh. */
# define x77(name) CONCAT(lfftw_, name)
# define X77(NAME) CONCAT(LFFTW_, NAME)
#elif defined(FFTW_QUAD)
# define x77(name) CONCAT(qfftw_, name)
# define X77(NAME) CONCAT(QFFTW_, NAME)
#else
# define x77(name) CONCAT(dfftw_, name)
# define X77(NAME) CONCAT(DFFTW_, NAME)
#endif
/* If F77_FUNC is not defined and the user didn't explicitly specify
--disable-fortran, then make our best guess at default wrappers
(since F77_FUNC_EQUIV should not be defined in this case, we
will use both double-underscored g77 wrappers and single- or
non-underscored wrappers). This saves us from dealing with
complaints in the cases where the user failed to specify
an F77 compiler or wrapper detection failed for some reason. */
#if !defined(F77_FUNC) && !defined(DISABLE_FORTRAN)
# if (defined(_WIN32) || defined(__WIN32__)) && !defined(WINDOWS_F77_MANGLING)
# define WINDOWS_F77_MANGLING 1
# endif
# if defined(_AIX) || defined(__hpux) || defined(hpux)
# define F77_FUNC(a, A) a
# elif defined(CRAY) || defined(_CRAY) || defined(_UNICOS)
# define F77_FUNC(a, A) A
# else
# define F77_FUNC(a, A) a ## _
# endif
# define F77_FUNC_(a, A) a ## __
#endif
#if defined(WITH_G77_WRAPPERS) && !defined(DISABLE_FORTRAN)
# undef F77_FUNC_
# define F77_FUNC_(a, A) a ## __
# undef F77_FUNC_EQUIV
#endif
/* annoying Windows syntax for shared-library declarations */
#if defined(FFTW_DLL) && (defined(_WIN32) || defined(__WIN32__))
# define FFTW_VOIDFUNC __declspec(dllexport) void
#else
# define FFTW_VOIDFUNC void
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment