From 066b4e1712fe0657162b0100830c7ab49453fec7 Mon Sep 17 00:00:00 2001 From: nandhanas Date: Wed, 2 Mar 2022 19:37:00 +0100 Subject: [PATCH] Added additional parameters --- allvars.c | 7 +- allvars.h | 7 +- data/paramfile.txt | 15 +++- fourier_transform.c | 18 ++--- gridding.c | 8 +-- init.c | 166 ++++++++++++++++++++++++++++++++------------ main.c | 8 --- 7 files changed, 155 insertions(+), 74 deletions(-) diff --git a/allvars.c b/allvars.c index 54f6d6a..07b6f6f 100644 --- a/allvars.c +++ b/allvars.c @@ -4,21 +4,16 @@ struct io file; struct ip in; -struct op out; -struct op outparam = {"grid.txt", "coords.txt", "grid_real.bin", "grid_img.bin", "fft.txt", "fft_real.bin", "fft_img.bin", "run.log", ".txt", "timings.dat"}; +struct op out, outparam; struct meta metaData; struct time timing; struct parameter param; struct fileData data; -int w_support = 7; char filename[1000], buf[30], num_buf[30]; char datapath[900]; int xaxis, yaxis; -int grid_size_x = 2048; -int grid_size_y = 2048; -int num_w_planes = 8; int rank; int size; long nsectors; diff --git a/allvars.h b/allvars.h index a2a0faa..48f4e57 100644 --- a/allvars.h +++ b/allvars.h @@ -96,6 +96,10 @@ extern struct parameter int num_threads; int ndatasets; char datapath_multi[NFILES][900]; + int grid_size_x; + int grid_size_y; + int num_w_planes; + int w_support; } param; extern struct fileData @@ -117,9 +121,6 @@ extern struct sectorlist { extern char filename[1000], buf[30], num_buf[30]; extern char datapath[900]; extern int xaxis, yaxis; -extern int grid_size_x; -extern int grid_size_y; -extern int num_w_planes, w_support; extern int rank; extern int size; extern long nsectors; diff --git a/data/paramfile.txt b/data/paramfile.txt index 63d1574..508923a 100644 --- a/data/paramfile.txt +++ b/data/paramfile.txt @@ -3,6 +3,10 @@ Datapath1 /u/nsakthivel/LOFAR/data/newgauss2noconj_t201806301100_SB Datapath2 /u/nsakthivel/LOFAR/data/newgauss2noconj_t201806301100_SBL180.binMS/ Datapath3 /u/nsakthivel/LOFAR/data/newgauss2noconj_t201806301100_SBL180.binMS/ num_threads 2 +w_support 7 +grid_size_x 2048 +grid_size_y 2048 +num_w_planes 8 ufile ucoord.bin vfile vcoord.bin wfile wcoord.bin @@ -10,4 +14,13 @@ weightsfile weights.bin visrealfile visibilities_real.bin visimgfile visibilities_img.bin metafile meta.txt - +outfile grid.txt +outfile1 coords.txt +outfile2 grid_real.bin +outfile3 grid_img.bin +fftfile fft.txt +fftfile2 fft_real.bin +fftfile3 fft_img.bin +logfile run.log +extension .txt +timingfile timings.dat diff --git a/fourier_transform.c b/fourier_transform.c index 130cd9d..ba8c652 100644 --- a/fourier_transform.c +++ b/fourier_transform.c @@ -11,19 +11,19 @@ void fftw_data(){ start = clock(); fftw_plan plan; ptrdiff_t alloc_local, local_n0, local_0_start; - double norm = 1.0/(double)(grid_size_x*grid_size_y); + double norm = 1.0/(double)(param.grid_size_x*param.grid_size_y); // map the 1D array of complex visibilities to a 2D array required by FFTW (complex[*][2]) // x is the direction of contiguous data and maps to the second parameter // y is the parallelized direction and corresponds to the first parameter (--> n0) // and perform the FFT per w plane - alloc_local = fftw_mpi_local_size_2d(grid_size_y, grid_size_x, MPI_COMM_WORLD,&local_n0, &local_0_start); + alloc_local = fftw_mpi_local_size_2d(param.grid_size_y, param.grid_size_x, MPI_COMM_WORLD,&local_n0, &local_0_start); fftwgrid = fftw_alloc_complex(alloc_local); - plan = fftw_mpi_plan_dft_2d(grid_size_y, grid_size_x, fftwgrid, fftwgrid, MPI_COMM_WORLD, FFTW_BACKWARD, FFTW_ESTIMATE); + plan = fftw_mpi_plan_dft_2d(param.grid_size_y, param.grid_size_x, fftwgrid, fftwgrid, MPI_COMM_WORLD, FFTW_BACKWARD, FFTW_ESTIMATE); long fftwindex = 0; long fftwindex2D = 0; - for (int iw=0; iw 1) + if (param.num_w_planes > 1) { - for (int iw=0; iw 1) { @@ -176,14 +244,21 @@ void read_parameter_file(char *fname) /* Communicating the relevent parameters to the other process */ - MPI_Bcast(&in, sizeof(struct ip), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(¶m, sizeof(struct parameter), MPI_BYTE, 0, MPI_COMM_WORLD); + #ifdef USE_MPI + MPI_Bcast(&in, sizeof(struct ip), MPI_BYTE, 0, MPI_COMM_WORLD); + MPI_Bcast(&outparam, sizeof(struct op), MPI_BYTE, 0, MPI_COMM_WORLD); + MPI_Bcast(¶m, sizeof(struct parameter), MPI_BYTE, 0, MPI_COMM_WORLD); + #endif + } + + void fileName(char datapath[900], char file[30]) { strcpy(filename,datapath); strcat(filename,file); } + void readMetaData(char fileLocal[1000]) { if(rank == 0) @@ -212,8 +287,10 @@ void readMetaData(char fileLocal[1000]) { } /* Communicating the relevent parameters to the other process */ - - MPI_Bcast(&metaData, sizeof(struct meta), MPI_BYTE, 0, MPI_COMM_WORLD); + #ifdef USE_MPI + MPI_Bcast(&metaData, sizeof(struct meta), MPI_BYTE, 0, MPI_COMM_WORLD); + #endif + } void metaData_calculation() { @@ -361,10 +438,13 @@ void readData() { /* Communicating the relevent parameters to the other process */ - MPI_Bcast(data.uu, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.vv, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.ww, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.weights, metaData.Nweights * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.visreal, metaData.Nvis * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); - MPI_Bcast(data.visimg, metaData.Nvis * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); + #ifdef USE_MPI + MPI_Bcast(data.uu, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); + MPI_Bcast(data.vv, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); + MPI_Bcast(data.ww, metaData.Nmeasures * sizeof(double), MPI_BYTE, 0, MPI_COMM_WORLD); + MPI_Bcast(data.weights, metaData.Nweights * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); + MPI_Bcast(data.visreal, metaData.Nvis * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); + MPI_Bcast(data.visimg, metaData.Nvis * sizeof(float), MPI_BYTE, 0, MPI_COMM_WORLD); + #endif + } diff --git a/main.c b/main.c index 925444a..96c1831 100644 --- a/main.c +++ b/main.c @@ -7,14 +7,6 @@ int main(int argc, char * argv[]) { - char srank[4]; - double elapsed; - - // DAV: the corresponding KernelLen is calculated within the wstack function. It can be anyway hardcoded for optimization - dx = 1.0/(double)grid_size_x; - dw = 1.0/(double)num_w_planes; - w_supporth = (double)((w_support-1)/2)*dx; - if(argc > 1) { strcpy(in.paramfile,argv[1]); -- GitLab