fftw_plan fft_plan_cc(
          int rank, const fftw_iodim *dims,
          int howmany_rank, const fftw_iodim *howmany_dims,
          fftw_complex *in, fftw_complex *out,
          unsigned flags){
  return fftw_plan_guru_dft(rank, dims, howmany_rank, howmany_dims, in, out, sign, flags);
}
示例#2
0
/*--------------------------------------------------------------------------*/
fftw_plan _fftwP (fftw_complex *in,   /* plan */
	          fftw_complex *out,
	          long ft_rank, long *ft_dims, long *ft_strides,
	          long ft_loop, long *loop_dims, long *loop_strides,
	          long dir)                         /* forward (1) or reverse (-1) */
{
  /* Declarations */
  int i;
  int sign= -1*dir;
  fftw_plan p;
  long plan_mode;
  fftw_iodim *id_fft;
  fftw_iodim *id_loop;

  plan_mode = FFTW_MEASURE; /* FFTW_ESTIMATE FFTW_MEASURE FFTW_PATIENT FFTW_EXHAUSTIVE;*/

  id_fft = (fftw_iodim *)fftw_malloc(sizeof(fftw_iodim) * ft_rank);
  id_loop = (fftw_iodim *)fftw_malloc(sizeof(fftw_iodim) * ft_loop);

  for (i = 0 ; i < ft_rank ; i++) {
    id_fft[i].n = ft_dims[i];
    id_fft[i].is = ft_strides[i];
    id_fft[i].os = ft_strides[i];
  }
  for (i = 0 ; i < ft_loop ; i++) {
    id_loop[i].n = loop_dims[i];
    id_loop[i].is = loop_strides[i];
    id_loop[i].os = loop_strides[i];
  }

  if (in == out){ /*in place*/
    p = fftw_plan_guru_dft((int)ft_rank, id_fft, (int)ft_loop, id_loop, in, in, sign, plan_mode);
  }else{
    p = fftw_plan_guru_dft((int)ft_rank, id_fft, (int)ft_loop, id_loop, in, out, sign, plan_mode);
  }

  fftw_free(id_fft);
  fftw_free(id_loop);

  return p;
}
示例#3
0
文件: transform.cpp 项目: kogn/scft
Space_trans::Space_trans(const Config & configSettings):Data(configSettings)
{
  fftw_iodim dims[DIM], howmany_dims[1];
  int rank = DIM;
  int howmany_rank = 1;
  if(DIM == 1){
    dims[0].n = m[0];
    dims[0].is = n3;
    dims[0].os = n3;
  }
  if(DIM == 2){
    dims[0].n = m[0];
    dims[0].is = n3;
    dims[0].os = n3;
    dims[1].n = m[1];
    dims[1].is = n3*m[0];
    dims[1].os = n3*m[0];
  }
  howmany_dims[0].n = n3;
  howmany_dims[0].is = 1;
  howmany_dims[0].os = 1;

  fftw_init_threads();
  fftw_plan_with_nthreads(NUM_THREADS);

  pf = fftw_plan_guru_dft( rank, dims,
      howmany_rank, howmany_dims,
      realdata, realdata,
      FFTW_FORWARD, FFTW_ESTIMATE );

  pi = fftw_plan_guru_dft( rank, dims,
      howmany_rank, howmany_dims,
      realdata, realdata,
      FFTW_BACKWARD, FFTW_ESTIMATE );
  fftw_plan_with_nthreads(1);
}
示例#4
0
Transformer_CPU::Transformer_CPU(int dim_x, int dim_y, int dim_z, int exp_x, int exp_y, int exp_z)
	: dim_x(dim_x), dim_y(dim_y), dim_z(dim_z), exp_x(exp_x), exp_y(exp_y), exp_z(exp_z)
{
	if (os::disable_SSE_for_FFTW()) {
		fftw_strategy |= FFTW_UNALIGNED; // see os.h for explanation
	}

	Matrix tmp(Shape(2, exp_x, exp_y, exp_z));
	Matrix::rw_accessor tmp_acc(tmp);
	double *tmp_inout = tmp_acc.ptr();

	// Create fftw plans
	fftw_iodim dims, loop;

	// X-Transform: (dim_y*dim_z) x 1d-C2C-FFT (length: exp_x) in x-direction, in-place transform
	dims.n = exp_x;
	dims.is = 1;
	dims.os = 1;
	
	loop.n = dim_y*dim_z;
	loop.is = exp_x;
	loop.os = exp_x/2+1;

	plan_x_r2c = fftw_plan_guru_dft_r2c(
		1, &dims, 
		1, &loop, 
		(      double*)tmp_inout,
		(fftw_complex*)tmp_inout, 
		fftw_strategy
	);
	assert(plan_x_r2c);

	dims.n = exp_x;
	dims.is = 1;
	dims.os = 1;
	
	loop.n = dim_y*dim_z;
	loop.is = exp_x/2+1;
	loop.os = exp_x;

	plan_x_c2r = fftw_plan_guru_dft_c2r(
		1, &dims, 
		1, &loop, 
		(fftw_complex*)tmp_inout, 
		(      double*)tmp_inout,
		fftw_strategy
	);
	assert(plan_x_c2r);

	// Y-Transform: (dim_z*exp_x/2+1) x 1d-C2C-FFT (length: exp_y) in x-direction, in-place transform
	dims.n = exp_y;
	dims.is = 1;
	dims.os = 1;
	
	loop.n = dim_z*(exp_x/2+1);
	loop.is = exp_y;
	loop.os = exp_y;

	plan_y_forw = fftw_plan_guru_dft(
		1, &dims,
		1, &loop,
		(fftw_complex*)tmp_inout, // in
		(fftw_complex*)tmp_inout, // out (-> in-place transform)
		FFTW_FORWARD,
		fftw_strategy
	);
	assert(plan_y_forw);

	plan_y_inv = fftw_plan_guru_dft(
		1, &dims,
		1, &loop,
		(fftw_complex*)tmp_inout, // in
		(fftw_complex*)tmp_inout, // out (-> in-place transform)
		FFTW_BACKWARD,
		fftw_strategy
	);
	assert(plan_y_inv);

	// Z-Transform: (exp_x/2+1*exp_y) x 1d-C2C-FFT (length: exp_z) in x-direction, in-place transform
	dims.n = exp_z;
	dims.is = 1;
	dims.os = 1;
	
	loop.n = (exp_x/2+1)*exp_y;
	loop.is = exp_z;
	loop.os = exp_z;

	plan_z_forw = fftw_plan_guru_dft(
		1, &dims,
		1, &loop,
		(fftw_complex*)tmp_inout, // in
		(fftw_complex*)tmp_inout, // out (-> in-place transform)
		FFTW_FORWARD,
		fftw_strategy
	);
	assert(plan_z_forw);

	plan_z_inv = fftw_plan_guru_dft(
		1, &dims,
		1, &loop,
		(fftw_complex*)tmp_inout, // in
		(fftw_complex*)tmp_inout, // out (-> in-place transform)
		FFTW_BACKWARD,
		fftw_strategy
	);
	assert(plan_z_inv);
}
示例#5
0
int main(int argc, char **argv)
{
  int rows=1,columns=1;
  int nthreads=1;
  int inplace=0;
  int measure=0;
  int runs=1;
  pfft_get_args(argc,argv,"-pfft_test_runs",1,PFFT_INT,&runs); 
  pfft_get_args(argc,argv,"-pfft_omp_threads",1,PFFT_INT,&nthreads); 
  pfft_get_args(argc,argv,"-pfft_omp_rows",1,PFFT_INT,&rows); 
  pfft_get_args(argc,argv,"-pfft_omp_columns",1,PFFT_INT,&columns); 
  pfft_get_args(argc,argv,"-pfft_omp_inplace",1,PFFT_SWITCH,&inplace); 
  pfft_get_args(argc,argv,"-pfft_omp_measure",1,PFFT_SWITCH,&measure); 
  if(inplace!=1) inplace=0;

/*  printf("Enter a number:");
  scanf("%d",&nthreads);
  printf("\n");*/
  fftw_complex*m1 = (fftw_complex *) fftw_malloc(sizeof(fftw_complex)*rows*columns);
  fftw_complex*m2 = (fftw_complex *) fftw_malloc(sizeof(fftw_complex)*rows*columns);
  fftw_iodim howmany_dims[2];
  howmany_dims[0].n=rows;
  howmany_dims[0].is=columns;
  howmany_dims[0].os=1;
  howmany_dims[1].n=columns;
  howmany_dims[1].is=1;
  howmany_dims[1].os=rows;
  const int howmany_rank = 2;
  // init OMP threads for fftw
  fftw_init_threads();
  fftw_plan_with_nthreads(nthreads);
  
  fftw_plan plan_transpose_outplace,plan_transpose_inplace,plansimple2d;

  int fftw_flags=FFTW_ESTIMATE;
  if(measure==1) fftw_flags=FFTW_MEASURE;


  plan_transpose_outplace = fftw_plan_guru_dft(/*rank*/ 0,NULL,howmany_rank, howmany_dims,m1,m2,FFTW_FORWARD,fftw_flags);
  plan_transpose_inplace = fftw_plan_guru_dft(/*rank*/ 0,NULL,howmany_rank, howmany_dims,m1,m1,FFTW_FORWARD,fftw_flags);
/*  plansimple2d=fftw_plan_2d()*/
  /*plansimple2d=fftw_plan_dft_2d(rows,columns,m1,m1,FFTW_FORWARD,FFTW_ESTIMATE);*/
  
  /*printf("# rows=%d, columns=%d, threads=%d,inplace=%d, measure=%d\n",rows,columns,nthreads,inplace,measure);
  initialize_matrix(m1,rows,columns);
  printf("# start calculation...\n");*/
  /*  printf("# check");*/
  /* printmatrix(m1,rows,columns);*/
  
  struct timeval t1,t2;
  gettimeofday(&t1,NULL);
   
  int i;
  for(i=0;i<runs;i++)
  {
    if(inplace==1) fftw_execute(plan_transpose_inplace);  
    if(inplace==0) fftw_execute(plan_transpose_outplace);  
  }
  /*if(selectplan==3) fftw_execute(plansimple2d);*/
  
  gettimeofday(&t2,NULL);
  float seconds=t2.tv_sec-t1.tv_sec+(t2.tv_usec-t1.tv_usec)/1000000.0;
  printf("# output: rows,cols,inplace,,measure,threads,runs,total time,average time\n");
  printf("%d %d %d %d %d %d %.6f %6f\n",rows,columns,inplace,measure,nthreads,runs,seconds,seconds/runs);
 /* printmatrix(m1,rows,columns);*/
  free(m1);
  free(m2);
  return 0;

}