diff options
author | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
---|---|---|
committer | scuri <scuri> | 2008-10-17 06:10:15 +0000 |
commit | 5a422aba704c375a307a902bafe658342e209906 (patch) | |
tree | 5005011e086bb863d8fb587ad3319bbec59b2447 /src/fftw3/api |
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'src/fftw3/api')
62 files changed, 3557 insertions, 0 deletions
diff --git a/src/fftw3/api/api.h b/src/fftw3/api/api.h new file mode 100644 index 0000000..6b37151 --- /dev/null +++ b/src/fftw3/api/api.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* internal API definitions */ +#ifndef __API_H__ +#define __API_H__ + +/* just in case: force <fftw3.h> not to use C99 complex numbers */ +#undef _Complex_I + +#include "fftw3.h" +#include "ifftw.h" + +/* the API ``plan'' contains both the kernel plan and problem */ +struct X(plan_s) { + plan *pln; + problem *prb; + int sign; +}; + +/* shorthand */ +typedef struct X(plan_s) apiplan; + +/* complex type for internal use */ +typedef R C[2]; + +void X(extract_reim)(int sign, C *c, R **r, R **i); + +#define TAINT_UNALIGNED(p, flg) TAINT(p, ((flg) & FFTW_UNALIGNED) != 0) + +tensor *X(mktensor_rowmajor)(int rnk, const int *n, + const int *niphys, const int *nophys, + int is, int os); + +tensor *X(mktensor_iodims)(int rank, const X(iodim) *dims, int is, int os); +const int *X(rdft2_pad)(int rnk, const int *n, const int *nembed, + int inplace, int cmplx, int **nfree); + +int X(many_kosherp)(int rnk, const int *n, int howmany); +int X(guru_kosherp)(int rank, const X(iodim) *dims, + int howmany_rank, const X(iodim) *howmany_dims); + + +printer *X(mkprinter_file)(FILE *f); + +planner *X(the_planner)(void); +void X(configure_planner)(planner *plnr); + +void X(mapflags)(planner *, unsigned); + +apiplan *X(mkapiplan)(int sign, unsigned flags, problem *prb); + +#endif /* __API_H__ */ diff --git a/src/fftw3/api/apiplan.c b/src/fftw3/api/apiplan.c new file mode 100644 index 0000000..b9fee6b --- /dev/null +++ b/src/fftw3/api/apiplan.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + + +apiplan *X(mkapiplan)(int sign, unsigned flags, problem *prb) +WITH_ALIGNED_STACK({ + plan *pln; + plan *pln0; + apiplan *p = 0; + planner *plnr = X(the_planner)(); + + /* map API flags into FFTW flags */ + X(mapflags)(plnr, flags); + + /* create plan */ + plnr->planner_flags &= ~BLESSING; + pln = plnr->adt->mkplan(plnr, prb); + + if (pln) { + AWAKE(pln, 1); + + /* build apiplan */ + p = (apiplan *) MALLOC(sizeof(apiplan), PLANS); + p->pln = pln; + p->prb = prb; + p->sign = sign; /* cache for execute_dft */ + + /* blessing protocol */ + plnr->planner_flags |= BLESSING; + pln0 = plnr->adt->mkplan(plnr, prb); + X(plan_destroy_internal)(pln0); + } else { + X(problem_destroy)(prb); + } + + /* discard all information not necessary to reconstruct the + plan */ + plnr->adt->forget(plnr, FORGET_ACCURSED); + + return p; +}) + +void X(destroy_plan)(X(plan) p) +{ + if (p) { + AWAKE(p->pln, 0); + X(plan_destroy_internal)(p->pln); + X(problem_destroy)(p->prb); + X(ifree)(p); + } +} diff --git a/src/fftw3/api/config.h b/src/fftw3/api/config.h new file mode 100644 index 0000000..e97bf0d --- /dev/null +++ b/src/fftw3/api/config.h @@ -0,0 +1,301 @@ +/* configuration file for the IM_FFTW3 library */ + +/* extra CFLAGS for codelets */ +#define CODELET_OPTIM "" + +/* Define to a macro mangling the given C identifier (in lower and upper + case), which must not contain underscores, for linking with Fortran. */ +#undef F77_FUNC + +/* As F77_FUNC, but for C identifiers containing underscores. */ +#undef F77_FUNC_ + +/* Define if F77_FUNC and F77_FUNC_ are equivalent. */ +#undef F77_FUNC_EQUIV + +/* C compiler name and flags */ +#define FFTW_CC "" + +/* Define to enable extra FFTW debugging code. */ +#undef FFTW_DEBUG + +/* Define to enable alignment debugging hacks. */ +#undef FFTW_DEBUG_ALIGNMENT + +/* Define to enable debugging malloc. */ +#undef FFTW_DEBUG_MALLOC + +/* enable fast, unsafe modular multiplications, risking overflow for large + prime sizes */ +#undef FFTW_ENABLE_UNSAFE_MULMOD + +/* Define to compile in long-double precision. */ +#undef FFTW_LDOUBLE + +/* Define to compile in single precision. */ +#define FFTW_SINGLE 1 + +/* Define to enable 3DNow! optimizations. */ +#undef HAVE_3DNOW + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to enable Altivec optimizations. */ +#undef HAVE_ALTIVEC + +/* Define to 1 if you have the `BSDgettimeofday' function. */ +#undef HAVE_BSDGETTIMEOFDAY + +/* Define to 1 if you have the `clock_gettime' function. */ +#undef HAVE_CLOCK_GETTIME + +/* Define to 1 if you have the `cosl' function. */ +#undef HAVE_COSL + +/* Define to 1 if you have the <c_asm.h> header file. */ +#undef HAVE_C_ASM_H + +/* Define to 1 if you have the declaration of `drand48', and to 0 if you don't. */ +#define HAVE_DECL_DRAND48 0 + +/* Define to 1 if you have the declaration of `memalign', and to 0 if you + don't. */ +#define HAVE_DECL_MEMALIGN 0 + +/* Define to 1 if you have the declaration of `posix_memalign', and to 0 if + you don't. */ +#define HAVE_DECL_POSIX_MEMALIGN 0 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the `drand48' function. */ +#undef HAVE_DRAND48 + +/* Define to 1 if you have the `gethrtime' function. */ +#undef HAVE_GETHRTIME + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if hrtime_t is defined in <sys/time.h> */ +#undef HAVE_HRTIME_T + +/* Define to 1 if you have the <intrinsics.h> header file. */ +#undef HAVE_INTRINSICS_H + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define if the isnan() function/macro is available. */ +#define HAVE_ISNAN 1 + +/* Define to enable AMD K7 optimizations. */ +#undef HAVE_K7 + +/* Define to 1 if you have the <libintl.h> header file. */ +#undef HAVE_LIBINTL_H + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <malloc.h> header file. */ +/* #define HAVE_MALLOC_H 1 */ + +/* Define to 1 if you have the `memalign' function. */ +#undef HAVE_MEMALIGN + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `posix_memalign' function. */ +#undef HAVE_POSIX_MEMALIGN + +/* Define if you have POSIX threads libraries and header files. */ +#undef HAVE_PTHREAD + +/* Define to 1 if you have the `read_real_time' function. */ +#undef HAVE_READ_REAL_TIME + +/* Define to 1 if you have the `sinl' function. */ +#define HAVE_SINL 1 + +/* Define to 1 if you have the `sqrt' function. */ +#define HAVE_SQRT 1 + +/* Define to enable SSE optimizations. */ +#undef HAVE_SSE +/*#define HAVE_SSE 1 */ + +/* Define to enable SSE2 optimizations. */ +#undef HAVE_SSE2 + +/* Define to 1 if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `tanl' function. */ +#define HAVE_TANL 1 + +/* Define if we have a threads library. */ +#undef HAVE_THREADS + +/* Define to 1 if you have the `time_base_to_time' function. */ +#undef HAVE_TIME_BASE_TO_TIME + +/* Define to 1 if the system has the type `uintptr_t'. */ +/* #undef HAVE_UINTPTR_T */ + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF + +/* Define to 1 if you have the `_mm_free' function. */ +#undef HAVE__MM_FREE + +/* Define to 1 if you have the `_mm_malloc' function. */ +#undef HAVE__MM_MALLOC + +/* Define if you have the UNICOS _rtc() intrinsic. */ +#undef HAVE__RTC + +/* Name of package */ +#define PACKAGE "FFTW" + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "FFTW_PACKAGENAME" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "FFTW V3" + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#define PACKAGE_VERSION 3 + +/* Define to the necessary symbol if this constant uses a non-standard name on + your system. */ +#undef PTHREAD_CREATE_JOINABLE + +/* The size of a `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of a `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of a `long long', as computed by sizeof. */ +#undef SIZEOF_LONG_LONG /* NO LONG LONG IN VC++ */ + +/* The size of a `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* The size of a `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 4 + +/* The size of a `unsigned long long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG_LONG + +/* The size of a `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#undef TIME_WITH_SYS_TIME + +/* Define if we have and are using OpenMP multithreading directives */ +#undef USING_OPENMP_THREADS + +/* Define if we have and are using POSIX threads. */ +#undef USING_POSIX_THREADS + +/* Version number of package */ +#define VERSION "3" + +/* Use common Windows Fortran mangling styles for the Fortran interfaces. */ +#undef WINDOWS_F77_MANGLING + +/* Use our own 16-byte aligned malloc routine; mainly helpful for Windows + systems lacking aligned allocation system-library routines. */ +#undef WITHOUT_CYCLE_COUNTER + +/* Use our own 16-byte aligned malloc routine; mainly helpful for Windows + systems lacking aligned allocation system-library routines. */ +#define WITH_OUR_MALLOC16 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +#define inline __inline + +/* Define to `unsigned' if <sys/types.h> does not define. */ +#undef size_t + +/* VC++ specific parameters */ +/* added May14th 2003, S.Ruel */ +#define HAVE_CONFIG_H 1 +#define isnan _isnan +#define __inline__ __inline +#define __asm__ __asm + +/* The intel and processor pack libraries should be compatible */ +#ifdef _MSC_VER +#define __ICC 1 +#endif diff --git a/src/fftw3/api/configure.c b/src/fftw3/api/configure.c new file mode 100644 index 0000000..995281b --- /dev/null +++ b/src/fftw3/api/configure.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" +#include "rdft.h" +#include "reodft.h" + +void X(configure_planner)(planner *plnr) +{ + X(dft_conf_standard)(plnr); + X(rdft_conf_standard)(plnr); + X(reodft_conf_standard)(plnr); +} diff --git a/src/fftw3/api/execute-dft-c2r.c b/src/fftw3/api/execute-dft-c2r.c new file mode 100644 index 0000000..18b0749 --- /dev/null +++ b/src/fftw3/api/execute-dft-c2r.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +/* guru interface: requires care in alignment, r - i, etcetera. */ +void X(execute_dft_c2r)(const X(plan) p, C *in, R *out) +WITH_ALIGNED_STACK({ + plan_rdft2 *pln = (plan_rdft2 *) p->pln; + pln->apply((plan *) pln, out, in[0], in[0]+1); +}) diff --git a/src/fftw3/api/execute-dft-r2c.c b/src/fftw3/api/execute-dft-r2c.c new file mode 100644 index 0000000..1f4818f --- /dev/null +++ b/src/fftw3/api/execute-dft-r2c.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +/* guru interface: requires care in alignment, r - i, etcetera. */ +void X(execute_dft_r2c)(const X(plan) p, R *in, C *out) +WITH_ALIGNED_STACK({ + plan_rdft2 *pln = (plan_rdft2 *) p->pln; + pln->apply((plan *) pln, in, out[0], out[0]+1); +}) diff --git a/src/fftw3/api/execute-dft.c b/src/fftw3/api/execute-dft.c new file mode 100644 index 0000000..67fc9b8 --- /dev/null +++ b/src/fftw3/api/execute-dft.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" + +/* guru interface: requires care in alignment etcetera. */ +void X(execute_dft)(const X(plan) p, C *in, C *out) +WITH_ALIGNED_STACK({ + plan_dft *pln = (plan_dft *) p->pln; + if (p->sign == FFT_SIGN) + pln->apply((plan *) pln, in[0], in[0]+1, out[0], out[0]+1); + else + pln->apply((plan *) pln, in[0]+1, in[0], out[0]+1, out[0]); +}) diff --git a/src/fftw3/api/execute-r2r.c b/src/fftw3/api/execute-r2r.c new file mode 100644 index 0000000..d05f4ef --- /dev/null +++ b/src/fftw3/api/execute-r2r.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +/* guru interface: requires care in alignment, etcetera. */ +void X(execute_r2r)(const X(plan) p, R *in, R *out) +WITH_ALIGNED_STACK({ + plan_rdft *pln = (plan_rdft *) p->pln; + pln->apply((plan *) pln, in, out); +}) diff --git a/src/fftw3/api/execute-split-dft-c2r.c b/src/fftw3/api/execute-split-dft-c2r.c new file mode 100644 index 0000000..5941436 --- /dev/null +++ b/src/fftw3/api/execute-split-dft-c2r.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +/* guru interface: requires care in alignment, r - i, etcetera. */ +void X(execute_split_dft_c2r)(const X(plan) p, R *ri, R *ii, R *out) +WITH_ALIGNED_STACK({ + plan_rdft2 *pln = (plan_rdft2 *) p->pln; + pln->apply((plan *) pln, out, ri, ii); +}) diff --git a/src/fftw3/api/execute-split-dft-r2c.c b/src/fftw3/api/execute-split-dft-r2c.c new file mode 100644 index 0000000..72eccb8 --- /dev/null +++ b/src/fftw3/api/execute-split-dft-r2c.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +/* guru interface: requires care in alignment, r - i, etcetera. */ +void X(execute_split_dft_r2c)(const X(plan) p, R *in, R *ro, R *io) +WITH_ALIGNED_STACK({ + plan_rdft2 *pln = (plan_rdft2 *) p->pln; + pln->apply((plan *) pln, in, ro, io); +}) diff --git a/src/fftw3/api/execute-split-dft.c b/src/fftw3/api/execute-split-dft.c new file mode 100644 index 0000000..4c226a9 --- /dev/null +++ b/src/fftw3/api/execute-split-dft.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" + +/* guru interface: requires care in alignment, r - i, etcetera. */ +void X(execute_split_dft)(const X(plan) p, R *ri, R *ii, R *ro, R *io) +WITH_ALIGNED_STACK({ + plan_dft *pln = (plan_dft *) p->pln; + pln->apply((plan *) pln, ri, ii, ro, io); +}) diff --git a/src/fftw3/api/execute.c b/src/fftw3/api/execute.c new file mode 100644 index 0000000..f995c1c --- /dev/null +++ b/src/fftw3/api/execute.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +void X(execute)(const X(plan) p) +WITH_ALIGNED_STACK({ + plan *pln = p->pln; + pln->adt->solve(pln, p->prb); +}) diff --git a/src/fftw3/api/export-wisdom-to-file.c b/src/fftw3/api/export-wisdom-to-file.c new file mode 100644 index 0000000..769f1b4 --- /dev/null +++ b/src/fftw3/api/export-wisdom-to-file.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +void X(export_wisdom_to_file)(FILE *output_file) +{ + printer *p = X(mkprinter_file)(output_file); + planner *plnr = X(the_planner)(); + plnr->adt->exprt(plnr, p); + X(printer_destroy)(p); +} diff --git a/src/fftw3/api/export-wisdom-to-string.c b/src/fftw3/api/export-wisdom-to-string.c new file mode 100644 index 0000000..df38b51 --- /dev/null +++ b/src/fftw3/api/export-wisdom-to-string.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +typedef struct { + printer super; + int *cnt; +} P_cnt; + +static void putchr_cnt(printer * p_, char c) +{ + P_cnt *p = (P_cnt *) p_; + UNUSED(c); + ++*p->cnt; +} + +static printer *mkprinter_cnt(int *cnt) +{ + P_cnt *p = (P_cnt *) X(mkprinter)(sizeof(P_cnt), putchr_cnt, 0); + p->cnt = cnt; + *cnt = 0; + return &p->super; +} + +typedef struct { + printer super; + char *s; +} P_str; + +static void putchr_str(printer * p_, char c) +{ + P_str *p = (P_str *) p_; + *p->s++ = c; + *p->s = 0; +} + +static printer *mkprinter_str(char *s) +{ + P_str *p = (P_str *) X(mkprinter)(sizeof(P_str), putchr_str, 0); + p->s = s; + *s = 0; + return &p->super; +} + +char *X(export_wisdom_to_string)(void) +{ + printer *p; + planner *plnr = X(the_planner)(); + int cnt; + char *s; + + p = mkprinter_cnt(&cnt); + plnr->adt->exprt(plnr, p); + X(printer_destroy)(p); + + s = (char *) NATIVE_MALLOC(sizeof(char) * (cnt + 1), OTHER); + if (s) { + p = mkprinter_str(s); + plnr->adt->exprt(plnr, p); + X(printer_destroy)(p); + } + + return s; +} diff --git a/src/fftw3/api/export-wisdom.c b/src/fftw3/api/export-wisdom.c new file mode 100644 index 0000000..d05c067 --- /dev/null +++ b/src/fftw3/api/export-wisdom.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +typedef struct { + printer super; + void (*write_char)(char c, void *); + void *data; +} P; + +static void putchr_generic(printer * p_, char c) +{ + P *p = (P *) p_; + (p->write_char)(c, p->data); +} + +void X(export_wisdom)(void (*write_char)(char c, void *), void *data) +{ + P *p = (P *) X(mkprinter)(sizeof(P), putchr_generic, 0); + planner *plnr = X(the_planner)(); + + p->write_char = write_char; + p->data = data; + plnr->adt->exprt(plnr, (printer *) p); + X(printer_destroy)((printer *) p); +} diff --git a/src/fftw3/api/extract-reim.c b/src/fftw3/api/extract-reim.c new file mode 100644 index 0000000..3a90ab5 --- /dev/null +++ b/src/fftw3/api/extract-reim.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +/* decompose complex pointer into real and imaginary parts. + Flip real and imaginary if there the sign does not match + FFTW's idea of what the sign should be */ + +void X(extract_reim)(int sign, C *c, R **r, R **i) +{ + if (sign == FFT_SIGN) { + *r = c[0] + 0; + *i = c[0] + 1; + } else { + *r = c[0] + 1; + *i = c[0] + 0; + } +} diff --git a/src/fftw3/api/f77api.c b/src/fftw3/api/f77api.c new file mode 100644 index 0000000..3f70716 --- /dev/null +++ b/src/fftw3/api/f77api.c @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" +#include "rdft.h" + +/* if F77_FUNC is not defined, then we don't know how to mangle identifiers + for the Fortran linker, and we must omit the f77 API. */ +#if defined(F77_FUNC) || defined(WINDOWS_F77_MANGLING) + +/*-----------------------------------------------------------------------*/ +/* some internal functions used by the f77 api */ + +/* in fortran, the natural array ordering is column-major, which + corresponds to reversing the dimensions relative to C's row-major */ +static int *reverse_n(int rnk, const int *n) +{ + int *nrev; + int i; + A(FINITE_RNK(rnk)); + nrev = (int *) MALLOC(sizeof(int) * rnk, PROBLEMS); + for (i = 0; i < rnk; ++i) + nrev[rnk - i - 1] = n[i]; + return nrev; +} + +/* f77 doesn't have data structures, so we have to pass iodims as + parallel arrays */ +static X(iodim) *make_dims(int rnk, const int *n, + const int *is, const int *os) +{ + X(iodim) *dims; + int i; + A(FINITE_RNK(rnk)); + dims = (X(iodim) *) MALLOC(sizeof(X(iodim)) * rnk, PROBLEMS); + for (i = 0; i < rnk; ++i) { + dims[i].n = n[i]; + dims[i].is = is[i]; + dims[i].os = os[i]; + } + return dims; +} + +typedef struct { + void (*f77_write_char)(char *, void *); + void *data; +} write_char_data; + +static void write_char(char c, void *d) +{ + write_char_data *ad = (write_char_data *) d; + ad->f77_write_char(&c, ad->data); +} + +typedef struct { + void (*f77_read_char)(int *, void *); + void *data; +} read_char_data; + +static int read_char(void *d) +{ + read_char_data *ed = (read_char_data *) d; + int c; + ed->f77_read_char(&c, ed->data); + return (c < 0 ? EOF : c); +} + +static X(r2r_kind) *ints2kinds(int rnk, const int *ik) +{ + if (!FINITE_RNK(rnk) || rnk == 0) + return 0; + else { + int i; + X(r2r_kind) *k; + + k = (X(r2r_kind) *) MALLOC(sizeof(X(r2r_kind)) * rnk, PROBLEMS); + /* reverse order for Fortran -> C */ + for (i = 0; i < rnk; ++i) + k[i] = (X(r2r_kind)) ik[rnk - 1 - i]; + return k; + } +} + +/*-----------------------------------------------------------------------*/ + +#include "x77.h" + +#define F77(a, A) F77x(x77(a), X77(A)) + +#ifndef WINDOWS_F77_MANGLING + +#if defined(F77_FUNC) +# define F77x(a, A) F77_FUNC(a, A) +# include "f77funcs.h" +#endif + +/* If identifiers with underscores are mangled differently than those + without underscores, then we include *both* mangling versions. The + reason is that the only Fortran compiler that does such differing + mangling is currently g77 (which adds an extra underscore to names + with underscores), whereas other compilers running on the same + machine are likely to use g77's non-underscored mangling. (I'm sick + of users complaining that FFTW works with g77 but not with e.g. + pgf77 or ifc on the same machine.) Note that all FFTW identifiers + contain underscores, and configure picks g77 by default. */ +#if defined(F77_FUNC_) && !defined(F77_FUNC_EQUIV) +# undef F77x +# define F77x(a, A) F77_FUNC_(a, A) +# include "f77funcs.h" +#endif + +#else /* WINDOWS_F77_MANGLING */ + +/* Various mangling conventions common (?) under Windows. */ + +/* g77 */ +# define WINDOWS_F77_FUNC(a, A) a ## __ +# define F77x(a, A) WINDOWS_F77_FUNC(a, A) +# include "f77funcs.h" + +/* Digital/Compaq/HP Visual Fortran, Intel Fortran. stdcall attribute + is apparently required to adjust for calling conventions (callee + pops stack in stdcall). See also: + http://msdn.microsoft.com/library/en-us/vccore98/html/_core_mixed.2d.language_programming.3a_.overview.asp +*/ +# undef WINDOWS_F77_FUNC +# if defined(__GNUC__) +# define WINDOWS_F77_FUNC(a, A) __attribute__((stdcall)) A +# elif defined(_MSC_VER) || defined(_ICC) || defined(_STDCALL_SUPPORTED) +# define WINDOWS_F77_FUNC(a, A) __stdcall A +# else +# define WINDOWS_F77_FUNC(a, A) A /* oh well */ +# endif +# include "f77funcs.h" + +#endif /* WINDOWS_F77_MANGLING */ + +#endif /* F77_FUNC */ diff --git a/src/fftw3/api/f77funcs.h b/src/fftw3/api/f77funcs.h new file mode 100644 index 0000000..ea0dd5c --- /dev/null +++ b/src/fftw3/api/f77funcs.h @@ -0,0 +1,438 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* Functions in the FFTW Fortran API, mangled according to the + F77(...) macro. This file is designed to be #included by + f77api.c, possibly multiple times in order to support multiple + compiler manglings (via redefinition of F77). */ + +void F77(execute, EXECUTE)(X(plan) * const p) +WITH_ALIGNED_STACK({ + plan *pln = (*p)->pln; + pln->adt->solve(pln, (*p)->prb); +}) + +void F77(destroy_plan, DESTROY_PLAN)(X(plan) *p) +{ + X(destroy_plan)(*p); +} + +void F77(cleanup, CLEANUP)(void) +{ + X(cleanup)(); +} + +void F77(forget_wisdom, FORGET_WISDOM)(void) +{ + X(forget_wisdom)(); +} + +void F77(export_wisdom, EXPORT_WISDOM)(void (*f77_write_char)(char *, void *), + void *data) +{ + write_char_data ad; + ad.f77_write_char = f77_write_char; + ad.data = data; + X(export_wisdom)(write_char, (void *) &ad); +} + +void F77(import_wisdom, IMPORT_WISDOM)(int *isuccess, + void (*f77_read_char)(int *, void *), + void *data) +{ + read_char_data ed; + ed.f77_read_char = f77_read_char; + ed.data = data; + *isuccess = X(import_wisdom)(read_char, (void *) &ed); +} + +void F77(import_system_wisdom, IMPORT_SYSTEM_WISDOM)(int *isuccess) +{ + *isuccess = X(import_system_wisdom)(); +} + +void F77(print_plan, PRINT_PLAN)(X(plan) * const p) +{ + X(print_plan)(*p); +} + +void F77(flops,FLOPS)(X(plan) *p, double *add, double *mul, double *fma) +{ + X(flops)(*p, add, mul, fma); +} + +/******************************** DFT ***********************************/ + +void F77(plan_dft, PLAN_DFT)(X(plan) *p, int *rank, const int *n, + C *in, C *out, int *sign, int *flags) +{ + int *nrev = reverse_n(*rank, n); + *p = X(plan_dft)(*rank, nrev, in, out, *sign, *flags); + X(ifree0)(nrev); +} + +void F77(plan_dft_1d, PLAN_DFT_1D)(X(plan) *p, int *n, C *in, C *out, + int *sign, int *flags) +{ + *p = X(plan_dft_1d)(*n, in, out, *sign, *flags); +} + +void F77(plan_dft_2d, PLAN_DFT_2D)(X(plan) *p, int *nx, int *ny, + C *in, C *out, int *sign, int *flags) +{ + *p = X(plan_dft_2d)(*ny, *nx, in, out, *sign, *flags); +} + +void F77(plan_dft_3d, PLAN_DFT_3D)(X(plan) *p, int *nx, int *ny, int *nz, + C *in, C *out, + int *sign, int *flags) +{ + *p = X(plan_dft_3d)(*nz, *ny, *nx, in, out, *sign, *flags); +} + +void F77(plan_many_dft, PLAN_MANY_DFT)(X(plan) *p, 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, int *flags) +{ + int *nrev = reverse_n(*rank, n); + int *inembedrev = reverse_n(*rank, inembed); + int *onembedrev = reverse_n(*rank, onembed); + *p = X(plan_many_dft)(*rank, nrev, *howmany, + in, inembedrev, *istride, *idist, + out, onembedrev, *ostride, *odist, + *sign, *flags); + X(ifree0)(onembedrev); + X(ifree0)(inembedrev); + X(ifree0)(nrev); +} + +void F77(plan_guru_dft, PLAN_GURU_DFT)(X(plan) *p, int *rank, const int *n, + const int *is, const int *os, + int *howmany_rank, const int *h_n, + const int *h_is, const int *h_os, + C *in, C *out, int *sign, int *flags) +{ + X(iodim) *dims = make_dims(*rank, n, is, os); + X(iodim) *howmany_dims = make_dims(*howmany_rank, h_n, h_is, h_os); + *p = X(plan_guru_dft)(*rank, dims, *howmany_rank, howmany_dims, + in, out, *sign, *flags); + X(ifree0)(howmany_dims); + X(ifree0)(dims); +} + +void F77(plan_guru_split_dft, PLAN_GURU_SPLIT_DFT)(X(plan) *p, int *rank, const int *n, + const int *is, const int *os, + int *howmany_rank, const int *h_n, + const int *h_is, const int *h_os, + R *ri, R *ii, R *ro, R *io, int *flags) +{ + X(iodim) *dims = make_dims(*rank, n, is, os); + X(iodim) *howmany_dims = make_dims(*howmany_rank, h_n, h_is, h_os); + *p = X(plan_guru_split_dft)(*rank, dims, *howmany_rank, howmany_dims, + ri, ii, ro, io, *flags); + X(ifree0)(howmany_dims); + X(ifree0)(dims); +} + +void F77(execute_dft, EXECUTE_DFT)(X(plan) * const p, C *in, C *out) +WITH_ALIGNED_STACK({ + plan_dft *pln = (plan_dft *) (*p)->pln; + if ((*p)->sign == FFT_SIGN) + pln->apply((plan *) pln, in[0], in[0]+1, out[0], out[0]+1); + else + pln->apply((plan *) pln, in[0]+1, in[0], out[0]+1, out[0]); +}) + +void F77(execute_split_dft, EXECUTE_SPLIT_DFT)(X(plan) * const p, + R *ri, R *ii, R *ro, R *io) +WITH_ALIGNED_STACK({ + plan_dft *pln = (plan_dft *) (*p)->pln; + pln->apply((plan *) pln, ri, ii, ro, io); +}) + +/****************************** DFT r2c *********************************/ + +void F77(plan_dft_r2c, PLAN_DFT_R2C)(X(plan) *p, int *rank, const int *n, + R *in, C *out, int *flags) +{ + int *nrev = reverse_n(*rank, n); + *p = X(plan_dft_r2c)(*rank, nrev, in, out, *flags); + X(ifree0)(nrev); +} + +void F77(plan_dft_r2c_1d, PLAN_DFT_R2C_1D)(X(plan) *p, int *n, R *in, C *out, + int *flags) +{ + *p = X(plan_dft_r2c_1d)(*n, in, out, *flags); +} + +void F77(plan_dft_r2c_2d, PLAN_DFT_R2C_2D)(X(plan) *p, int *nx, int *ny, + R *in, C *out, int *flags) +{ + *p = X(plan_dft_r2c_2d)(*ny, *nx, in, out, *flags); +} + +void F77(plan_dft_r2c_3d, PLAN_DFT_R2C_3D)(X(plan) *p, + int *nx, int *ny, int *nz, + R *in, C *out, + int *flags) +{ + *p = X(plan_dft_r2c_3d)(*nz, *ny, *nx, in, out, *flags); +} + +void F77(plan_many_dft_r2c, PLAN_MANY_DFT_R2C)( + X(plan) *p, 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, + int *flags) +{ + int *nrev = reverse_n(*rank, n); + int *inembedrev = reverse_n(*rank, inembed); + int *onembedrev = reverse_n(*rank, onembed); + *p = X(plan_many_dft_r2c)(*rank, nrev, *howmany, + in, inembedrev, *istride, *idist, + out, onembedrev, *ostride, *odist, + *flags); + X(ifree0)(onembedrev); + X(ifree0)(inembedrev); + X(ifree0)(nrev); +} + +void F77(plan_guru_dft_r2c, PLAN_GURU_DFT_R2C)( + X(plan) *p, int *rank, const int *n, + const int *is, const int *os, + int *howmany_rank, const int *h_n, + const int *h_is, const int *h_os, + R *in, C *out, int *flags) +{ + X(iodim) *dims = make_dims(*rank, n, is, os); + X(iodim) *howmany_dims = make_dims(*howmany_rank, h_n, h_is, h_os); + *p = X(plan_guru_dft_r2c)(*rank, dims, *howmany_rank, howmany_dims, + in, out, *flags); + X(ifree0)(howmany_dims); + X(ifree0)(dims); +} + +void F77(plan_guru_split_dft_r2c, PLAN_GURU_SPLIT_DFT_R2C)( + X(plan) *p, int *rank, const int *n, + const int *is, const int *os, + int *howmany_rank, const int *h_n, + const int *h_is, const int *h_os, + R *in, R *ro, R *io, int *flags) +{ + X(iodim) *dims = make_dims(*rank, n, is, os); + X(iodim) *howmany_dims = make_dims(*howmany_rank, h_n, h_is, h_os); + *p = X(plan_guru_split_dft_r2c)(*rank, dims, *howmany_rank, howmany_dims, + in, ro, io, *flags); + X(ifree0)(howmany_dims); + X(ifree0)(dims); +} + +void F77(execute_dft_r2c, EXECUTE_DFT_R2C)(X(plan) * const p, R *in, C *out) +WITH_ALIGNED_STACK({ + plan_rdft2 *pln = (plan_rdft2 *) (*p)->pln; + pln->apply((plan *) pln, in, out[0], out[0]+1); +}) + +void F77(execute_split_dft_r2c, EXECUTE_SPLIT_DFT_R2C)(X(plan) * const p, + R *in, R *ro, R *io) +WITH_ALIGNED_STACK({ + plan_rdft2 *pln = (plan_rdft2 *) (*p)->pln; + pln->apply((plan *) pln, in, ro, io); +}) + +/****************************** DFT c2r *********************************/ + +void F77(plan_dft_c2r, PLAN_DFT_C2R)(X(plan) *p, int *rank, const int *n, + C *in, R *out, int *flags) +{ + int *nrev = reverse_n(*rank, n); + *p = X(plan_dft_c2r)(*rank, nrev, in, out, *flags); + X(ifree0)(nrev); +} + +void F77(plan_dft_c2r_1d, PLAN_DFT_C2R_1D)(X(plan) *p, int *n, C *in, R *out, + int *flags) +{ + *p = X(plan_dft_c2r_1d)(*n, in, out, *flags); +} + +void F77(plan_dft_c2r_2d, PLAN_DFT_C2R_2D)(X(plan) *p, int *nx, int *ny, + C *in, R *out, int *flags) +{ + *p = X(plan_dft_c2r_2d)(*ny, *nx, in, out, *flags); +} + +void F77(plan_dft_c2r_3d, PLAN_DFT_C2R_3D)(X(plan) *p, + int *nx, int *ny, int *nz, + C *in, R *out, + int *flags) +{ + *p = X(plan_dft_c2r_3d)(*nz, *ny, *nx, in, out, *flags); +} + +void F77(plan_many_dft_c2r, PLAN_MANY_DFT_C2R)( + X(plan) *p, int *rank, const int *n, + int *howmany, + C *in, const int *inembed, int *istride, int *idist, + R *out, const int *onembed, int *ostride, int *odist, + int *flags) +{ + int *nrev = reverse_n(*rank, n); + int *inembedrev = reverse_n(*rank, inembed); + int *onembedrev = reverse_n(*rank, onembed); + *p = X(plan_many_dft_c2r)(*rank, nrev, *howmany, + in, inembedrev, *istride, *idist, + out, onembedrev, *ostride, *odist, + *flags); + X(ifree0)(onembedrev); + X(ifree0)(inembedrev); + X(ifree0)(nrev); +} + +void F77(plan_guru_dft_c2r, PLAN_GURU_DFT_C2R)( + X(plan) *p, int *rank, const int *n, + const int *is, const int *os, + int *howmany_rank, const int *h_n, + const int *h_is, const int *h_os, + C *in, R *out, int *flags) +{ + X(iodim) *dims = make_dims(*rank, n, is, os); + X(iodim) *howmany_dims = make_dims(*howmany_rank, h_n, h_is, h_os); + *p = X(plan_guru_dft_c2r)(*rank, dims, *howmany_rank, howmany_dims, + in, out, *flags); + X(ifree0)(howmany_dims); + X(ifree0)(dims); +} + +void F77(plan_guru_split_dft_c2r, PLAN_GURU_SPLIT_DFT_C2R)( + X(plan) *p, int *rank, const int *n, + const int *is, const int *os, + int *howmany_rank, const int *h_n, + const int *h_is, const int *h_os, + R *ri, R *ii, R *out, int *flags) +{ + X(iodim) *dims = make_dims(*rank, n, is, os); + X(iodim) *howmany_dims = make_dims(*howmany_rank, h_n, h_is, h_os); + *p = X(plan_guru_split_dft_c2r)(*rank, dims, *howmany_rank, howmany_dims, + ri, ii, out, *flags); + X(ifree0)(howmany_dims); + X(ifree0)(dims); +} + +void F77(execute_dft_c2r, EXECUTE_DFT_C2R)(X(plan) * const p, C *in, R *out) +WITH_ALIGNED_STACK({ + plan_rdft2 *pln = (plan_rdft2 *) (*p)->pln; + pln->apply((plan *) pln, out, in[0], in[0]+1); +}) + +void F77(execute_split_dft_c2r, EXECUTE_SPLIT_DFT_C2R)(X(plan) * const p, + R *ri, R *ii, R *out) +WITH_ALIGNED_STACK({ + plan_rdft2 *pln = (plan_rdft2 *) (*p)->pln; + pln->apply((plan *) pln, out, ri, ii); +}) + +/****************************** r2r *********************************/ + +void F77(plan_r2r, PLAN_R2R)(X(plan) *p, int *rank, const int *n, + R *in, R *out, + int *kind, int *flags) +{ + int *nrev = reverse_n(*rank, n); + X(r2r_kind) *k = ints2kinds(*rank, kind); + *p = X(plan_r2r)(*rank, nrev, in, out, k, *flags); + X(ifree0)(k); + X(ifree0)(nrev); +} + +void F77(plan_r2r_1d, PLAN_R2R_1D)(X(plan) *p, int *n, R *in, R *out, + int *kind, int *flags) +{ + *p = X(plan_r2r_1d)(*n, in, out, (X(r2r_kind)) *kind, *flags); +} + +void F77(plan_r2r_2d, PLAN_R2R_2D)(X(plan) *p, int *nx, int *ny, + R *in, R *out, + int *kindx, int *kindy, int *flags) +{ + *p = X(plan_r2r_2d)(*ny, *nx, in, out, + (X(r2r_kind)) *kindy, (X(r2r_kind)) *kindx, *flags); +} + +void F77(plan_r2r_3d, PLAN_R2R_3D)(X(plan) *p, + int *nx, int *ny, int *nz, + R *in, R *out, + int *kindx, int *kindy, int *kindz, + int *flags) +{ + *p = X(plan_r2r_3d)(*nz, *ny, *nx, in, out, + (X(r2r_kind)) *kindz, (X(r2r_kind)) *kindy, + (X(r2r_kind)) *kindx, *flags); +} + +void F77(plan_many_r2r, PLAN_MANY_R2R)( + X(plan) *p, 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, + int *kind, int *flags) +{ + int *nrev = reverse_n(*rank, n); + int *inembedrev = reverse_n(*rank, inembed); + int *onembedrev = reverse_n(*rank, onembed); + X(r2r_kind) *k = ints2kinds(*rank, kind); + *p = X(plan_many_r2r)(*rank, nrev, *howmany, + in, inembedrev, *istride, *idist, + out, onembedrev, *ostride, *odist, + k, *flags); + X(ifree0)(k); + X(ifree0)(onembedrev); + X(ifree0)(inembedrev); + X(ifree0)(nrev); +} + +void F77(plan_guru_r2r, PLAN_GURU_R2R)( + X(plan) *p, int *rank, const int *n, + const int *is, const int *os, + int *howmany_rank, const int *h_n, + const int *h_is, const int *h_os, + R *in, R *out, int *kind, int *flags) +{ + X(iodim) *dims = make_dims(*rank, n, is, os); + X(iodim) *howmany_dims = make_dims(*howmany_rank, h_n, h_is, h_os); + X(r2r_kind) *k = ints2kinds(*rank, kind); + *p = X(plan_guru_r2r)(*rank, dims, *howmany_rank, howmany_dims, + in, out, k, *flags); + X(ifree0)(k); + X(ifree0)(howmany_dims); + X(ifree0)(dims); +} + +void F77(execute_r2r, EXECUTE_R2R)(X(plan) * const p, R *in, R *out) +WITH_ALIGNED_STACK({ + plan_rdft *pln = (plan_rdft *) (*p)->pln; + pln->apply((plan *) pln, in, out); +}) diff --git a/src/fftw3/api/fftw3.h b/src/fftw3/api/fftw3.h new file mode 100644 index 0000000..6cb3254 --- /dev/null +++ b/src/fftw3/api/fftw3.h @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* header file for fftw3 */ +/* $Id: fftw3.h,v 1.1 2008/10/17 06:10:47 scuri Exp $ */ + +#ifndef FFTW3_H +#define FFTW3_H + +#include <stdio.h> + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* If <complex.h> is included, use the C99 complex type. Otherwise + define a type bit-compatible with C99 complex */ +#ifdef _Complex_I +# define FFTW_DEFINE_COMPLEX(R, C) typedef R _Complex C +#else +# define FFTW_DEFINE_COMPLEX(R, C) typedef R C[2] +#endif + +#define FFTW_CONCAT(prefix, name) prefix ## name +#define FFTW_MANGLE_DOUBLE(name) FFTW_CONCAT(fftw_, name) +#define FFTW_MANGLE_FLOAT(name) FFTW_CONCAT(fftwf_, name) +#define FFTW_MANGLE_LONG_DOUBLE(name) FFTW_CONCAT(fftwl_, name) + + +enum fftw_r2r_kind_do_not_use_me { + FFTW_R2HC=0, FFTW_HC2R=1, FFTW_DHT=2, + FFTW_REDFT00=3, FFTW_REDFT01=4, FFTW_REDFT10=5, FFTW_REDFT11=6, + FFTW_RODFT00=7, FFTW_RODFT01=8, FFTW_RODFT10=9, FFTW_RODFT11=10 +}; + +struct fftw_iodim_do_not_use_me { + int n; /* dimension size */ + int is; /* input stride */ + int os; /* output stride */ +}; + +/* + huge second-order macro that defines prototypes for all API + functions. We expand this macro for each supported precision + + X: name-mangling macro + R: real data type + C: complex data type +*/ + +#define FFTW_DEFINE_API(X, R, C) \ + \ +FFTW_DEFINE_COMPLEX(R, C); \ + \ +typedef struct X(plan_s) *X(plan); \ + \ +typedef struct fftw_iodim_do_not_use_me X(iodim); \ + \ +typedef enum fftw_r2r_kind_do_not_use_me X(r2r_kind); \ + \ +void X(execute)(const X(plan) p); \ + \ +X(plan) X(plan_dft)(int rank, const int *n, \ + C *in, C *out, int sign, unsigned flags); \ + \ +X(plan) X(plan_dft_1d)(int n, C *in, C *out, int sign, \ + unsigned flags); \ +X(plan) X(plan_dft_2d)(int nx, int ny, \ + C *in, C *out, int sign, unsigned flags); \ +X(plan) X(plan_dft_3d)(int nx, int ny, int nz, \ + C *in, C *out, int sign, unsigned flags); \ + \ +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); \ + \ +X(plan) X(plan_guru_dft)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + C *in, C *out, \ + int sign, unsigned flags); \ +X(plan) X(plan_guru_split_dft)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *ri, R *ii, R *ro, R *io, \ + unsigned flags); \ + \ +void X(execute_dft)(const X(plan) p, C *in, C *out); \ +void X(execute_split_dft)(const X(plan) p, R *ri, R *ii, R *ro, R *io); \ + \ +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); \ + \ +X(plan) X(plan_dft_r2c)(int rank, const int *n, \ + R *in, C *out, unsigned flags); \ + \ +X(plan) X(plan_dft_r2c_1d)(int n,R *in,C *out,unsigned flags); \ +X(plan) X(plan_dft_r2c_2d)(int nx, int ny, \ + R *in, C *out, unsigned flags); \ +X(plan) X(plan_dft_r2c_3d)(int nx, int ny, \ + int nz, \ + R *in, C *out, unsigned flags); \ + \ + \ +X(plan) X(plan_many_dft_c2r)(int rank, const int *n, \ + int howmany, \ + C *in, const int *inembed, \ + int istride, int idist, \ + R *out, const int *onembed, \ + int ostride, int odist, \ + unsigned flags); \ + \ +X(plan) X(plan_dft_c2r)(int rank, const int *n, \ + C *in, R *out, unsigned flags); \ + \ +X(plan) X(plan_dft_c2r_1d)(int n,C *in,R *out,unsigned flags); \ +X(plan) X(plan_dft_c2r_2d)(int nx, int ny, \ + C *in, R *out, unsigned flags); \ +X(plan) X(plan_dft_c2r_3d)(int nx, int ny, \ + int nz, \ + C *in, R *out, unsigned flags); \ + \ +X(plan) X(plan_guru_dft_r2c)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *in, C *out, \ + unsigned flags); \ +X(plan) X(plan_guru_dft_c2r)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + C *in, R *out, \ + unsigned flags); \ + \ +X(plan) X(plan_guru_split_dft_r2c)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *in, R *ro, R *io, \ + unsigned flags); \ +X(plan) X(plan_guru_split_dft_c2r)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *ri, R *ii, R *out, \ + unsigned flags); \ + \ +void X(execute_dft_r2c)(const X(plan) p, R *in, C *out); \ +void X(execute_dft_c2r)(const X(plan) p, C *in, R *out); \ + \ +void X(execute_split_dft_r2c)(const X(plan) p, R *in, R *ro, R *io); \ +void X(execute_split_dft_c2r)(const X(plan) p, R *ri, R *ii, R *out); \ + \ +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) X(plan_r2r)(int rank, const int *n, R *in, R *out, \ + const X(r2r_kind) *kind, unsigned flags); \ + \ +X(plan) X(plan_r2r_1d)(int n, R *in, R *out, \ + X(r2r_kind) kind, unsigned flags); \ +X(plan) X(plan_r2r_2d)(int nx, int ny, R *in, R *out, \ + X(r2r_kind) kindx, X(r2r_kind) kindy, \ + unsigned flags); \ +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); \ + \ +X(plan) X(plan_guru_r2r)(int rank, const X(iodim) *dims, \ + int howmany_rank, \ + const X(iodim) *howmany_dims, \ + R *in, R *out, \ + const X(r2r_kind) *kind, unsigned flags); \ +void X(execute_r2r)(const X(plan) p, R *in, R *out); \ + \ +void X(destroy_plan)(X(plan) p); \ +void X(forget_wisdom)(void); \ +void X(cleanup)(void); \ + \ +void X(plan_with_nthreads)(int nthreads); \ +int X(init_threads)(void); \ +void X(cleanup_threads)(void); \ + \ +void X(export_wisdom_to_file)(FILE *output_file); \ +char *X(export_wisdom_to_string)(void); \ +void X(export_wisdom)(void (*write_char)(char c, void *), void *data); \ +int X(import_system_wisdom)(void); \ +int X(import_wisdom_from_file)(FILE *input_file); \ +int X(import_wisdom_from_string)(const char *input_string); \ +int X(import_wisdom)(int (*read_char)(void *), void *data); \ + \ +void X(fprint_plan)(const X(plan) p, FILE *output_file); \ +void X(print_plan)(const X(plan) p); \ + \ +void *X(malloc)(size_t n); \ +void X(free)(void *p); \ + \ +void X(flops)(const X(plan) p, double *add, double *mul, double *fma); \ + \ +extern const char X(version)[]; \ +extern const char X(cc)[]; \ +extern const char X(codelet_optim)[]; + + +/* end of FFTW_DEFINE_API macro */ + +FFTW_DEFINE_API(FFTW_MANGLE_DOUBLE, double, fftw_complex) +FFTW_DEFINE_API(FFTW_MANGLE_FLOAT, float, fftwf_complex) +FFTW_DEFINE_API(FFTW_MANGLE_LONG_DOUBLE, long double, fftwl_complex) + +#define FFTW_FORWARD (-1) +#define FFTW_BACKWARD (+1) + +/* documented flags */ +#define FFTW_MEASURE (0U) +#define FFTW_DESTROY_INPUT (1U << 0) +#define FFTW_UNALIGNED (1U << 1) +#define FFTW_CONSERVE_MEMORY (1U << 2) +#define FFTW_EXHAUSTIVE (1U << 3) /* NO_EXHAUSTIVE is default */ +#define FFTW_PRESERVE_INPUT (1U << 4) /* cancels FFTW_DESTROY_INPUT */ +#define FFTW_PATIENT (1U << 5) /* IMPATIENT is default */ +#define FFTW_ESTIMATE (1U << 6) + +/* undocumented beyond-guru flags */ +#define FFTW_ESTIMATE_PATIENT (1U << 7) +#define FFTW_BELIEVE_PCOST (1U << 8) +#define FFTW_DFT_R2HC_ICKY (1U << 9) +#define FFTW_NONTHREADED_ICKY (1U << 10) +#define FFTW_NO_BUFFERING (1U << 11) +#define FFTW_NO_INDIRECT_OP (1U << 12) +#define FFTW_ALLOW_LARGE_GENERIC (1U << 13) /* NO_LARGE_GENERIC is default */ +#define FFTW_NO_RANK_SPLITS (1U << 14) +#define FFTW_NO_VRANK_SPLITS (1U << 15) +#define FFTW_NO_VRECURSE (1U << 16) + +#define FFTW_NO_SIMD (1U << 17) + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* FFTW3_H */ diff --git a/src/fftw3/api/flops.c b/src/fftw3/api/flops.c new file mode 100644 index 0000000..43e8891 --- /dev/null +++ b/src/fftw3/api/flops.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +void X(flops)(const X(plan) p, double *add, double *mul, double *fma) +{ + opcnt *o = &p->pln->ops; + *add = o->add; *mul = o->mul; *fma = o->fma; +} diff --git a/src/fftw3/api/forget-wisdom.c b/src/fftw3/api/forget-wisdom.c new file mode 100644 index 0000000..10ea580 --- /dev/null +++ b/src/fftw3/api/forget-wisdom.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +void X(forget_wisdom)(void) +{ + planner *plnr = X(the_planner)(); + plnr->adt->forget(plnr, FORGET_EVERYTHING); +} diff --git a/src/fftw3/api/import-system-wisdom.c b/src/fftw3/api/import-system-wisdom.c new file mode 100644 index 0000000..393b3a6 --- /dev/null +++ b/src/fftw3/api/import-system-wisdom.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +#if defined(FFTW_SINGLE) +# define WISDOM_NAME "wisdomf" +#elif defined(FFTW_LDOUBLE) +# define WISDOM_NAME "wisdoml" +#else +# define WISDOM_NAME "wisdom" +#endif + +int X(import_system_wisdom)(void) +{ +#if defined(__WIN32__) || defined(WIN32) || defined(_WINDOWS) + return 0; /* TODO? */ +#else + + FILE *f; + f = fopen("/etc/fftw/" WISDOM_NAME, "r"); + if (f) { + int ret = X(import_wisdom_from_file)(f); + fclose(f); + return ret; + } else + return 0; +#endif +} diff --git a/src/fftw3/api/import-wisdom-from-file.c b/src/fftw3/api/import-wisdom-from-file.c new file mode 100644 index 0000000..e682ab9 --- /dev/null +++ b/src/fftw3/api/import-wisdom-from-file.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include <stdio.h> + +/* getc()/putc() are *unbelievably* slow on linux. Looks like glibc + is grabbing a lock for each call to getc()/putc(), or something + like that. You pay the price for these idiotic posix threads + whether you use them or not. + + So, we do our own buffering. This completely defeats the purpose + of having stdio in the first place, of course. +*/ + +#define BUFSZ 256 + +typedef struct { + scanner super; + FILE *f; + char buf[BUFSZ]; + char *bufr, *bufw; +} S; + +static int getchr_file(scanner * sc_) +{ + S *sc = (S *) sc_; + + if (sc->bufr >= sc->bufw) { + sc->bufr = sc->buf; + sc->bufw = sc->buf + fread(sc->buf, 1, BUFSZ, sc->f); + if (sc->bufr >= sc->bufw) + return EOF; + } + + return *(sc->bufr++); +} + +static scanner *mkscanner_file(FILE *f) +{ + S *sc = (S *) X(mkscanner)(sizeof(S), getchr_file); + sc->f = f; + sc->bufr = sc->bufw = sc->buf; + return &sc->super; +} + +int X(import_wisdom_from_file)(FILE *input_file) +{ + scanner *s = mkscanner_file(input_file); + planner *plnr = X(the_planner)(); + int ret = plnr->adt->imprt(plnr, s); + X(scanner_destroy)(s); + return ret; +} diff --git a/src/fftw3/api/import-wisdom-from-string.c b/src/fftw3/api/import-wisdom-from-string.c new file mode 100644 index 0000000..d1ca6b8 --- /dev/null +++ b/src/fftw3/api/import-wisdom-from-string.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +typedef struct { + scanner super; + const char *s; +} S_str; + +static int getchr_str(scanner * sc_) +{ + S_str *sc = (S_str *) sc_; + if (!*sc->s) + return EOF; + return *sc->s++; +} + +static scanner *mkscanner_str(const char *s) +{ + S_str *sc = (S_str *) X(mkscanner)(sizeof(S_str), getchr_str); + sc->s = s; + return &sc->super; +} + +int X(import_wisdom_from_string)(const char *input_string) +{ + scanner *s = mkscanner_str(input_string); + planner *plnr = X(the_planner)(); + int ret = plnr->adt->imprt(plnr, s); + X(scanner_destroy)(s); + return ret; +} diff --git a/src/fftw3/api/import-wisdom.c b/src/fftw3/api/import-wisdom.c new file mode 100644 index 0000000..505ebab --- /dev/null +++ b/src/fftw3/api/import-wisdom.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +typedef struct { + scanner super; + int (*read_char)(void *); + void *data; +} S; + +static int getchr_generic(scanner * s_) +{ + S *s = (S *) s_; + return (s->read_char)(s->data); +} + +int X(import_wisdom)(int (*read_char)(void *), void *data) +{ + S *s = (S *) X(mkscanner)(sizeof(S), getchr_generic); + planner *plnr = X(the_planner)(); + int ret; + + s->read_char = read_char; + s->data = data; + ret = plnr->adt->imprt(plnr, (scanner *) s); + X(scanner_destroy)((scanner *) s); + return ret; +} diff --git a/src/fftw3/api/map-r2r-kind.c b/src/fftw3/api/map-r2r-kind.c new file mode 100644 index 0000000..adba2ce --- /dev/null +++ b/src/fftw3/api/map-r2r-kind.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind) +{ + int i; + rdft_kind *k; + + A(FINITE_RNK(rank)); + k = (rdft_kind *) MALLOC(rank * sizeof(rdft_kind), PROBLEMS); + for (i = 0; i < rank; ++i) { + rdft_kind m; + switch (kind[i]) { + case FFTW_R2HC: m = R2HC; break; + case FFTW_HC2R: m = HC2R; break; + case FFTW_DHT: m = DHT; break; + case FFTW_REDFT00: m = REDFT00; break; + case FFTW_REDFT01: m = REDFT01; break; + case FFTW_REDFT10: m = REDFT10; break; + case FFTW_REDFT11: m = REDFT11; break; + case FFTW_RODFT00: m = RODFT00; break; + case FFTW_RODFT01: m = RODFT01; break; + case FFTW_RODFT10: m = RODFT10; break; + case FFTW_RODFT11: m = RODFT11; break; + default: m = R2HC; A(0); + } + k[i] = m; + } + return k; +} diff --git a/src/fftw3/api/mapflags.c b/src/fftw3/api/mapflags.c new file mode 100644 index 0000000..abb4e6b --- /dev/null +++ b/src/fftw3/api/mapflags.c @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +/* a flag operation: x is either a flag, in which case xm == 0, or + a mask, in which case xm == x; using this we can compactly code + the various bit operations via (flags & x) ^ xm or (flags | x) ^ xm. */ +typedef struct { + unsigned x, xm; +} flagmask; + +typedef struct { + flagmask flag; + flagmask op; +} flagop; + +#define FLAGP(f, msk)(((f) & (msk).x) ^ (msk).xm) +#define OP(f, msk)(((f) | (msk).x) ^ (msk).xm) + +#define YES(x) {x, 0} +#define NO(x) {x, x} +#define IMPLIES(predicate, consequence) { predicate, consequence } +#define EQV(a, b) IMPLIES(YES(a), YES(b)), IMPLIES(NO(a), NO(b)) +#define NEQV(a, b) IMPLIES(YES(a), NO(b)), IMPLIES(NO(a), YES(b)) + +static void map_flags(unsigned *iflags, unsigned *oflags, + const flagop flagmap[], int nmap) +{ + int i; + for (i = 0; i < nmap; ++i) + if (FLAGP(*iflags, flagmap[i].flag)) + *oflags = OP(*oflags, flagmap[i].op); +} + +#define NELEM(array)(sizeof(array) / sizeof((array)[0])) + +void X(mapflags)(planner *plnr, unsigned flags) +{ + unsigned tmpflags; + + /* map of api flags -> api flags, to implement consistency rules + and combination flags */ + const flagop self_flagmap[] = { + /* in some cases (notably for halfcomplex->real transforms), + DESTROY_INPUT is the default, so we need to support + an inverse flag to disable it: */ + IMPLIES(YES(FFTW_PRESERVE_INPUT), NO(FFTW_DESTROY_INPUT)), + + IMPLIES(YES(FFTW_EXHAUSTIVE), YES(FFTW_PATIENT)), + + IMPLIES(YES(FFTW_ESTIMATE), NO(FFTW_PATIENT)), + IMPLIES(YES(FFTW_ESTIMATE), + YES(FFTW_ESTIMATE_PATIENT | FFTW_NO_INDIRECT_OP)), + + /* a canonical set of fftw2-like impatience flags */ + IMPLIES(NO(FFTW_PATIENT), + YES(FFTW_NO_VRECURSE + | FFTW_NO_RANK_SPLITS + | FFTW_NO_VRANK_SPLITS + | FFTW_NONTHREADED_ICKY + | FFTW_DFT_R2HC_ICKY + | FFTW_BELIEVE_PCOST)) + }; + + /* map of (processed) api flags to internal problem/planner flags */ + const flagop problem_flagmap[] = { + EQV(FFTW_DESTROY_INPUT, DESTROY_INPUT), + EQV(FFTW_NO_SIMD, NO_SIMD), + EQV(FFTW_CONSERVE_MEMORY, CONSERVE_MEMORY) + }; + const flagop planner_flagmap[] = { + NEQV(FFTW_EXHAUSTIVE, NO_EXHAUSTIVE), + + /* the following are undocumented, "beyond-guru" flags that + require some understanding of FFTW internals */ + EQV(FFTW_ESTIMATE_PATIENT, ESTIMATE), + EQV(FFTW_BELIEVE_PCOST, BELIEVE_PCOST), + EQV(FFTW_DFT_R2HC_ICKY, DFT_R2HC_ICKY), + EQV(FFTW_NONTHREADED_ICKY, NONTHREADED_ICKY), + EQV(FFTW_NO_BUFFERING, NO_BUFFERING), + EQV(FFTW_NO_INDIRECT_OP, NO_INDIRECT_OP), + NEQV(FFTW_ALLOW_LARGE_GENERIC, NO_LARGE_GENERIC), + EQV(FFTW_NO_RANK_SPLITS, NO_RANK_SPLITS), + EQV(FFTW_NO_VRANK_SPLITS, NO_VRANK_SPLITS), + EQV(FFTW_NO_VRECURSE, NO_VRECURSE) + }; + + map_flags(&flags, &flags, self_flagmap, NELEM(self_flagmap)); + + tmpflags = 0; + map_flags(&flags, &tmpflags, problem_flagmap, NELEM(problem_flagmap)); + plnr->problem_flags = tmpflags; + + tmpflags = 0; + map_flags(&flags, &tmpflags, planner_flagmap, NELEM(planner_flagmap)); + plnr->planner_flags = tmpflags; +} diff --git a/src/fftw3/api/mkprinter-file.c b/src/fftw3/api/mkprinter-file.c new file mode 100644 index 0000000..24476f9 --- /dev/null +++ b/src/fftw3/api/mkprinter-file.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include <stdio.h> + +#define BUFSZ 256 + +typedef struct { + printer super; + FILE *f; + char buf[BUFSZ]; + char *bufw; +} P; + +static void myflush(P *p) +{ + fwrite(p->buf, 1, p->bufw - p->buf, p->f); + p->bufw = p->buf; +} + +static void myputchr(printer *p_, char c) +{ + P *p = (P *) p_; + if (p->bufw >= p->buf + BUFSZ) + myflush(p); + *p->bufw++ = c; +} + +static void mycleanup(printer *p_) +{ + P *p = (P *) p_; + myflush(p); +} + +printer *X(mkprinter_file)(FILE *f) +{ + P *p = (P *) X(mkprinter)(sizeof(P), myputchr, mycleanup); + p->f = f; + p->bufw = p->buf; + return &p->super; +} diff --git a/src/fftw3/api/mktensor-iodims.c b/src/fftw3/api/mktensor-iodims.c new file mode 100644 index 0000000..99ce49e --- /dev/null +++ b/src/fftw3/api/mktensor-iodims.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +tensor *X(mktensor_iodims)(int rank, const X(iodim) *dims, int is, int os) +{ + int i; + tensor *x = X(mktensor)(rank); + + if (FINITE_RNK(rank)) { + for (i = 0; i < rank; ++i) { + x->dims[i].n = dims[i].n; + x->dims[i].is = dims[i].is * is; + x->dims[i].os = dims[i].os * os; + } + } + return x; +} + +static int iodims_kosherp(int rank, const X(iodim) *dims, int allow_minfty) +{ + int i; + + if (rank < 0) return 0; + + if (allow_minfty) { + if (!FINITE_RNK(rank)) return 1; + for (i = 0; i < rank; ++i) + if (dims[i].n < 0) return 0; + } else { + if (!FINITE_RNK(rank)) return 0; + for (i = 0; i < rank; ++i) + if (dims[i].n <= 0) return 0; + } + + return 1; +} + +int X(guru_kosherp)(int rank, const X(iodim) *dims, + int howmany_rank, const X(iodim) *howmany_dims) +{ + return (iodims_kosherp(rank, dims, 0) && + iodims_kosherp(howmany_rank, howmany_dims, 1)); +} diff --git a/src/fftw3/api/mktensor-rowmajor.c b/src/fftw3/api/mktensor-rowmajor.c new file mode 100644 index 0000000..84b87ca --- /dev/null +++ b/src/fftw3/api/mktensor-rowmajor.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +tensor *X(mktensor_rowmajor)(int rnk, const int *n, + const int *niphys, const int *nophys, + int is, int os) +{ + tensor *x = X(mktensor)(rnk); + + if (FINITE_RNK(rnk) && rnk > 0) { + int i; + + A(n && niphys && nophys); + x->dims[rnk - 1].is = is; + x->dims[rnk - 1].os = os; + x->dims[rnk - 1].n = n[rnk - 1]; + for (i = rnk - 1; i > 0; --i) { + x->dims[i - 1].is = x->dims[i].is * niphys[i]; + x->dims[i - 1].os = x->dims[i].os * nophys[i]; + x->dims[i - 1].n = n[i - 1]; + } + } + return x; +} + +static int rowmajor_kosherp(int rnk, const int *n) +{ + int i; + + if (!FINITE_RNK(rnk)) return 0; + if (rnk < 0) return 0; + + for (i = 0; i < rnk; ++i) + if (n[i] <= 0) return 0; + + return 1; +} + +int X(many_kosherp)(int rnk, const int *n, int howmany) +{ + return (howmany >= 0) && rowmajor_kosherp(rnk, n); +} diff --git a/src/fftw3/api/plan-dft-1d.c b/src/fftw3/api/plan-dft-1d.c new file mode 100644 index 0000000..02ff69d --- /dev/null +++ b/src/fftw3/api/plan-dft-1d.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" + +X(plan) X(plan_dft_1d)(int n, C *in, C *out, int sign, unsigned flags) +{ + return X(plan_dft)(1, &n, in, out, sign, flags); +} diff --git a/src/fftw3/api/plan-dft-2d.c b/src/fftw3/api/plan-dft-2d.c new file mode 100644 index 0000000..f41e7e3 --- /dev/null +++ b/src/fftw3/api/plan-dft-2d.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" + +X(plan) X(plan_dft_2d)(int nx, int ny, C *in, C *out, int sign, unsigned flags) +{ + int n[2]; + n[0] = nx; + n[1] = ny; + return X(plan_dft)(2, n, in, out, sign, flags); +} diff --git a/src/fftw3/api/plan-dft-3d.c b/src/fftw3/api/plan-dft-3d.c new file mode 100644 index 0000000..a605a46 --- /dev/null +++ b/src/fftw3/api/plan-dft-3d.c @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" + +X(plan) X(plan_dft_3d)(int nx, int ny, int nz, + C *in, C *out, int sign, unsigned flags) +{ + int n[3]; + n[0] = nx; + n[1] = ny; + n[2] = nz; + return X(plan_dft)(3, n, in, out, sign, flags); +} diff --git a/src/fftw3/api/plan-dft-c2r-1d.c b/src/fftw3/api/plan-dft-c2r-1d.c new file mode 100644 index 0000000..7dc9a93 --- /dev/null +++ b/src/fftw3/api/plan-dft-c2r-1d.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft_c2r_1d)(int n, C *in, R *out, unsigned flags) +{ + return X(plan_dft_c2r)(1, &n, in, out, flags); +} diff --git a/src/fftw3/api/plan-dft-c2r-2d.c b/src/fftw3/api/plan-dft-c2r-2d.c new file mode 100644 index 0000000..37d39bb --- /dev/null +++ b/src/fftw3/api/plan-dft-c2r-2d.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft_c2r_2d)(int nx, int ny, C *in, R *out, unsigned flags) +{ + int n[2]; + n[0] = nx; + n[1] = ny; + return X(plan_dft_c2r)(2, n, in, out, flags); +} diff --git a/src/fftw3/api/plan-dft-c2r-3d.c b/src/fftw3/api/plan-dft-c2r-3d.c new file mode 100644 index 0000000..4644126 --- /dev/null +++ b/src/fftw3/api/plan-dft-c2r-3d.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft_c2r_3d)(int nx, int ny, int nz, + C *in, R *out, unsigned flags) +{ + int n[3]; + n[0] = nx; + n[1] = ny; + n[2] = nz; + return X(plan_dft_c2r)(3, n, in, out, flags); +} diff --git a/src/fftw3/api/plan-dft-c2r.c b/src/fftw3/api/plan-dft-c2r.c new file mode 100644 index 0000000..118c1cb --- /dev/null +++ b/src/fftw3/api/plan-dft-c2r.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft_c2r)(int rank, const int *n, C *in, R *out, unsigned flags) +{ + return X(plan_many_dft_c2r)(rank, n, 1, + in, 0, 1, 1, out, 0, 1, 1, flags); +} diff --git a/src/fftw3/api/plan-dft-r2c-1d.c b/src/fftw3/api/plan-dft-r2c-1d.c new file mode 100644 index 0000000..5d4865a --- /dev/null +++ b/src/fftw3/api/plan-dft-r2c-1d.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft_r2c_1d)(int n, R *in, C *out, unsigned flags) +{ + return X(plan_dft_r2c)(1, &n, in, out, flags); +} diff --git a/src/fftw3/api/plan-dft-r2c-2d.c b/src/fftw3/api/plan-dft-r2c-2d.c new file mode 100644 index 0000000..289841c --- /dev/null +++ b/src/fftw3/api/plan-dft-r2c-2d.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft_r2c_2d)(int nx, int ny, R *in, C *out, unsigned flags) +{ + int n[2]; + n[0] = nx; + n[1] = ny; + return X(plan_dft_r2c)(2, n, in, out, flags); +} diff --git a/src/fftw3/api/plan-dft-r2c-3d.c b/src/fftw3/api/plan-dft-r2c-3d.c new file mode 100644 index 0000000..c25d04f --- /dev/null +++ b/src/fftw3/api/plan-dft-r2c-3d.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft_r2c_3d)(int nx, int ny, int nz, + R *in, C *out, unsigned flags) +{ + int n[3]; + n[0] = nx; + n[1] = ny; + n[2] = nz; + return X(plan_dft_r2c)(3, n, in, out, flags); +} diff --git a/src/fftw3/api/plan-dft-r2c.c b/src/fftw3/api/plan-dft-r2c.c new file mode 100644 index 0000000..8624995 --- /dev/null +++ b/src/fftw3/api/plan-dft-r2c.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft_r2c)(int rank, const int *n, R *in, C *out, unsigned flags) +{ + return X(plan_many_dft_r2c)(rank, n, 1, + in, 0, 1, 1, + out, 0, 1, 1, + flags); +} diff --git a/src/fftw3/api/plan-dft.c b/src/fftw3/api/plan-dft.c new file mode 100644 index 0000000..f9c8756 --- /dev/null +++ b/src/fftw3/api/plan-dft.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +X(plan) X(plan_dft)(int rank, const int *n, + C *in, C *out, int sign, unsigned flags) +{ + return X(plan_many_dft)(rank, n, 1, + in, 0, 1, 1, + out, 0, 1, 1, + sign, flags); +} diff --git a/src/fftw3/api/plan-guru-dft-c2r.c b/src/fftw3/api/plan-guru-dft-c2r.c new file mode 100644 index 0000000..0ab3a9c --- /dev/null +++ b/src/fftw3/api/plan-guru-dft-c2r.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +X(plan) X(plan_guru_dft_c2r)(int rank, const X(iodim) *dims, + int howmany_rank, const X(iodim) *howmany_dims, + C *in, R *out, unsigned flags) +{ + R *ri, *ii; + + if (!X(guru_kosherp)(rank, dims, howmany_rank, howmany_dims)) return 0; + + X(extract_reim)(FFT_SIGN, in, &ri, &ii); + + if (out != ri) + flags |= FFTW_DESTROY_INPUT; + return X(mkapiplan)( + 0, flags, + X(mkproblem_rdft2_d)(X(mktensor_iodims)(rank, dims, 2, 1), + X(mktensor_iodims)(howmany_rank, howmany_dims, + 2, 1), + TAINT_UNALIGNED(out, flags), + TAINT_UNALIGNED(ri, flags), + TAINT_UNALIGNED(ii, flags), HC2R)); +} diff --git a/src/fftw3/api/plan-guru-dft-r2c.c b/src/fftw3/api/plan-guru-dft-r2c.c new file mode 100644 index 0000000..c4e4d41 --- /dev/null +++ b/src/fftw3/api/plan-guru-dft-r2c.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +X(plan) X(plan_guru_dft_r2c)(int rank, const X(iodim) *dims, + int howmany_rank, + const X(iodim) *howmany_dims, + R *in, C *out, unsigned flags) +{ + R *ro, *io; + + if (!X(guru_kosherp)(rank, dims, howmany_rank, howmany_dims)) return 0; + + X(extract_reim)(FFT_SIGN, out, &ro, &io); + + return X(mkapiplan)( + 0, flags, + X(mkproblem_rdft2_d)(X(mktensor_iodims)(rank, dims, 1, 2), + X(mktensor_iodims)(howmany_rank, howmany_dims, + 1, 2), + TAINT_UNALIGNED(in, flags), + TAINT_UNALIGNED(ro, flags), + TAINT_UNALIGNED(io, flags), R2HC)); +} diff --git a/src/fftw3/api/plan-guru-dft.c b/src/fftw3/api/plan-guru-dft.c new file mode 100644 index 0000000..32c894b --- /dev/null +++ b/src/fftw3/api/plan-guru-dft.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" + +X(plan) X(plan_guru_dft)(int rank, const X(iodim) *dims, + int howmany_rank, const X(iodim) *howmany_dims, + C *in, C *out, int sign, unsigned flags) +{ + R *ri, *ii, *ro, *io; + + if (!X(guru_kosherp)(rank, dims, howmany_rank, howmany_dims)) return 0; + + X(extract_reim)(sign, in, &ri, &ii); + X(extract_reim)(sign, out, &ro, &io); + + return X(mkapiplan)( + sign, flags, + X(mkproblem_dft_d)(X(mktensor_iodims)(rank, dims, 2, 2), + X(mktensor_iodims)(howmany_rank, howmany_dims, + 2, 2), + TAINT_UNALIGNED(ri, flags), + TAINT_UNALIGNED(ii, flags), + TAINT_UNALIGNED(ro, flags), + TAINT_UNALIGNED(io, flags))); +} diff --git a/src/fftw3/api/plan-guru-r2r.c b/src/fftw3/api/plan-guru-r2r.c new file mode 100644 index 0000000..d5f2120 --- /dev/null +++ b/src/fftw3/api/plan-guru-r2r.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind); + +X(plan) X(plan_guru_r2r)(int rank, const X(iodim) *dims, + int howmany_rank, + const X(iodim) *howmany_dims, + R *in, R *out, + const X(r2r_kind) * kind, unsigned flags) +{ + X(plan) p; + rdft_kind *k; + + if (!X(guru_kosherp)(rank, dims, howmany_rank, howmany_dims)) return 0; + + k = X(map_r2r_kind)(rank, kind); + p = X(mkapiplan)( + 0, flags, + X(mkproblem_rdft_d)(X(mktensor_iodims)(rank, dims, 1, 1), + X(mktensor_iodims)(howmany_rank, howmany_dims, + 1, 1), + TAINT_UNALIGNED(in, flags), + TAINT_UNALIGNED(out, flags), k)); + X(ifree0)(k); + return p; +} diff --git a/src/fftw3/api/plan-guru-split-dft-c2r.c b/src/fftw3/api/plan-guru-split-dft-c2r.c new file mode 100644 index 0000000..f51bc9a --- /dev/null +++ b/src/fftw3/api/plan-guru-split-dft-c2r.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +X(plan) X(plan_guru_split_dft_c2r)(int rank, const X(iodim) *dims, + int howmany_rank, const X(iodim) *howmany_dims, + R *ri, R *ii, R *out, unsigned flags) +{ + if (!X(guru_kosherp)(rank, dims, howmany_rank, howmany_dims)) return 0; + + if (out != ri) + flags |= FFTW_DESTROY_INPUT; + return X(mkapiplan)( + 0, flags, + X(mkproblem_rdft2_d)(X(mktensor_iodims)(rank, dims, 1, 1), + X(mktensor_iodims)(howmany_rank, howmany_dims, + 1, 1), + TAINT_UNALIGNED(out, flags), + TAINT_UNALIGNED(ri, flags), + TAINT_UNALIGNED(ii, flags), HC2R)); +} diff --git a/src/fftw3/api/plan-guru-split-dft-r2c.c b/src/fftw3/api/plan-guru-split-dft-r2c.c new file mode 100644 index 0000000..3c5eafd --- /dev/null +++ b/src/fftw3/api/plan-guru-split-dft-r2c.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +X(plan) X(plan_guru_split_dft_r2c)(int rank, const X(iodim) *dims, + int howmany_rank, + const X(iodim) *howmany_dims, + R *in, R *ro, R *io, unsigned flags) +{ + if (!X(guru_kosherp)(rank, dims, howmany_rank, howmany_dims)) return 0; + + return X(mkapiplan)( + 0, flags, + X(mkproblem_rdft2_d)(X(mktensor_iodims)(rank, dims, 1, 1), + X(mktensor_iodims)(howmany_rank, howmany_dims, + 1, 1), + TAINT_UNALIGNED(in, flags), + TAINT_UNALIGNED(ro, flags), + TAINT_UNALIGNED(io, flags), R2HC)); +} diff --git a/src/fftw3/api/plan-guru-split-dft.c b/src/fftw3/api/plan-guru-split-dft.c new file mode 100644 index 0000000..62437c2 --- /dev/null +++ b/src/fftw3/api/plan-guru-split-dft.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "dft.h" + +X(plan) X(plan_guru_split_dft)(int rank, const X(iodim) *dims, + int howmany_rank, const X(iodim) *howmany_dims, + R *ri, R *ii, R *ro, R *io, unsigned flags) +{ + if (!X(guru_kosherp)(rank, dims, howmany_rank, howmany_dims)) return 0; + + return X(mkapiplan)( + ii - ri == 1 && io - ro == 1 ? FFT_SIGN : -FFT_SIGN, flags, + X(mkproblem_dft_d)(X(mktensor_iodims)(rank, dims, 1, 1), + X(mktensor_iodims)(howmany_rank, howmany_dims, + 1, 1), + TAINT_UNALIGNED(ri, flags), + TAINT_UNALIGNED(ii, flags), + TAINT_UNALIGNED(ro, flags), + TAINT_UNALIGNED(io, flags))); +} diff --git a/src/fftw3/api/plan-many-dft-c2r.c b/src/fftw3/api/plan-many-dft-c2r.c new file mode 100644 index 0000000..81b6338 --- /dev/null +++ b/src/fftw3/api/plan-many-dft-c2r.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +X(plan) X(plan_many_dft_c2r)(int rank, const int *n, + int howmany, + C *in, const int *inembed, + int istride, int idist, + R *out, const int *onembed, + int ostride, int odist, unsigned flags) +{ + R *ri, *ii; + int *nfi, *nfo; + int inplace; + X(plan) p; + + if (!X(many_kosherp)(rank, n, howmany)) return 0; + + X(extract_reim)(FFT_SIGN, in, &ri, &ii); + inplace = out == ri; + + if (!inplace) + flags |= FFTW_DESTROY_INPUT; + p = X(mkapiplan)( + 0, flags, + X(mkproblem_rdft2_d)( + X(mktensor_rowmajor)( + rank, n, + X (rdft2_pad)(rank, n, inembed, inplace, 1, &nfi), + X (rdft2_pad)(rank, n, onembed, inplace, 0, &nfo), + 2 * istride, ostride), + X(mktensor_1d)(howmany, 2 * idist, odist), + TAINT_UNALIGNED(out, flags), + TAINT_UNALIGNED(ri, flags), TAINT_UNALIGNED(ii, flags), + HC2R)); + + X(ifree0)(nfi); + X(ifree0)(nfo); + return p; +} diff --git a/src/fftw3/api/plan-many-dft-r2c.c b/src/fftw3/api/plan-many-dft-r2c.c new file mode 100644 index 0000000..093d9ba --- /dev/null +++ b/src/fftw3/api/plan-many-dft-r2c.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "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; + + X(extract_reim)(FFT_SIGN, out, &ro, &io); + inplace = in == ro; + + p = X(mkapiplan)( + 0, flags, + X(mkproblem_rdft2_d)( + 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; +} diff --git a/src/fftw3/api/plan-many-dft.c b/src/fftw3/api/plan-many-dft.c new file mode 100644 index 0000000..56f0ed4 --- /dev/null +++ b/src/fftw3/api/plan-many-dft.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "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; + + X(extract_reim)(sign, in, &ri, &ii); + X(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))); +} diff --git a/src/fftw3/api/plan-many-r2r.c b/src/fftw3/api/plan-many-r2r.c new file mode 100644 index 0000000..0a6815f --- /dev/null +++ b/src/fftw3/api/plan-many-r2r.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" +#include "rdft.h" + +rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind); + +#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; +} diff --git a/src/fftw3/api/plan-r2r-1d.c b/src/fftw3/api/plan-r2r-1d.c new file mode 100644 index 0000000..372d1c0 --- /dev/null +++ b/src/fftw3/api/plan-r2r-1d.c @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "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); +} diff --git a/src/fftw3/api/plan-r2r-2d.c b/src/fftw3/api/plan-r2r-2d.c new file mode 100644 index 0000000..7702560 --- /dev/null +++ b/src/fftw3/api/plan-r2r-2d.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "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); +} diff --git a/src/fftw3/api/plan-r2r-3d.c b/src/fftw3/api/plan-r2r-3d.c new file mode 100644 index 0000000..84ae651 --- /dev/null +++ b/src/fftw3/api/plan-r2r-3d.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "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); +} diff --git a/src/fftw3/api/plan-r2r.c b/src/fftw3/api/plan-r2r.c new file mode 100644 index 0000000..ba8f971 --- /dev/null +++ b/src/fftw3/api/plan-r2r.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "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); +} diff --git a/src/fftw3/api/print-plan.c b/src/fftw3/api/print-plan.c new file mode 100644 index 0000000..094446d --- /dev/null +++ b/src/fftw3/api/print-plan.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "api.h" + +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); +} diff --git a/src/fftw3/api/rdft2-pad.c b/src/fftw3/api/rdft2-pad.c new file mode 100644 index 0000000..499a55d --- /dev/null +++ b/src/fftw3/api/rdft2-pad.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <string.h> +#include "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) * rnk, PROBLEMS); + memcpy(np, n, sizeof(int) * rnk); + np[rnk - 1] = (n[rnk - 1] / 2 + 1) * (1 + !cmplx); + nembed = *nfree = np; + } else + nembed = n; + } + return nembed; +} diff --git a/src/fftw3/api/the-planner.c b/src/fftw3/api/the-planner.c new file mode 100644 index 0000000..8f6d546 --- /dev/null +++ b/src/fftw3/api/the-planner.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "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; + } +} diff --git a/src/fftw3/api/version.c b/src/fftw3/api/version.c new file mode 100644 index 0000000..2abf1ec --- /dev/null +++ b/src/fftw3/api/version.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* $Id: version.c,v 1.1 2008/10/17 06:10:48 scuri Exp $ */ + +#include "api.h" + +const char X(cc)[] = FFTW_CC; +const char X(codelet_optim)[] = CODELET_OPTIM; + +const char X(version)[] = PACKAGE "-" VERSION + +#if HAVE_SSE + "-sse" +#endif + +#if HAVE_SSE2 + "-sse2" +#endif + +#if HAVE_ALTIVEC + "-altivec" +#endif + +#if HAVE_3DNOW + "-3dnow" +#endif + +#if HAVE_K7 + "-k7" +#endif +; diff --git a/src/fftw3/api/x77.h b/src/fftw3/api/x77.h new file mode 100644 index 0000000..74513b3 --- /dev/null +++ b/src/fftw3/api/x77.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003 Matteo Frigo + * Copyright (c) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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) +#else +# define x77(name) CONCAT(dfftw_, name) +# define X77(NAME) CONCAT(DFFTW_, NAME) +#endif |