From bf5195414a60ad17f4cd18feb68c74d3d7aa8467 Mon Sep 17 00:00:00 2001 From: Steven Franke Date: Sun, 3 Apr 2016 00:33:21 +0000 Subject: [PATCH] Tweaks to wsprd_exp. Apply Pavel's double->float patch, fix long-standing 1-second dt offset, retune metric bias to lower false-decode probability. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6571 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/wsprd/Makefile | 2 +- lib/wsprd/wsprd.c | 4 +- lib/wsprd/wsprd_exp.c | 271 +++++++++++++++++++++--------------------- 3 files changed, 138 insertions(+), 139 deletions(-) diff --git a/lib/wsprd/Makefile b/lib/wsprd/Makefile index 3849e7bc0..097c0b7d4 100644 --- a/lib/wsprd/Makefile +++ b/lib/wsprd/Makefile @@ -5,7 +5,7 @@ FC = gfortran CFLAGS= -I/usr/include -Wall -Wno-missing-braces -O3 -ffast-math LDFLAGS = -L/usr/lib FFLAGS = -O2 -Wall -Wno-conversion -LIBS = -lfftw3 -lm +LIBS = -lfftw3f -lm # Default rules %.o: %.c $(DEPS) diff --git a/lib/wsprd/wsprd.c b/lib/wsprd/wsprd.c index 19d7d7e7b..eb689de71 100644 --- a/lib/wsprd/wsprd.c +++ b/lib/wsprd/wsprd.c @@ -40,7 +40,7 @@ #include "nhash.h" #include "wsprd_utils.h" #include "wsprsim_utils.h" -#include "lib/init_random_seed.h" +//#include "lib/init_random_seed.h" #define max(x,y) ((x) > (y) ? (x) : (y)) // Possible PATIENCE options: FFTW_ESTIMATE, FFTW_ESTIMATE_PATIENT, @@ -616,7 +616,7 @@ int main(int argc, char *argv[]) int uniques=0, noprint=0; - init_random_seed(); +// init_random_seed(); // Parameters used for performance-tuning: maxcycles=10000; //Fano timeout limit diff --git a/lib/wsprd/wsprd_exp.c b/lib/wsprd/wsprd_exp.c index 3cf0599c1..391661e08 100644 --- a/lib/wsprd/wsprd_exp.c +++ b/lib/wsprd/wsprd_exp.c @@ -46,7 +46,7 @@ // Possible PATIENCE options: FFTW_ESTIMATE, FFTW_ESTIMATE_PATIENT, // FFTW_MEASURE, FFTW_PATIENT, FFTW_EXHAUSTIVE #define PATIENCE FFTW_ESTIMATE -fftw_plan PLAN1,PLAN2,PLAN3; +fftwf_plan PLAN1,PLAN2,PLAN3; unsigned char pr3[162]= {1,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0, @@ -64,7 +64,7 @@ unsigned long nr; int printdata=0; //*************************************************************************** -unsigned long readc2file(char *ptr_to_infile, double *idat, double *qdat, +unsigned long readc2file(char *ptr_to_infile, float *idat, float *qdat, double *freq, int *wspr_type) { float *buffer; @@ -99,10 +99,11 @@ unsigned long readc2file(char *ptr_to_infile, double *idat, double *qdat, } else { return 1; } + free(buffer); } //*************************************************************************** -unsigned long readwavfile(char *ptr_to_infile, int ntrmin, double *idat, double *qdat ) +unsigned long readwavfile(char *ptr_to_infile, int ntrmin, float *idat, float *qdat ) { unsigned long i, j, npoints; int nfft1, nfft2, nh2, i0; @@ -126,8 +127,8 @@ unsigned long readwavfile(char *ptr_to_infile, int ntrmin, double *idat, double return 1; } - double *realin; - fftw_complex *fftin, *fftout; + float *realin; + fftwf_complex *fftin, *fftout; FILE *fp; short int *buf2; @@ -142,9 +143,9 @@ unsigned long readwavfile(char *ptr_to_infile, int ntrmin, double *idat, double nr=fread(buf2,2,npoints,fp); //Read raw data fclose(fp); - realin=(double*) fftw_malloc(sizeof(double)*nfft1); - fftout=(fftw_complex*) fftw_malloc(sizeof(fftw_complex)*nfft1); - PLAN1 = fftw_plan_dft_r2c_1d(nfft1, realin, fftout, PATIENCE); + realin=(float*) fftwf_malloc(sizeof(float)*nfft1); + fftout=(fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex)*nfft1); + PLAN1 = fftwf_plan_dft_r2c_1d(nfft1, realin, fftout, PATIENCE); for (i=0; i 0 && ndecodes_pass == 0 ) break; ndecodes_pass=0; - memset(ps,0.0, sizeof(double)*512*nffts); + memset(ps,0.0, sizeof(float)*512*nffts); for (i=0; i511 ) @@ -828,7 +827,7 @@ int main(int argc, char *argv[]) } // Compute average spectrum - memset(psavg,0.0, sizeof(double)*512); + memset(psavg,0.0, sizeof(float)*512); for (i=0; i minsync1 ) { @@ -1073,14 +1072,14 @@ int main(int argc, char *argv[]) t0 = clock(); sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1, lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 0); - tsync0 += (double)(clock()-t0)/CLOCKS_PER_SEC; + tsync0 += (float)(clock()-t0)/CLOCKS_PER_SEC; // fine search over frequency fstep=0.05; ifmin=-2; ifmax=2; t0 = clock(); sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &shift1, lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 1); - tsync1 += (double)(clock()-t0)/CLOCKS_PER_SEC; + tsync1 += (float)(clock()-t0)/CLOCKS_PER_SEC; worth_a_try = 1; } else { @@ -1088,7 +1087,7 @@ int main(int argc, char *argv[]) } int idt=0, ii=0, jiggered_shift; - double y,sq,rms; + float y,sq,rms; not_decoded=1; while ( worth_a_try && not_decoded && idt<=(128/iifac)) { @@ -1102,11 +1101,11 @@ int main(int argc, char *argv[]) sync_and_demodulate(idat, qdat, npoints, symbols, &f1, ifmin, ifmax, fstep, &jiggered_shift, lagmin, lagmax, lagstep, &drift1, symfac, &sync1, 2); - tsync2 += (double)(clock()-t0)/CLOCKS_PER_SEC; + tsync2 += (float)(clock()-t0)/CLOCKS_PER_SEC; sq=0.0; for(i=0; i<162; i++) { - y=(double)symbols[i] - 128.0; + y=(float)symbols[i] - 128.0; sq += y*y; } rms=sqrt(sq/162.0); @@ -1123,7 +1122,7 @@ int main(int argc, char *argv[]) mettab,delta,maxcycles); } - tfano += (double)(clock()-t0)/CLOCKS_PER_SEC; + tfano += (float)(clock()-t0)/CLOCKS_PER_SEC; } idt++; @@ -1174,10 +1173,10 @@ int main(int argc, char *argv[]) if( wspr_type == 15 ) { freq_print=dialfreq+(1500+112.5+f1/8.0)/1e6; - dt_print=shift1*8*dt-2.0; + dt_print=shift1*8*dt-1.0; } else { freq_print=dialfreq+(1500+f1)/1e6; - dt_print=shift1*dt-2.0; + dt_print=shift1*dt-1.0; } strcpy(decodes[uniques-1].date,date); @@ -1236,15 +1235,15 @@ int main(int argc, char *argv[]) } printf("\n"); - fftw_free(fftin); - fftw_free(fftout); + fftwf_free(fftin); + fftwf_free(fftout); - if ((fp_fftw_wisdom_file = fopen(wisdom_fname, "w"))) { - fftw_export_wisdom_to_file(fp_fftw_wisdom_file); - fclose(fp_fftw_wisdom_file); + if ((fp_fftwf_wisdom_file = fopen(wisdom_fname, "w"))) { + fftwf_export_wisdom_to_file(fp_fftwf_wisdom_file); + fclose(fp_fftwf_wisdom_file); } - ttotal += (double)(clock()-t00)/CLOCKS_PER_SEC; + ttotal += (float)(clock()-t00)/CLOCKS_PER_SEC; fprintf(ftimer,"%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n\n", treadwav,tcandidates,tsync0,tsync1,tsync2,tfano,ttotal); @@ -1265,9 +1264,9 @@ int main(int argc, char *argv[]) fclose(fwsprd); // fclose(fdiag); fclose(ftimer); - fftw_destroy_plan(PLAN1); - fftw_destroy_plan(PLAN2); - fftw_destroy_plan(PLAN3); + fftwf_destroy_plan(PLAN1); + fftwf_destroy_plan(PLAN2); + fftwf_destroy_plan(PLAN3); if( usehashtable ) { fhash=fopen(hash_fname,"w");