annotate src/ext/kissfft/test/doit.c @ 196:da283326bcd3 tip master

Update plugin versions in RDF
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 28 Feb 2020 09:43:02 +0000
parents 5ed6e970541b
children
rev   line source
c@174 1 /* this program is in the public domain
c@174 2 A program that helps the authors of the fine fftw library benchmark kiss
c@174 3 */
c@174 4
c@174 5 #include "bench-user.h"
c@174 6 #include <math.h>
c@174 7
c@174 8 #include "kiss_fft.h"
c@174 9 #include "kiss_fftnd.h"
c@174 10 #include "kiss_fftr.h"
c@174 11
c@174 12 BEGIN_BENCH_DOC
c@174 13 BENCH_DOC("name", "kissfft")
c@174 14 BENCH_DOC("version", "1.0.1")
c@174 15 BENCH_DOC("year", "2004")
c@174 16 BENCH_DOC("author", "Mark Borgerding")
c@174 17 BENCH_DOC("language", "C")
c@174 18 BENCH_DOC("url", "http://sourceforge.net/projects/kissfft/")
c@174 19 BENCH_DOC("copyright",
c@174 20 "Copyright (c) 2003,4 Mark Borgerding\n"
c@174 21 "\n"
c@174 22 "All rights reserved.\n"
c@174 23 "\n"
c@174 24 "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n"
c@174 25 "\n"
c@174 26 " * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n"
c@174 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"
c@174 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"
c@174 29 "\n"
c@174 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")
c@174 31 END_BENCH_DOC
c@174 32
c@174 33 int can_do(struct problem *p)
c@174 34 {
c@174 35 if (p->rank == 1) {
c@174 36 if (p->kind == PROBLEM_REAL) {
c@174 37 return (p->n[0] & 1) == 0; /* only even real is okay */
c@174 38 } else {
c@174 39 return 1;
c@174 40 }
c@174 41 } else {
c@174 42 return p->kind == PROBLEM_COMPLEX;
c@174 43 }
c@174 44 }
c@174 45
c@174 46 static kiss_fft_cfg cfg=NULL;
c@174 47 static kiss_fftr_cfg cfgr=NULL;
c@174 48 static kiss_fftnd_cfg cfgnd=NULL;
c@174 49
c@174 50 #define FAILIF( c ) \
c@174 51 if ( c ) do {\
c@174 52 fprintf(stderr,\
c@174 53 "kissfft: " #c " (file=%s:%d errno=%d %s)\n",\
c@174 54 __FILE__,__LINE__ , errno,strerror( errno ) ) ;\
c@174 55 exit(1);\
c@174 56 }while(0)
c@174 57
c@174 58
c@174 59
c@174 60 void setup(struct problem *p)
c@174 61 {
c@174 62 size_t i;
c@174 63
c@174 64 /*
c@174 65 fprintf(stderr,"%s %s %d-d ",
c@174 66 (p->sign == 1)?"Inverse":"Forward",
c@174 67 p->kind == PROBLEM_COMPLEX?"Complex":"Real",
c@174 68 p->rank);
c@174 69 */
c@174 70 if (p->rank == 1) {
c@174 71 if (p->kind == PROBLEM_COMPLEX) {
c@174 72 cfg = kiss_fft_alloc (p->n[0], (p->sign == 1), 0, 0);
c@174 73 FAILIF(cfg==NULL);
c@174 74 }else{
c@174 75 cfgr = kiss_fftr_alloc (p->n[0], (p->sign == 1), 0, 0);
c@174 76 FAILIF(cfgr==NULL);
c@174 77 }
c@174 78 }else{
c@174 79 int dims[5];
c@174 80 for (i=0;i<p->rank;++i){
c@174 81 dims[i] = p->n[i];
c@174 82 }
c@174 83 /* multi-dimensional */
c@174 84 if (p->kind == PROBLEM_COMPLEX) {
c@174 85 cfgnd = kiss_fftnd_alloc( dims , p->rank, (p->sign == 1), 0, 0 );
c@174 86 FAILIF(cfgnd==NULL);
c@174 87 }
c@174 88 }
c@174 89 }
c@174 90
c@174 91 void doit(int iter, struct problem *p)
c@174 92 {
c@174 93 int i;
c@174 94 void *in = p->in;
c@174 95 void *out = p->out;
c@174 96
c@174 97 if (p->in_place)
c@174 98 out = p->in;
c@174 99
c@174 100 if (p->rank == 1) {
c@174 101 if (p->kind == PROBLEM_COMPLEX){
c@174 102 for (i = 0; i < iter; ++i)
c@174 103 kiss_fft (cfg, in, out);
c@174 104 } else {
c@174 105 /* PROBLEM_REAL */
c@174 106 if (p->sign == -1) /* FORWARD */
c@174 107 for (i = 0; i < iter; ++i)
c@174 108 kiss_fftr (cfgr, in, out);
c@174 109 else
c@174 110 for (i = 0; i < iter; ++i)
c@174 111 kiss_fftri (cfgr, in, out);
c@174 112 }
c@174 113 }else{
c@174 114 /* multi-dimensional */
c@174 115 for (i = 0; i < iter; ++i)
c@174 116 kiss_fftnd(cfgnd,in,out);
c@174 117 }
c@174 118 }
c@174 119
c@174 120 void done(struct problem *p)
c@174 121 {
c@174 122 free(cfg);
c@174 123 cfg=NULL;
c@174 124 free(cfgr);
c@174 125 cfgr=NULL;
c@174 126 free(cfgnd);
c@174 127 cfgnd=NULL;
c@174 128 UNUSED(p);
c@174 129 }