diff options
Diffstat (limited to 'plugins/supereq/shibatch_rdft.c')
-rw-r--r-- | plugins/supereq/shibatch_rdft.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/plugins/supereq/shibatch_rdft.c b/plugins/supereq/shibatch_rdft.c index 2a352f7e..db453eb8 100644 --- a/plugins/supereq/shibatch_rdft.c +++ b/plugins/supereq/shibatch_rdft.c @@ -6,34 +6,66 @@ #include "SIMDBase.h" #include "DFT.h" -typedef float REAL; #define TYPE SIMDBase_TYPE_FLOAT -void rfft(int n,int isign,REAL *x) { +void rfft(int n,int isign,float *x) { static DFT *p = NULL; + static float *buf = NULL; static int ipsize = 0; static int mode = 0; + static int veclen = 0; int newipsize; if (n == 0) { + if (buf) { + SIMDBase_alignedFree (buf); + buf = NULL; + } if (p) { DFT_dispose(p, mode); p = NULL; } return; } - n = 1 << n; - newipsize = 2+sqrt(n/2); - if (newipsize > ipsize) { + int nn = n; + n = 1<<n; + newipsize = n; + if (newipsize != ipsize) { ipsize = newipsize; + if (buf) { + SIMDBase_alignedFree (buf); + buf = NULL; + } + if (p) { DFT_dispose(p, mode); p = NULL; } + buf = SIMDBase_alignedMalloc (n * sizeof (float)); + mode = SIMDBase_chooseBestMode(TYPE); - p = DFT_init(mode, n, 0); + veclen = SIMDBase_getModeParamInt(SIMDBase_PARAMID_VECTOR_LEN, mode); + int sizeOfVect = SIMDBase_getModeParamInt(SIMDBase_PARAMID_SIZE_OF_VECT, mode); + printf ("n: %d, veclen: %d, sizeOfVect: %d\n", n, veclen, sizeOfVect); + p = DFT_init(mode, n/veclen, DFT_FLAG_REAL); + } + + // store in simd order + int asize = n / veclen; + int i, j; + for(j=0;j<veclen;j++) { + for (i = 0; i < asize; i++) { + buf[i * veclen + j] = x[j * asize + i]; + } } - DFT_execute(p, mode, x, 1); + DFT_execute(p, mode, buf, isign); + +#define THRES 1e-3 + for(j=0;j<veclen;j++) { + for (i = 0; i < asize; i++) { + x[j * asize + i] = buf[i * veclen + j]; + } + } } |