Commit 677aac52 authored by Nandhana Sakhtivel's avatar Nandhana Sakhtivel
Browse files

read metadata file

parent f368adcb
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -11,5 +11,14 @@ struct time timing;

char filename[1000];
int num_threads;
char datapath_multi[NFILES][900];
char datapath_multi[NFILES][900], datapath[900];
int xaxis, yaxis;
int ndatasets;
int grid_size_x = 2048;
int grid_size_y = 2048;
int num_w_planes = 8;
int rank;
int size;
clock_t start, end, start0, startk, endk;
struct timespec begin, finish, begin0, begink, finishk;
long nsectors;
+36 −1
Original line number Diff line number Diff line
/* file to store global variables*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef USE_MPI
#include <mpi.h>
#ifdef USE_FFTW
#include <fftw3-mpi.h>
#endif
#endif
#ifdef ACCOMP
#include "w-stacking_omp.h"
#else
#include "w-stacking.h"
#endif
#ifdef NVIDIA
#include <cuda_runtime.h>
#endif
#define PI 3.14159265359
#define NUM_OF_SECTORS -1
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define NOVERBOSE
#define NFILES 100
#include <omp.h>
#include <math.h>
#include <time.h>
#include <unistd.h>

extern struct io
{
@@ -68,5 +93,15 @@ extern struct time

extern char filename[1000];
extern int num_threads;
extern char datapath_multi[NFILES][900];
extern char datapath_multi[NFILES][900],datapath[900];
extern int xaxis, yaxis;
extern int ndatasets;
extern int grid_size_x;
extern int grid_size_y;
extern int num_w_planes;
extern int rank;
extern int size;
extern long nsectors;

extern clock_t start, end, start0, startk, endk;
extern struct timespec begin, finish, begin0, begink, finishk;
+62 −1
Original line number Diff line number Diff line
@@ -4,9 +4,70 @@
#include "allvars.h"
#include "proto.h"

void init()
void init(int argc, char * argv[])
{
   // MESH SIZE
   int local_grid_size_x;// = 8;
   int local_grid_size_y;// = 8;
   
   read_parameter_file(in.paramfile);
   
   if ( num_threads == 0 )
   {
    fprintf(stderr, "Usage: %s number_of_OMP_Threads \n", num_threads);
    exit(1);
   }
   clock_gettime(CLOCK_MONOTONIC, &begin0);
   start0 = clock();
   // Intialize MPI environment
   #ifdef USE_MPI
	MPI_Init(&argc,&argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &size);
	if(rank == 0)printf("Running with %d MPI tasks\n",size);
  	#ifdef USE_FFTW
		fftw_mpi_init();
  	#endif
   #else
	rank = 0;
	size = 1;
   #endif

   if(rank == 0)printf("Running with %d threads\n",num_threads);

   #ifdef ACCOMP
	if(rank == 0){
  		if (0 == omp_get_num_devices()) {
      			printf("No accelerator found ... exit\n");
      			exit(255);
   		}
   		printf("Number of available GPUs %d\n", omp_get_num_devices());
  		#ifdef NVIDIA
      			prtAccelInfo();
   		#endif
 	}
   #endif

   // set the local size of the image
   local_grid_size_x = grid_size_x;
   nsectors = NUM_OF_SECTORS;
   if (nsectors < 0) nsectors = size;
   local_grid_size_y = grid_size_y/nsectors;
   //nsectors = size;

   // LOCAL grid size
   xaxis = local_grid_size_x;
   yaxis = local_grid_size_y;

   clock_gettime(CLOCK_MONOTONIC, &begin);
   start = clock();

   // INPUT FILES (only the first ndatasets entries are used)
   strcpy(datapath,datapath_multi[0]);
                   
   // Read metadata
   fileName(datapath, in.metafile);
   readMetaData(filename);
}


+30 −68
Original line number Diff line number Diff line
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef USE_MPI
#include <mpi.h>
#ifdef USE_FFTW
#include <fftw3-mpi.h>
#endif
#endif
#include <omp.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include "allvars.h"
#include "proto.h"
#ifdef ACCOMP
#include "w-stacking_omp.h"
#else
#include "w-stacking.h"
#endif
#define PI 3.14159265359
#define NUM_OF_SECTORS -1
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define NOVERBOSE


// Linked List set-up
struct sectorlist {
@@ -41,10 +20,6 @@ void Push(struct sectorlist** headRef, long data) {
// Main Code
int main(int argc, char * argv[])
{
	int rank;
	int size;

	char datapath[900];

	char srank[4];

@@ -57,31 +32,23 @@ int main(int argc, char * argv[])
	double resolution;

  // MESH SIZE
	int grid_size_x = 2048;
	int grid_size_y = 2048;
	int local_grid_size_x;// = 8;
	int local_grid_size_y;// = 8;
	int xaxis;
	int yaxis;
	int num_w_planes = 8;
//	int local_grid_size_x;// = 8;
//	int local_grid_size_y;// = 8;
//	int xaxis;
//	int yaxis;

	// DAV: the corresponding KernelLen is calculated within the wstack function. It can be anyway hardcoded for optimization
	int w_support = 7;
	int num_threads;// = 4;
	double dx = 1.0/(double)grid_size_x;
	double dw = 1.0/(double)num_w_planes;
	double w_supporth = (double)((w_support-1)/2)*dx;

	clock_t start, end, start0, startk, endk;
	struct timespec begin, finish, begin0, begink, finishk;
	double elapsed;
	long nsectors;
//	long nsectors;
  
        if(argc > 1)
        {
          strcpy(in.paramfile,argv[1]);
     printf("parameter file = %s\n", in.paramfile);
     init();
        }
        else
        {
@@ -89,18 +56,8 @@ int main(int argc, char * argv[])
          exit(1);
        }
 
  
  if ( num_threads == 0 )
  {
    fprintf(stderr, "Wrong parameter: %s\n\n", argv[1]);
    fprintf(stderr, "Usage: %s number_of_OMP_Threads \n", argv[0]);
    exit(1);
  }

	clock_gettime(CLOCK_MONOTONIC, &begin0);
	start0 = clock();

	// Intialize MPI environment
        init(argc, argv); 
  /*       
        #ifdef USE_MPI
	MPI_Init(&argc,&argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -109,7 +66,6 @@ int main(int argc, char * argv[])
  #ifdef USE_FFTW
	fftw_mpi_init();
  #endif
  MPI_Barrier(MPI_COMM_WORLD);
#else
	rank = 0;
	size = 1;
@@ -130,6 +86,11 @@ if(rank == 0){
 }
#endif






	// set the local size of the image
	local_grid_size_x = grid_size_x;
	nsectors = NUM_OF_SECTORS;
@@ -146,10 +107,11 @@ if(rank == 0){

	// INPUT FILES (only the first ndatasets entries are used)
    	strcpy(datapath,datapath_multi[0]);
	
        // Read metadata
        fileName(datapath, in.metafile);
        readMetaData(filename);

*/
	// WATCH THIS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	int nsub = 1000;
	//int nsub = 10;
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@

/* init.c */

void init();
void init(int argc, char * argv[]);
void read_parameter_file(char *);
void fileName(char datapath[900], char file[30]);
void readMetaData(char fileLocal[1000]);