Example #1
0
static void init_parameters(
    int argc, char **argv,
    int *n, int *iter,
    int *inplace, int* patience
    )
{
  pfft_get_args(argc, argv, "-pfft_n", 3, PFFT_INT, n);
  pfft_get_args(argc, argv, "-pfft_iter", 1, PFFT_INT, iter); 
  pfft_get_args(argc, argv, "-pfft_ip", 1, PFFT_INT, inplace);
  pfft_get_args(argc, argv, "-pfft_pat", 1, PFFT_INT, patience);
}
static void init_parameters(
    int argc, char **argv,
    ptrdiff_t *n, int *np, ptrdiff_t *gc_below, ptrdiff_t *gc_above,
    int* verbose
    )
{
  pfft_get_args(argc, argv, "-pfft_n", 3, PFFT_PTRDIFF_T, n);
  pfft_get_args(argc, argv, "-pfft_np", 3, PFFT_INT, np);
  pfft_get_args(argc, argv, "-pfft_gcb", 3, PFFT_PTRDIFF_T, gc_below);
  pfft_get_args(argc, argv, "-pfft_gca", 3, PFFT_PTRDIFF_T, gc_above);
  pfft_get_args(argc, argv, "-pfft_verb", 1, PFFT_INT, verbose);
}
Example #3
0
static void init_parameters(
    int argc, char **argv,
    ptrdiff_t *n, int *np, int *loops, int *inplace,
    unsigned *opt_flag, unsigned *tune_flag, unsigned *destroy_input_flag 
    )
{
  int opt=0, tune=0, destroy_input=0;

  pfft_get_args(argc, argv, "-pfft_n", 3, PFFT_PTRDIFF_T, n);
  pfft_get_args(argc, argv, "-pfft_np", 2, PFFT_INT, np);
  pfft_get_args(argc, argv, "-pfft_loops", 1, PFFT_INT, loops);
  pfft_get_args(argc, argv, "-pfft_ip", 1, PFFT_INT, inplace);
  pfft_get_args(argc, argv, "-pfft_opt", 1, PFFT_INT, &opt);
  pfft_get_args(argc, argv, "-pfft_tune", 1, PFFT_INT, &tune);
  pfft_get_args(argc, argv, "-pfft_di", 1, PFFT_INT, &destroy_input);


  switch(opt){
    case 1: *opt_flag = PFFT_MEASURE; break;
    case 2: *opt_flag = PFFT_PATIENT; break;
    case 3: *opt_flag = PFFT_EXHAUSTIVE; break;
  }

  if(destroy_input)
    *destroy_input_flag = PFFT_DESTROY_INPUT;

  if(tune)
    *tune_flag = PFFT_TUNE;
}
Example #4
0
static void init_parameters(
    int argc, char **argv,
    ptrdiff_t *N, ptrdiff_t *n, ptrdiff_t *local_M,
    int *m, int *window, int *intpol, int *interlacing,
    double *x_max, int *np
    )
{
  pfft_get_args(argc, argv, "-pnfft_local_M", 1, PFFT_PTRDIFF_T, local_M);
  pfft_get_args(argc, argv, "-pnfft_N", 3, PFFT_PTRDIFF_T, N);
  pfft_get_args(argc, argv, "-pnfft_n", 3, PFFT_PTRDIFF_T, n);
  pfft_get_args(argc, argv, "-pnfft_np", 3, PFFT_INT, np);
  pfft_get_args(argc, argv, "-pnfft_m", 1, PFFT_INT, m);
  pfft_get_args(argc, argv, "-pnfft_window", 1, PFFT_INT, window);
  pfft_get_args(argc, argv, "-pnfft_intpol", 1, PFFT_INT, intpol);
  pfft_get_args(argc, argv, "-pnfft_interlacing", 1, PFFT_INT, interlacing);
  pfft_get_args(argc, argv, "-pnfft_x_max", 3, PFFT_DOUBLE, x_max);
}
Example #5
0
int main(int argc, char **argv)
{
  int nthreads=1; /*number of threads to initialize openmp with*/
  int runs=1; /*number of runs for testing*/
  int np[2];
  ptrdiff_t n[3];
  ptrdiff_t alloc_local;
  ptrdiff_t local_ni[3], local_i_start[3];
  ptrdiff_t local_no[3], local_o_start[3];
  double err;
  pfft_complex *in, *out;
  pfft_plan plan_forw=NULL, plan_back=NULL;
  MPI_Comm comm_cart_2d;

  /* Init OpenMP */
  pfft_get_args(argc,argv,"-pfft_omp_threads",1,PFFT_INT,&nthreads);
  pfft_get_args(argc,argv,"-pfft_runs",1,PFFT_INT,&runs);
  pfft_plan_with_nthreads(nthreads);

  /* Set size of FFT and process mesh */
  n[0] = NNN;n[1] =NNN; n[2] =NNN;
  np[0] = 1; np[1] = 1;
  
  /* Initialize MPI and PFFT */
  MPI_Init(&argc, &argv);
  pfft_init();

  pfft_plan_with_nthreads(nthreads);
  pfft_printf(MPI_COMM_WORLD, "# %4d threads will be used for openmp (default is 1)\n", nthreads);

 /* Create two-dimensional process grid of size np[0] x np[1], if possible */
  if( pfft_create_procmesh_2d(MPI_COMM_WORLD, np[0], np[1], &comm_cart_2d) ){
    pfft_fprintf(MPI_COMM_WORLD, stderr, "Error: This test file only works with %d processes.\n", np[0]*np[1]);
    MPI_Finalize();
    return 1;
  }

  /* Get parameters of data distribution */
  alloc_local = pfft_local_size_dft_3d(n, comm_cart_2d, PFFT_TRANSPOSED_NONE,
      local_ni, local_i_start, local_no, local_o_start);

  /* Allocate memory */
  in  = pfft_alloc_complex(alloc_local);
  out = pfft_alloc_complex(alloc_local);

  /* Plan parallel forward FFT */
  plan_forw = pfft_plan_dft_3d(
      n, in, out, comm_cart_2d, PFFT_FORWARD, PFFT_TRANSPOSED_OUT| PFFT_MEASURE| PFFT_DESTROY_INPUT| PFFT_TUNE| PFFT_SHIFTED_IN);
  
  /* Plan parallel backward FFT */
  plan_back = pfft_plan_dft_3d(
      n, out, in, comm_cart_2d, PFFT_BACKWARD, PFFT_TRANSPOSED_IN| PFFT_MEASURE| PFFT_DESTROY_INPUT| PFFT_TUNE| PFFT_SHIFTED_OUT);

  /* Initialize input with random numbers */
  pfft_init_input_complex_3d(n, local_ni, local_i_start,
      in);

  for(int i=0; i<runs; i++)
  {
    /* execute parallel forward FFT */
    pfft_execute(plan_forw);

    /* clear the old input */
    /* pfft_clear_input_complex_3d(n, local_ni, local_i_start,
        in);
    */
    /* execute parallel backward FFT */
    pfft_execute(plan_back);

    /* Scale data */
    ptrdiff_t l;
    for(l=0; l < local_ni[0] * local_ni[1] * local_ni[2]; l++)
      in[l] /= (n[0]*n[1]*n[2]);
  }

  pfft_print_average_timer_adv(plan_forw, MPI_COMM_WORLD);
  pfft_print_average_timer_adv(plan_back, MPI_COMM_WORLD);

  /* Print error of back transformed data */
  err = pfft_check_output_complex_3d(n, local_ni, local_i_start, in, comm_cart_2d);
  pfft_printf(comm_cart_2d, "Error after %d forward and backward trafos of size n=(%td, %td, %td):\n", runs, n[0], n[1], n[2]); 
  pfft_printf(comm_cart_2d, "maxerror = %6.2e;\n", err);
  
  /* free mem and finalize */
  pfft_destroy_plan(plan_forw);
  pfft_destroy_plan(plan_back);
  MPI_Comm_free(&comm_cart_2d);
  pfft_free(in); pfft_free(out);
  MPI_Finalize();
  return 0;
}
Example #6
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;

}