// Copyright Naoki Shibata and contributors 2010 - 2021. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #define _DEFAULT_SOURCE #define _XOPEN_SOURCE 700 #include #include #include #include #include #include #include #include #include #ifdef USEFFTW #include #include #else #include "sleef.h" #include "sleefdft.h" #endif typedef double real; static uint64_t gettime() { struct timespec tp; clock_gettime(CLOCK_MONOTONIC, &tp); return (uint64_t)tp.tv_sec * 1000000000 + ((uint64_t)tp.tv_nsec); } #define REPEAT 8 int main(int argc, char **argv) { if (argc == 1) { fprintf(stderr, "%s \n", argv[0]); exit(-1); } int backward = 0; int log2n = atoi(argv[1]); if (log2n < 0) { backward = 1; log2n = -log2n; } const int n = 1 << log2n; const int64_t niter = (int)(100000000000.0 / n / log2n); printf("Number of iterations = %lld\n", (long long int)niter); #ifdef USEFFTW fftw_complex *in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); fftw_complex *out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n); #if 0 int fftw_init_threads(void); fftw_plan_with_nthreads(omp_get_max_threads()); #endif fftw_plan w = fftw_plan_dft_1d(n, in, out, backward ? FFTW_BACKWARD : FFTW_FORWARD, FFTW_MEASURE); //fftw_plan w = fftw_plan_dft_1d(n, in, out, backward ? FFTW_BACKWARD : FFTW_FORWARD, FFTW_PATIENT); for(int i=0;i= 3) mode = SLEEF_MODE_VERBOSE | SLEEF_MODE_ESTIMATE; if (backward) mode |= SLEEF_MODE_BACKWARD; struct SleefDFT *p = SleefDFT_double_init1d(n, in, out, mode); if (argc >= 3) SleefDFT_setPath(p, argv[2]); for(int i=0;i