From a582159d41bea54b437a4ad5f354a8272ab67976 Mon Sep 17 00:00:00 2001
From: nandhanas <s.nandhana@gmail.com>
Date: Fri, 17 Feb 2023 02:32:36 +0100
Subject: [PATCH] Timing results for ring reduce

---
 Makefile  | 7 ++++---
 allvars.c | 2 ++
 allvars.h | 4 +++-
 reduce.c  | 4 ++--
 result.c  | 2 ++
 5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index ce9be41..fe95390 100644
--- a/Makefile
+++ b/Makefile
@@ -32,16 +32,17 @@ endif
 # perform one-side communication (suggested) instead of reduce (only if MPI is active)
 OPT += -DONE_SIDE
 # write the full 3D cube of gridded visibilities and its FFT transform
-OPT += -DWRITE_DATA
+#OPT += -DWRITE_DATA
 # write the final image
-OPT += -DWRITE_IMAGE
+#OPT += -DWRITE_IMAGE
 # perform w-stacking phase correction
 OPT += -DPHASE_ON
 # perform ring reduce
 OPT += -DRING
 #perform binomial reduce
 #OPT += -DBINOMIAL
-
+#perform debuging
+#OPT += -DDEBUG
 
 
 DEPS = w-stacking.h main.c w-stacking.cu phase_correction.cu allvars.h init.c gridding.c fourier_transform.c result.c reduce.c numa.h
diff --git a/allvars.c b/allvars.c
index f74e55f..2307e38 100644
--- a/allvars.c
+++ b/allvars.c
@@ -47,3 +47,5 @@ int    **cwins = NULL;
 int max_level = 0;
 double *end_4, *end_reduce;
 int dsize_4, iter=0;  
+struct timing_r timing;
+struct timingmpi_r timingmpi;
diff --git a/allvars.h b/allvars.h
index e8fef26..5988789 100644
--- a/allvars.h
+++ b/allvars.h
@@ -271,4 +271,6 @@ extern double **swins;
 extern int    **cwins;
 extern int max_level;
 extern double *end_4, *end_reduce;
-extern int dsize_4, iter; 
+extern int dsize_4, iter;
+extern struct timing_r { double rtime, ttotal, treduce, tspin, tspin_in, tmovmemory, tsum;} timing ;
+extern struct timingmpi_r{ double tmpi, tmpi_reduce, tmpi_reduce_wait, tmpi_setup;} timingmpi ; 
diff --git a/reduce.c b/reduce.c
index 7c866ab..a773557 100644
--- a/reduce.c
+++ b/reduce.c
@@ -16,8 +16,8 @@ double check_host_value ;
 double check_global_value ;
 #endif
 
-struct { double rtime, ttotal, treduce, tspin, tspin_in, tmovmemory, tsum;} timing = {0};
-struct { double tmpi, tmpi_reduce, tmpi_reduce_wait, tmpi_setup;} timingmpi = {0};
+//struct { double rtime, ttotal, treduce, tspin, tspin_in, tmovmemory, tsum;} timing = {0};
+//struct { double tmpi, tmpi_reduce, tmpi_reduce_wait, tmpi_setup;} timingmpi = {0};
 
 
 int_t summations = 0;
diff --git a/result.c b/result.c
index 34fca09..d982dfb 100644
--- a/result.c
+++ b/result.c
@@ -16,6 +16,8 @@ void write_result()
      #if defined(ONE_SIDE)
       //printf("%14s time : %f sec\n", "Reduce sh", wt_timing.reduce_sh);
       printf("%14s time : %f sec\n", "Reduce ring", wt_timing.reduce_ring);
+      printf("%14s time : %f sec\n", "Shared mem reduce ring", timing.treduce);
+      printf("%14s time : %f sec\n", "Shmem reduce multi host", timing.treduce+timingmpi.tmpi_reduce);
       //printf("%14s time : %f sec\n", "Mmove", wt_timing.mmove);
       //printf("%14s time : %f sec\n", "ReduceMPI", wt_timing.reduce_mpi);
      #endif
-- 
GitLab