diff --git a/init.c b/init.c index afd3833fe64693d56bf44eddefb3d38987052b72..8cfad3ba587805e5f47491bb34c2ee0ecc359c36 100755 --- a/init.c +++ b/init.c @@ -48,9 +48,7 @@ void init(int index) metaData_calculation(); // Allocate Data Buffer - // CLAAAAAA assume here that data shape/size will never change across multiple data read - allocate_memory(); - //if (index == 0) allocate_memory(); + allocate_memory(index); // Reading Data readData(); @@ -354,7 +352,7 @@ void metaData_calculation() { } -void allocate_memory() { +void allocate_memory(int index) { // DAV: all these arrays can be allocatate statically for the sake of optimization. However be careful that if MPI is used @@ -371,18 +369,20 @@ void allocate_memory() { // Create sector grid - size_of_grid = 2*param.num_w_planes*xaxis*yaxis; + if (index == 0) + { + size_of_grid = 2*param.num_w_planes*xaxis*yaxis; - int size_of_grid_pointers = (3 + 2*(param.reduce_method != REDUCE_RING)) * size_of_grid; - grid_pointers = (double*)calloc( size_of_grid_pointers, sizeof(double)); + int size_of_grid_pointers = (3 + 2*(param.reduce_method != REDUCE_RING)) * size_of_grid; + grid_pointers = (double*)calloc( size_of_grid_pointers, sizeof(double)); - if ( param.reduce_method != REDUCE_RING ) + if ( param.reduce_method != REDUCE_RING ) { - gridss = grid_pointers; + gridss = grid_pointers; grid = gridss + size_of_grid; gridss_w = gridss + size_of_grid; } - else + else { gridss_w = grid_pointers; numa_allocate_shared_windows( &Me, size_of_grid*sizeof(double)*1.1, sizeof(double)*1.1 ); @@ -391,8 +391,9 @@ void allocate_memory() { } // CLAAAAA these two arrays are need ONLY for I/O purposes. Can be improved! - gridss_real = gridss_w + size_of_grid; - gridss_img = gridss_real + size_of_grid / 2; + gridss_real = gridss_w + size_of_grid; + gridss_img = gridss_real + size_of_grid / 2; + } } diff --git a/proto.h b/proto.h index 771f691090df1f5052ea026dc01de6405ea9255d..6824314d8ed1d78c2c6b7b1ac52fd1c83ff3258c 100755 --- a/proto.h +++ b/proto.h @@ -9,7 +9,7 @@ void read_parameter_file(char *); void fileName(char datapath[900], char file[30]); void readMetaData(char fileLocal[1000]); void metaData_calculation(); -void allocate_memory(); +void allocate_memory(int); void readData(); #ifdef __cplusplus