int main(int argc, char **argv){ int np[3], m, window; unsigned window_flag; ptrdiff_t N[3], n[3], local_M; double f_hat_sum, x_max[3]; pnfft_complex *f1, *f2; MPI_Init(&argc, &argv); pnfft_init(); /* set default values */ N[0] = N[1] = N[2] = 16; n[0] = n[1] = n[2] = 0; local_M = 0; m = 6; window = 4; x_max[0] = x_max[1] = x_max[2] = 0.5; np[0]=2; np[1]=2; np[2]=2; /* set parameters by command line */ init_parameters(argc, argv, N, n, &local_M, &m, &window, x_max, np); /* if M or n are set to zero, we choose nice values */ local_M = (local_M==0) ? N[0]*N[1]*N[2]/(np[0]*np[1]*np[2]) : local_M; for(int t=0; t<3; t++) n[t] = (n[t]==0) ? 2*N[t] : n[t]; switch(window){ case 0: window_flag = PNFFT_WINDOW_GAUSSIAN; break; case 1: window_flag = PNFFT_WINDOW_BSPLINE; break; case 2: window_flag = PNFFT_WINDOW_SINC_POWER; break; case 3: window_flag = PNFFT_WINDOW_BESSEL_I0; break; default: window_flag = PNFFT_WINDOW_KAISER_BESSEL; } pfft_printf(MPI_COMM_WORLD, "******************************************************************************************************\n"); pfft_printf(MPI_COMM_WORLD, "* Computation of parallel NFFT\n"); pfft_printf(MPI_COMM_WORLD, "* for N[0] x N[1] x N[2] = %td x %td x %td Fourier coefficients (change with -pnfft_N * * *)\n", N[0], N[1], N[2]); pfft_printf(MPI_COMM_WORLD, "* at local_M = %td nodes per process (change with -pnfft_local_M *)\n", local_M); pfft_printf(MPI_COMM_WORLD, "* with n[0] x n[1] x n[2] = %td x %td x %td FFT grid size (change with -pnfft_n * * *),\n", n[0], n[1], n[2]); pfft_printf(MPI_COMM_WORLD, "* m = %d real space cutoff (change with -pnfft_m *),\n", m); pfft_printf(MPI_COMM_WORLD, "* window = %d window function ", window); switch(window){ case 0: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_GAUSSIAN) "); break; case 1: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_BSPLINE) "); break; case 2: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_SINC_POWER) "); break; case 3: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_BESSEL_I0) "); break; default: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_KAISER_BESSEL) "); break; } pfft_printf(MPI_COMM_WORLD, "(change with -pnfft_window *),\n"); pfft_printf(MPI_COMM_WORLD, "* on np[0] x np[1] x np[2] = %td x %td x %td processes (change with -pnfft_np * * *)\n", np[0], np[1], np[2]); pfft_printf(MPI_COMM_WORLD, "*******************************************************************************************************\n\n"); /* calculate parallel NFFT */ pnfft_perform_guru(N, n, local_M, m, x_max, window_flag, np, MPI_COMM_WORLD, &f1, &f_hat_sum); /* calculate parallel NFFT with higher accuracy */ pnfft_perform_guru(N, n, local_M, m+2, x_max, PNFFT_WINDOW_KAISER_BESSEL, np, MPI_COMM_WORLD, &f2, &f_hat_sum); /* calculate error of PNFFT */ compare_f(f1, f2, local_M, f_hat_sum, "* Results in", MPI_COMM_WORLD); /* free mem and finalize */ pnfft_free(f1); pnfft_free(f2); pnfft_cleanup(); MPI_Finalize(); return 0; }
int main(int argc, char **argv){ int np[3]; ptrdiff_t N[3], local_M; ptrdiff_t local_N[3], local_N_start[3]; double lower_border[3], upper_border[3]; MPI_Comm comm_cart_3d; pnfft_complex *f_hat, *f; double *x; pnfft_plan pnfft; MPI_Init(&argc, &argv); pnfft_init(); /* Set default values */ N[0] = N[1] = N[2] = 16; np[0]=2; np[1]=2; np[2]=2; local_M = N[0]*N[1]*N[2]/(np[0]*np[1]*np[2]); /* Print infos */ pfft_printf(MPI_COMM_WORLD, "******************************************************************************************************\n"); pfft_printf(MPI_COMM_WORLD, "* Computation of parallel NFFT\n"); pfft_printf(MPI_COMM_WORLD, "* for N[0] x N[1] x N[2] = %td x %td x %td Fourier coefficients\n", N[0], N[1], N[2]); pfft_printf(MPI_COMM_WORLD, "* at local_M = %td nodes per process\n", local_M); pfft_printf(MPI_COMM_WORLD, "* on np[0] x np[1] x np[2] = %td x %td x %td processes\n", np[0], np[1], np[2]); pfft_printf(MPI_COMM_WORLD, "*******************************************************************************************************\n\n"); /* create three-dimensional process grid of size np[0] x np[1] x np[2], if possible */ if( pnfft_create_procmesh(3, MPI_COMM_WORLD, np, &comm_cart_3d) ){ pfft_fprintf(MPI_COMM_WORLD, stderr, "Error: Procmesh of size %d x %d x %d does not fit to number of allocated processes.\n", np[0], np[1], np[2]); pfft_fprintf(MPI_COMM_WORLD, stderr, " Please allocate %d processes (mpiexec -np %d ...) or change the procmesh (with -pnfft_np * * *).\n", np[0]*np[1]*np[2], np[0]*np[1]*np[2]); MPI_Finalize(); return 1; } /* Get parameters of data distribution */ pnfft_local_size_3d(N, comm_cart_3d, PNFFT_TRANSPOSED_NONE, local_N, local_N_start, lower_border, upper_border); /* Plan parallel NFFT */ pnfft = pnfft_init_3d(N, local_M, comm_cart_3d); /* Get data pointers */ f_hat = pnfft_get_f_hat(pnfft); f = pnfft_get_f(pnfft); x = pnfft_get_x(pnfft); /* Initialize Fourier coefficients */ pnfft_init_f_hat_3d(N, local_N, local_N_start, PNFFT_TRANSPOSED_NONE, f_hat); /* Initialize nonequispaced nodes */ init_random_x(lower_border, upper_border, local_M, x); /* Print input Fourier coefficents */ vpr_complex(comm_cart_3d, 8, f_hat, "Input Fourier coefficients on process 1:"); /* Execute parallel NFFT */ pnfft_trafo(pnfft); /* Print NFFT results */ vpr_complex(comm_cart_3d, 8, f, "PNFFT Results on process 1:"); /* Execute parallel adjoint NFFT */ pnfft_adj(pnfft); /* Scale data */ for(ptrdiff_t l=0; l < local_N[0] * local_N[1] * local_N[2]; l++) f_hat[l] /= (N[0]*N[1]*N[2]); /* Print output Fourier coefficents */ vpr_complex(comm_cart_3d, 8, f_hat, "Fourier coefficients after one forward and backward PNFFT on process 1:"); /* free mem and finalize */ pnfft_finalize(pnfft, PNFFT_FREE_X | PNFFT_FREE_F_HAT| PNFFT_FREE_F); MPI_Comm_free(&comm_cart_3d); pnfft_cleanup(); MPI_Finalize(); return 0; }
int main(int argc, char **argv){ int np[3], m, window, interlacing; ptrdiff_t N[3], n[3], local_M; double x_max[3]; MPI_Init(&argc, &argv); pnfft_init(); /* set default values */ N[0] = N[1] = N[2] = 16; n[0] = n[1] = n[2] = 0; local_M = 0; m = 6; window = 4; interlacing = 0; x_max[0] = x_max[1] = x_max[2] = 0.5; np[0]=2; np[1]=2; np[2]=2; /* set parameters by command line */ int intpol = -1; init_parameters(argc, argv, N, n, &local_M, &m, &window, &intpol, &interlacing, x_max, np); /* if M or n are set to zero, we choose nice values */ local_M = (local_M==0) ? N[0]*N[1]*N[2]/(np[0]*np[1]*np[2]) : local_M; for(int t=0; t<3; t++) n[t] = (n[t]==0) ? 2*N[t] : n[t]; unsigned window_flag; switch(window){ case 0: window_flag = PNFFT_WINDOW_GAUSSIAN; break; case 1: window_flag = PNFFT_WINDOW_BSPLINE; break; case 2: window_flag = PNFFT_WINDOW_SINC_POWER; break; case 3: window_flag = PNFFT_WINDOW_BESSEL_I0; break; case 4: window_flag = PNFFT_WINDOW_KAISER_BESSEL; break; case 5: window_flag = PNFFT_WINDOW_GAUSSIAN_T; break; default: window_flag = PNFFT_WINDOW_GAUSSIAN; window = 0; } unsigned intpol_flag; switch(intpol){ case 0: intpol_flag = PNFFT_PRE_CONST_PSI; break; case 1: intpol_flag = PNFFT_PRE_LIN_PSI; break; case 2: intpol_flag = PNFFT_PRE_QUAD_PSI; break; case 3: intpol_flag = PNFFT_PRE_CUB_PSI; break; default: intpol_flag = (window==0) ? PNFFT_FG_PSI : 0; } unsigned interlacing_flag = (interlacing) ? PNFFT_INTERLACED : 0; pfft_printf(MPI_COMM_WORLD, "******************************************************************************************************\n"); pfft_printf(MPI_COMM_WORLD, "* Computation of parallel NFFT\n"); pfft_printf(MPI_COMM_WORLD, "* for N[0] x N[1] x N[2] = %td x %td x %td Fourier coefficients (change with -pnfft_N * * *)\n", N[0], N[1], N[2]); pfft_printf(MPI_COMM_WORLD, "* at local_M = %td nodes per process (change with -pnfft_local_M *)\n", local_M); pfft_printf(MPI_COMM_WORLD, "* with n[0] x n[1] x n[2] = %td x %td x %td FFT grid size (change with -pnfft_n * * *),\n", n[0], n[1], n[2]); pfft_printf(MPI_COMM_WORLD, "* m = %d real space cutoff (change with -pnfft_m *),\n", m); pfft_printf(MPI_COMM_WORLD, "* window = %d window function ", window); switch(window){ case 0: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_GAUSSIAN) "); break; case 1: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_BSPLINE) "); break; case 2: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_SINC_POWER) "); break; case 3: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_BESSEL_I0) "); break; case 4: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_KAISER_BESSEL) "); break; case 5: pfft_printf(MPI_COMM_WORLD, "(PNFFT_WINDOW_GAUSSIAN_T) "); break; } pfft_printf(MPI_COMM_WORLD, "(change with -pnfft_window *),\n"); pfft_printf(MPI_COMM_WORLD, "* intpol = %d interpolation order ", intpol); switch(intpol){ case 0: pfft_printf(MPI_COMM_WORLD, "(PNFFT_PRE_CONST_PSI) "); break; case 1: pfft_printf(MPI_COMM_WORLD, "(PNFFT_PRE_LIN_PSI) "); break; case 2: pfft_printf(MPI_COMM_WORLD, "(PNFFT_PRE_QUAD_PSI) "); break; case 3: pfft_printf(MPI_COMM_WORLD, "(PNFFT_PRE_CUB_PSI) "); break; default: if(window==0 || window==5) pfft_printf(MPI_COMM_WORLD, "(PNFFT_FG_PSI) "); else pfft_printf(MPI_COMM_WORLD, "(No interpolation enabled) "); } pfft_printf(MPI_COMM_WORLD, "(change with -pnfft_intpol *),\n"); if(interlacing) pfft_printf(MPI_COMM_WORLD, "* interlacing = enabled (disable with -pnfft_interlacing 0)"); else pfft_printf(MPI_COMM_WORLD, "* interlacing = disabled (enable with -pnfft_interlacing 1)"); pfft_printf(MPI_COMM_WORLD, "* on np[0] x np[1] x np[2] = %td x %td x %td processes (change with -pnfft_np * * *)\n", np[0], np[1], np[2]); pfft_printf(MPI_COMM_WORLD, "*******************************************************************************************************\n\n"); /* calculate parallel NFFT */ pnfft_perform_guru(N, n, local_M, m, x_max, window_flag| intpol_flag| interlacing_flag, np, MPI_COMM_WORLD); /* free mem and finalize */ pnfft_cleanup(); MPI_Finalize(); return 0; }