Exemplo n.º 1
0
void fft2_finalize()
/*< clean up fftw >*/
{
/* make sure everything is back to its pristine state */
#ifdef SF_HAS_FFTW
#ifdef _OPENMP
    fftwf_cleanup_threads();
#endif
    fftwf_destroy_plan(cfg);
    fftwf_destroy_plan(icfg);
    fftwf_cleanup();
    cfg=NULL;
    icfg=NULL;
#else
    if (NULL != cfg) { free(cfg); cfg=NULL; }
    if (NULL != icfg) { free(icfg); icfg=NULL; }
    if (NULL != cfg1) { free(cfg1); cfg1=NULL; }
    if (NULL != icfg1) { free(icfg1); icfg1=NULL; }
    if (NULL != cfg2) { free(cfg2); cfg2=NULL; }
    if (NULL != icfg2) { free(icfg2); icfg2=NULL; }
    if (NULL != tmp) { free(*tmp); free(tmp); tmp=NULL; }
    if (NULL != trace2) { free(trace2); trace2=NULL; }
#endif
    if (cmplx) {
      if (NULL != cc) { free(*cc); free(cc); cc=NULL; }
    } else {
      if (NULL != ff) { free(*ff); free(ff); ff=NULL; }
    }
    if (NULL != dd) { free(dd); dd=NULL; }
}
Exemplo n.º 2
0
void cfft3_finalize()
/*< clean up fftw >*/
{
#ifdef SF_HAS_FFTW
#ifdef _OPENMP
    fftwf_cleanup_threads();
#endif
    fftwf_destroy_plan(cfg);
    fftwf_destroy_plan(icfg);
    fftwf_cleanup();
    cfg=NULL;
    icfg=NULL;
#else
    free(cfg1); cfg1=NULL;
    free(icfg1); icfg1=NULL;
    free(cfg2); cfg2=NULL;
    free(icfg2); icfg2=NULL;
    free(cfg3); cfg3=NULL;
    free(icfg3); icfg3=NULL;
#endif

    free(**cc);
    free(*cc);
    free(cc);
}
Exemplo n.º 3
0
void cfft2_finalize()
/*< clean up fftw >*/
{
    /* make sure everything is back to its pristine state */
#ifdef SF_HAS_FFTW
#ifdef _OPENMP
    fftw_cleanup_threads();
#endif
    fftwf_destroy_plan(cfg);
    fftwf_destroy_plan(icfg);
    fftwf_cleanup();
    cfg=NULL;
    icfg=NULL;
#else
    free(cfg1);
    cfg1=NULL;
    free(icfg1);
    icfg1=NULL;
    free(cfg2);
    cfg2=NULL;
    free(icfg2);
    icfg2=NULL;
#endif

    free(*cc);
    free(cc);
    free(*dd);
    free(dd);
}
Exemplo n.º 4
0
Fourier::~Fourier()
{

  const char* fname = "void Fourier::Finalize()";

    //---- This is the last instance of Hamiltonian
    VRB.Debug(fname, "Deallocating memory and destoying plans for FFTW.");

#ifdef USE_SINGLE
    fftwf_free(b);
    fftwf_destroy_plan(p1);
    fftwf_destroy_plan(p2);
    fftwf_cleanup();
#endif
#ifdef USE_DOUBLE
    fftw_free(b);
    fftw_destroy_plan(p1);
    fftw_destroy_plan(p2);
    fftw_cleanup();
#endif
#ifdef USE_LONG_DOUBLE
    fftwl_free(b);
    fftwl_destroy_plan(p1);
    fftwl_destroy_plan(p2);
    fftwl_cleanup();
#endif


}
Exemplo n.º 5
0
void _fini()
#endif
{
#ifdef XTRACT_FFT
xtract_free_fft();
fftwf_cleanup();
#endif
}
Exemplo n.º 6
0
/**
 * Cleanup all resources allocated by Essentia.
 */
void shutdown() {
  fftwf_cleanup();
  standard::AlgorithmFactory::shutdown();
  streaming::AlgorithmFactory::shutdown();
  TypeMap::shutdown();

  _initialized = false;
}
Exemplo n.º 7
0
Arquivo: demo.c Projeto: psava/cwp12
int main(){
    int nthreads = 4;
    omp_set_num_threads(nthreads);
    #pragma omp parallel 
        fprintf(stderr,"nthreads %d \n", omp_get_num_threads());
 
    int n3 = 128;
    int n2 = 128;
    int n1 = 128;
//    float ***array = sf_floatalloc3(n1,n2,n3);
    
    float *array = fftwf_alloc_real(n3*n2*n1);
    fftwf_complex* cout = fftwf_alloc_complex(n3*n2*n1);

    int err = fftwf_init_threads();
    if (err == 0) {
        fprintf(stderr,"something went wrong with fftw\n");
    }

    fprintf(stderr,"Got here\n");

    double start,end;
    start = omp_get_wtime()*omp_get_wtick();
    fftwf_plan_with_nthreads(nthreads);
    fftwf_plan plan =  fftwf_plan_dft_r2c_3d(
                                    n1,n2,n3,
                                    array,cout,
                                    FFTW_MEASURE);
    end = omp_get_wtime()*omp_get_wtick();
    fprintf(stderr,"elapsed time: %f %f %f\n",end,start,end-start);

    for(int i = 0; i < n3*n2*n1; ++i)
        array[i] = rand()/RAND_MAX;
 
    //float start = clock()/CLOCKS_PER_SEC;
    start = omp_get_wtime();

    for(int i=0; i < 1001; ++i)
        fftwf_execute(plan);
   
    //float end = clock()/CLOCKS_PER_SEC;
    end = omp_get_wtime();
    fprintf(stderr,"elapsed time: %f time/calc %f\n",
        end-start,(end-start)/100.0);

    fftwf_cleanup_threads();
    fftwf_cleanup();
    fftwf_destroy_plan(plan);

    fftwf_free(cout);
    fftwf_free(array);
    //free(**array); free(*array); free(array);
    return 0;

}
Exemplo n.º 8
0
void conv_tilde_free_fft_plans(t_conv_tilde *x)
{
	int i;

	/* free storage vectors */
    for ( i = 0; i < x->channels; i++)
    {
        fftwf_free(x->stored_input[i]);
        fftwf_free(x->stored_ir[i]);
        fftwf_free(x->overlap_save[i]);
    }
    free(x->stored_input);
    free(x->stored_ir);
    free(x->overlap_save);

	/* free fft arrays */
	fftwf_free(x->input_complex);
	fftwf_free(x->ir_complex);
	fftwf_free(x->out_complex);
	fftwf_free(x->outTemp);

	#ifndef INPLACE
		fftwf_free(x->input_to_fft);
		fftwf_free(x->ir_to_fft);
	#endif

	/* destroy plans */
	fftwf_destroy_plan(x->fftplan_in);
	fftwf_destroy_plan(x->fftplan_ir);
	fftwf_destroy_plan(x->fftplan_inverse);

	#ifdef THREADS

		/* free fft arrays */
		fftwf_free(x->input_complex_2);
		fftwf_free(x->ir_complex_2);
		fftwf_free(x->out_complex_2);
		fftwf_free(x->outTemp_2);

		#ifndef INPLACE
			fftwf_free(x->input_to_fft_2);
			fftwf_free(x->ir_to_fft_2);
		#endif

		/* destroy plans */
		fftwf_destroy_plan(x->fftplan_in_2);
		fftwf_destroy_plan(x->fftplan_ir_2);
		fftwf_destroy_plan(x->fftplan_inverse_2);
	#endif


	/* Clean up to make sure all memory used by fftw is freed */
	//fftwf_cleanup_threads();
	fftwf_cleanup();
}
Exemplo n.º 9
0
/****** fft_end ************************************************************
PROTO	void fft_init(void)
PURPOSE	Clear up stuff set by FFT routines
INPUT	-.
OUTPUT	-.
NOTES	-.
AUTHOR	E. Bertin (IAP)
VERSION	26/06/2009
 ***/
void    fft_end(void)
 {

  if (firsttimeflag)
    {
    firsttimeflag = 0;
    fftwf_cleanup();
    }

  return;
  }
Exemplo n.º 10
0
void
aubio_cleanup (void)
{
#ifdef HAVE_FFTW3F
  fftwf_cleanup ();
#else
#ifdef HAVE_FFTW3
  fftw_cleanup ();
#endif
#endif
}
Exemplo n.º 11
0
ofxFftw::~ofxFftw() {
	if (fftPlan != NULL) {
		fftwf_destroy_plan(fftPlan);
		fftwf_free(fftIn);
		fftwf_free(fftOut);

		fftwf_destroy_plan(ifftPlan);
		fftwf_free(ifftIn);
		fftwf_free(ifftOut);
		fftwf_cleanup();
	}
}
Exemplo n.º 12
0
// wrapper around FFTW3 that computes the complex-valued Fourier transform
// of a real-valued image
static void fft_2dfloat(fftwf_complex *fx, float *x, int w, int h)
{
	fftwf_complex *a = fftwf_malloc(w*h*sizeof*a);

	//fprintf(stderr, "planning...\n");
	evoke_wisdom();
	fftwf_plan p = fftwf_plan_dft_2d(h, w, a, fx,
						FFTW_FORWARD, FFTW_ESTIMATE);
	bequeath_wisdom();
	//fprintf(stderr, "...planned!\n");

	FORI(w*h) a[i] = x[i]; // complex assignment!
	fftwf_execute(p);

	fftwf_destroy_plan(p);
	fftwf_free(a);
	fftwf_cleanup();
}
Exemplo n.º 13
0
/*--------------------------------------------------------------------------*/
void _fftwfC (void)  /*cleanup*/
{
  fftwf_cleanup();
  return;
}
Exemplo n.º 14
0
 static void cleanup(){
   fftwf_cleanup();
 }
Exemplo n.º 15
0
int main(int argc, char **argv) {
	int distance;
	int i, n;
	int ngroup, nseq, max_nseq;
	char ack_rx;

	if (argc < 3) {
		usage(argv[0]);
		exit(-1);
	}

	parse_args(argc,argv);

	max_nseq = CP_ISNORM(cp)?PHICH_NORM_NSEQUENCES:PHICH_EXT_NSEQUENCES;

	if (base_init()) {
		fprintf(stderr, "Error initializing memory\n");
		exit(-1);
	}

	n = filesource_read(&fsrc, input_buffer, flen);

	lte_fft_run(&fft, input_buffer, fft_buffer);

	if (fmatlab) {
		fprintf(fmatlab, "infft=");
		vec_fprint_c(fmatlab, input_buffer, flen);
		fprintf(fmatlab, ";\n");

		fprintf(fmatlab, "outfft=");
		vec_fprint_c(fmatlab, fft_buffer, CP_NSYMB(cp) * nof_prb * RE_X_RB);
		fprintf(fmatlab, ";\n");
	}

	/* Get channel estimates for each port */
	for (i=0;i<nof_ports;i++) {
		chest_ce_slot_port(&chest, fft_buffer, ce[i], 0, i);
		if (fmatlab) {
			chest_fprint(&chest, fmatlab, 0, i);
		}
	}

	INFO("Decoding PHICH\n", 0);

	/* Receive all PHICH groups and sequence numbers */
	for (ngroup=0;ngroup<phich_ngroups(&phich);ngroup++) {
		for (nseq=0;nseq<max_nseq;nseq++) {

			if (phich_decode(&phich, fft_buffer, ce, ngroup, nseq, numsubframe, &ack_rx, &distance)<0) {
				printf("Error decoding ACK\n");
				exit(-1);
			}

			INFO("%d/%d, ack_rx: %d, ns: %d, distance: %d\n",
					ngroup, nseq, ack_rx, numsubframe, distance);
		}
	}

	base_free();
	fftwf_cleanup();

	if (n < 0) {
		fprintf(stderr, "Error decoding phich\n");
		exit(-1);
	} else if (n == 0) {
		printf("Could not decode phich\n");
		exit(-1);
	} else {
		exit(0);
	}
}
Exemplo n.º 16
0
void FFT_cleanup()
{
    fftwf_cleanup();
}
Exemplo n.º 17
0
void Fft::CleanupFft(){
	fftwf_cleanup_threads();
	fftwf_cleanup();
}
Exemplo n.º 18
0
FftwPlugin::~FftwPlugin( void )
{
#if defined( FFTW_PLUGIN_SUPPORTED )
	fftwf_cleanup();
#endif
}
Exemplo n.º 19
0
void srslte_dft_exit() {
#ifdef FFTW_WISDOM_FILE
  fftwf_export_wisdom_to_filename(FFTW_WISDOM_FILE);
#endif
  fftwf_cleanup();
}