annotate constant-q-cpp/src/ext/kissfft/test/doit.c @ 372:af71cbdab621 tip

Update bqvec code
author Chris Cannam
date Tue, 19 Nov 2019 10:13:32 +0000
parents 5d0a2ebb4d17
children
rev   line source
Chris@366 1 /* this program is in the public domain
Chris@366 2 A program that helps the authors of the fine fftw library benchmark kiss
Chris@366 3 */
Chris@366 4
Chris@366 5 #include "bench-user.h"
Chris@366 6 #include <math.h>
Chris@366 7
Chris@366 8 #include "kiss_fft.h"
Chris@366 9 #include "kiss_fftnd.h"
Chris@366 10 #include "kiss_fftr.h"
Chris@366 11
Chris@366 12 BEGIN_BENCH_DOC
Chris@366 13 BENCH_DOC("name", "kissfft")
Chris@366 14 BENCH_DOC("version", "1.0.1")
Chris@366 15 BENCH_DOC("year", "2004")
Chris@366 16 BENCH_DOC("author", "Mark Borgerding")
Chris@366 17 BENCH_DOC("language", "C")
Chris@366 18 BENCH_DOC("url", "http://sourceforge.net/projects/kissfft/")
Chris@366 19 BENCH_DOC("copyright",
Chris@366 20 "Copyright (c) 2003,4 Mark Borgerding\n"
Chris@366 21 "\n"
Chris@366 22 "All rights reserved.\n"
Chris@366 23 "\n"
Chris@366 24 "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n"
Chris@366 25 "\n"
Chris@366 26 " * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n"
Chris@366 27 " * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n"
Chris@366 28 " * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n"
Chris@366 29 "\n"
Chris@366 30 "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n")
Chris@366 31 END_BENCH_DOC
Chris@366 32
Chris@366 33 int can_do(struct problem *p)
Chris@366 34 {
Chris@366 35 if (p->rank == 1) {
Chris@366 36 if (p->kind == PROBLEM_REAL) {
Chris@366 37 return (p->n[0] & 1) == 0; /* only even real is okay */
Chris@366 38 } else {
Chris@366 39 return 1;
Chris@366 40 }
Chris@366 41 } else {
Chris@366 42 return p->kind == PROBLEM_COMPLEX;
Chris@366 43 }
Chris@366 44 }
Chris@366 45
Chris@366 46 static kiss_fft_cfg cfg=NULL;
Chris@366 47 static kiss_fftr_cfg cfgr=NULL;
Chris@366 48 static kiss_fftnd_cfg cfgnd=NULL;
Chris@366 49
Chris@366 50 #define FAILIF( c ) \
Chris@366 51 if ( c ) do {\
Chris@366 52 fprintf(stderr,\
Chris@366 53 "kissfft: " #c " (file=%s:%d errno=%d %s)\n",\
Chris@366 54 __FILE__,__LINE__ , errno,strerror( errno ) ) ;\
Chris@366 55 exit(1);\
Chris@366 56 }while(0)
Chris@366 57
Chris@366 58
Chris@366 59
Chris@366 60 void setup(struct problem *p)
Chris@366 61 {
Chris@366 62 size_t i;
Chris@366 63
Chris@366 64 /*
Chris@366 65 fprintf(stderr,"%s %s %d-d ",
Chris@366 66 (p->sign == 1)?"Inverse":"Forward",
Chris@366 67 p->kind == PROBLEM_COMPLEX?"Complex":"Real",
Chris@366 68 p->rank);
Chris@366 69 */
Chris@366 70 if (p->rank == 1) {
Chris@366 71 if (p->kind == PROBLEM_COMPLEX) {
Chris@366 72 cfg = kiss_fft_alloc (p->n[0], (p->sign == 1), 0, 0);
Chris@366 73 FAILIF(cfg==NULL);
Chris@366 74 }else{
Chris@366 75 cfgr = kiss_fftr_alloc (p->n[0], (p->sign == 1), 0, 0);
Chris@366 76 FAILIF(cfgr==NULL);
Chris@366 77 }
Chris@366 78 }else{
Chris@366 79 int dims[5];
Chris@366 80 for (i=0;i<p->rank;++i){
Chris@366 81 dims[i] = p->n[i];
Chris@366 82 }
Chris@366 83 /* multi-dimensional */
Chris@366 84 if (p->kind == PROBLEM_COMPLEX) {
Chris@366 85 cfgnd = kiss_fftnd_alloc( dims , p->rank, (p->sign == 1), 0, 0 );
Chris@366 86 FAILIF(cfgnd==NULL);
Chris@366 87 }
Chris@366 88 }
Chris@366 89 }
Chris@366 90
Chris@366 91 void doit(int iter, struct problem *p)
Chris@366 92 {
Chris@366 93 int i;
Chris@366 94 void *in = p->in;
Chris@366 95 void *out = p->out;
Chris@366 96
Chris@366 97 if (p->in_place)
Chris@366 98 out = p->in;
Chris@366 99
Chris@366 100 if (p->rank == 1) {
Chris@366 101 if (p->kind == PROBLEM_COMPLEX){
Chris@366 102 for (i = 0; i < iter; ++i)
Chris@366 103 kiss_fft (cfg, in, out);
Chris@366 104 } else {
Chris@366 105 /* PROBLEM_REAL */
Chris@366 106 if (p->sign == -1) /* FORWARD */
Chris@366 107 for (i = 0; i < iter; ++i)
Chris@366 108 kiss_fftr (cfgr, in, out);
Chris@366 109 else
Chris@366 110 for (i = 0; i < iter; ++i)
Chris@366 111 kiss_fftri (cfgr, in, out);
Chris@366 112 }
Chris@366 113 }else{
Chris@366 114 /* multi-dimensional */
Chris@366 115 for (i = 0; i < iter; ++i)
Chris@366 116 kiss_fftnd(cfgnd,in,out);
Chris@366 117 }
Chris@366 118 }
Chris@366 119
Chris@366 120 void done(struct problem *p)
Chris@366 121 {
Chris@366 122 free(cfg);
Chris@366 123 cfg=NULL;
Chris@366 124 free(cfgr);
Chris@366 125 cfgr=NULL;
Chris@366 126 free(cfgnd);
Chris@366 127 cfgnd=NULL;
Chris@366 128 UNUSED(p);
Chris@366 129 }