From b0ce573bf2e1957476c265424d4e0e146c6f9725 Mon Sep 17 00:00:00 2001 From: Claudio Gheller Date: Mon, 19 Dec 2022 16:05:51 +0100 Subject: [PATCH] Makefile and gitignore extended to inverse-imaging, inverse-imaging updated --- .gitignore | 1 + Makefile | 1 + inverse-imaging.c | 90 +++++++++++++++-------------------------------- 3 files changed, 30 insertions(+), 62 deletions(-) diff --git a/.gitignore b/.gitignore index 77346fd..2f2b2de 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ w-stackingCfftw w-stackingfftw w-stackingCfftw_serial w-stackingfftw_serial +inverse-imaging diff --git a/Makefile b/Makefile index 23d161d..0a8527d 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,7 @@ serial_cuda: mpi: $(COBJ) $(MPICC) $(OPTIMIZE) -o w-stackingCfftw $^ $(CFLAGS) $(LIBS) + $(MPICC) $(OPTIMIZE) -o inverse-imaging inverse-imaging.c w-stacking.c $(CFLAGS) $(LIBS) mpi_cuda: $(NVCC) $(NVFLAGS) -c w-stacking.cu phase_correction.cu $(NVLIB) diff --git a/inverse-imaging.c b/inverse-imaging.c index cc76519..2a10345 100644 --- a/inverse-imaging.c +++ b/inverse-imaging.c @@ -79,8 +79,8 @@ int main(int argc, char * argv[]) char timingfile[FILENAMELENGTH] = "timings.dat"; // Image related files - char imagepath[900] = "./" - imagename[FILENAMELENGTH] = "image_name.bin" + char imagepath[900] = "./"; + char imagename[FILENAMELENGTH] = "image_name.bin"; // Visibilities related variables double * uu; @@ -115,7 +115,7 @@ int main(int argc, char * argv[]) int yaxis; // Number of planes in the w direction - int num_w_planes = 8; + int num_w_planes = 1; // Size of the convoutional kernel support int w_support = 7; @@ -278,6 +278,8 @@ if(rank == 0){ visreal = (float*) calloc(Nvis,sizeof(float)); visimg = (float*) calloc(Nvis,sizeof(float)); + // reading baselines + if(rank == 0)printf("READING DATA\n"); // Read data strcpy(filename,datapath); @@ -316,13 +318,33 @@ if(rank == 0){ setup_time = ((double) (end - start)) / CLOCKS_PER_SEC; setup_time1 = (finish.tv_sec - begin.tv_sec); setup_time1 += (finish.tv_nsec - begin.tv_nsec) / 1000000000.0; + // baselines read + + // define image variable + double* image_real = (double*) calloc(xaxis*yaxis,sizeof(double)); + + // reading image + strcpy(filename,imagepath); + strcat(filename,imagename); + printf("Reading Image %s\n",filename); + + // all MPI tasks read together: parallel filesystem required + pFilereal = fopen (filename,"rb"); + long global_index = rank*(xaxis*yaxis)*sizeof(double); + fseek(pFilereal, global_index, SEEK_SET); + fwrite(image_real, xaxis*yaxis, sizeof(double), pFilereal); + fclose(pFilereal); + // image read + + if(rank == 0)printf("FFT TRANSFORMING (from Real to Complex Fourier space)\n"); + - if(rank == 0)printf("GRIDDING DATA\n"); + if(rank == 0)printf("DEGRIDDING DATA\n"); // Create histograms and linked lists - clock_gettime(CLOCK_MONOTONIC, &begin); - start = clock(); + clock_gettime(CLOCK_MONOTONIC, &begin); + start = clock(); // Initialize linked list struct sectorlist ** sectorhead; @@ -919,62 +941,6 @@ if(rank == 0){ fftw_free(fftwgrid); - // Phase correction - clock_gettime(CLOCK_MONOTONIC, &begin); - start = clock(); - if(rank == 0)printf("PHASE CORRECTION\n"); - double* image_real = (double*) calloc(xaxis*yaxis,sizeof(double)); - double* image_imag = (double*) calloc(xaxis*yaxis,sizeof(double)); - - phase_correction(gridss,image_real,image_imag,xaxis,yaxis,num_w_planes,grid_size_x,grid_size_y,resolution,wmin,wmax,num_threads); - - end = clock(); - clock_gettime(CLOCK_MONOTONIC, &finish); - phase_time = ((double) (end - start)) / CLOCKS_PER_SEC; - phase_time1 = (finish.tv_sec - begin.tv_sec); - phase_time1 += (finish.tv_nsec - begin.tv_nsec) / 1000000000.0; -#ifdef WRITE_IMAGE - - if(rank == 0) - { - pFilereal = fopen (fftfile2,"wb"); - pFileimg = fopen (fftfile3,"wb"); - fclose(pFilereal); - fclose(pFileimg); - } - #ifdef USE_MPI - MPI_Barrier(MPI_COMM_WORLD); - #endif - if(rank == 0)printf("WRITING IMAGE\n"); - for (int isector=0; isector