From 11b7d2165f8a9e2fa2d0b6f85f9fdd5194973be5 Mon Sep 17 00:00:00 2001 From: yurkin Date: Fri, 18 May 2012 10:35:32 +0000 Subject: [PATCH] Timing of I/O is now additionally incremented in several places of the code. The result is shown even when -prognosis is used. --- src/CalculateE.c | 2 ++ src/GenerateB.c | 2 ++ src/calculator.c | 2 ++ src/crosssec.c | 6 ++++++ src/make_particle.c | 8 ++++++++ src/timing.c | 8 ++++---- 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/CalculateE.c b/src/CalculateE.c index 4fecb61d..a2001c5a 100644 --- a/src/CalculateE.c +++ b/src/CalculateE.c @@ -607,6 +607,7 @@ static void CalcIntegralScatQuantities(const enum incpol which) * the same quantities calculated by different means). */ if (IFROOT) { + TIME_TYPE tstart_io=GET_TIME(); Cnorm = EIGHT_PI; Qnorm = EIGHT_PI*inv_G; PrintBoth(CCfile,"\nMatrix\n" @@ -633,6 +634,7 @@ static void CalcIntegralScatQuantities(const enum incpol which) Frp[3*j],Frp[3*j+1],Frp[3*j+2]); FCloseErr(VisFrp,fname_frp,ONE_POS); } + Timing_FileIO += GET_TIME() - tstart_io; } Free_general(Fsca); Free_general(Finc); diff --git a/src/GenerateB.c b/src/GenerateB.c index 37cd0785..7585d5e3 100644 --- a/src/GenerateB.c +++ b/src/GenerateB.c @@ -295,6 +295,7 @@ void GenerateB (const enum incpol which, // x - or y polarized incident light "polarization need to be calculated"); fname=beam_fnameX; } + TIME_TYPE tstart=GET_TIME(); FILE *file=FOpenErr(fname,"r",ALL_POS); // the same format as used for saving the beam by StoreFields(...) in make_particle.c const char beam_format[]="%*f %*f %*f %*f %lf %lf %lf %lf %lf %lf"; @@ -323,6 +324,7 @@ void GenerateB (const enum incpol which, // x - or y polarized incident light if(i==local_nvoid_d1 && i!=nvoid_Ndip) break; } } + Timing_FileIO+=GET_TIME()-tstart; } /* TO ADD NEW BEAM * add an option here (in the end of 'else if' sequence). Identifier ('B_...') diff --git a/src/calculator.c b/src/calculator.c index 7d38d432..6f2e3d23 100644 --- a/src/calculator.c +++ b/src/calculator.c @@ -280,6 +280,7 @@ static void ReadTables(void) { int i, j, ymax, Rm2, Rm2x; + TIME_TYPE tstart=GET_TIME(); tab1=ReadTableFile(TAB_FNAME(1),1); tab2=ReadTableFile(TAB_FNAME(2),6); tab3=ReadTableFile(TAB_FNAME(3),3); @@ -290,6 +291,7 @@ static void ReadTables(void) tab8=ReadTableFile(TAB_FNAME(8),6); tab9=ReadTableFile(TAB_FNAME(9),1); tab10=ReadTableFile(TAB_FNAME(10),6); + Timing_FileIO += GET_TIME() - tstart; if (!prognosis) { // allocate memory for tab_index diff --git a/src/crosssec.c b/src/crosssec.c index 0a66dccf..c7a89425 100644 --- a/src/crosssec.c +++ b/src/crosssec.c @@ -366,6 +366,7 @@ void ReadAvgParms(const char * restrict fname) FILE * restrict input; char buf[BUF_LINE],temp[BUF_LINE]; + TIME_TYPE tstart=GET_TIME(); // open file input=FOpenErr(fname,"r",ALL_POS); //scan file @@ -388,6 +389,7 @@ void ReadAvgParms(const char * restrict fname) alpha_int.min,alpha_int.max,alpha_int.N,beta_int.min,beta_int.max,beta_int.N,gamma_int.min, gamma_int.max,gamma_int.N); D("ReadAvgParms finished"); + Timing_FileIO+=GET_TIME()-tstart; } //===================================================================== @@ -400,6 +402,7 @@ void ReadAlldirParms(const char * restrict fname) FILE * restrict input; char buf[BUF_LINE],temp[BUF_LINE]; + TIME_TYPE tstart=GET_TIME(); // open file input=FOpenErr(fname,"r",ALL_POS); //scan file @@ -418,6 +421,7 @@ void ReadAlldirParms(const char * restrict fname) "see files 'log_int_***' for details\n\n", theta_int.min,theta_int.max,theta_int.N,phi_int.min,phi_int.max,phi_int.N); D("ReadAlldirParms finished"); + Timing_FileIO+=GET_TIME()-tstart; } //===================================================================== @@ -430,6 +434,7 @@ void ReadScatGridParms(const char * restrict fname) enum angleset theta_type,phi_type; size_t i; + TIME_TYPE tstart=GET_TIME(); // redundant initialization to remove warnings theta_type=phi_type=AS_RANGE; @@ -498,6 +503,7 @@ void ReadScatGridParms(const char * restrict fname) fprintf(logfile,"\n"); } D("ReadScatGridParms finished"); + Timing_FileIO+=GET_TIME()-tstart; } //=====================================================================*/ diff --git a/src/make_particle.c b/src/make_particle.c index 2a88932b..92809321 100644 --- a/src/make_particle.c +++ b/src/make_particle.c @@ -155,6 +155,7 @@ static void SaveGeometry(void) * Each part is done in corresponding if-else-if sequence */ + TIME_TYPE tstart=GET_TIME(); // create save_geom_fname if not specified, by adding extension to the shapename if (save_geom_fname[0]==0) { const char *ext; @@ -221,6 +222,7 @@ static void SaveGeometry(void) if (IFROOT) CatNFiles(directory,F_GEOM_TMP,save_geom_fname); #endif if (IFROOT) printf("Geometry saved to file\n"); + Timing_FileIO+=GET_TIME()-tstart; } //=========================================================== @@ -243,6 +245,7 @@ static void InitDipFile(const char * restrict fname,int *bX,int *bY,int *bZ,int char linebuf[BUF_LINE]; const char *rf_text; + TIME_TYPE tstart=GET_TIME(); dipfile=FOpenErr(fname,"r",ALL_POS); // detect file format @@ -403,6 +406,7 @@ static void InitDipFile(const char * restrict fname,int *bX,int *bY,int *bZ,int */ fseek(dipfile,0,SEEK_SET); SkipNLines(dipfile,skiplines); + Timing_FileIO+=GET_TIME()-tstart; } //=========================================================== @@ -417,6 +421,7 @@ static void ReadDipFile(const char * restrict fname) size_t boxX_l; char linebuf[BUF_LINE]; + TIME_TYPE tstart=GET_TIME(); // to remove possible overflows boxX_l=(size_t)boxX; @@ -449,6 +454,7 @@ static void ReadDipFile(const char * restrict fname) } } FCloseErr(dipfile,fname,ALL_POS); + Timing_FileIO+=GET_TIME()-tstart; } //========================================================== @@ -527,6 +533,7 @@ static void InitContour(const char *fname,double *ratio,double *shSize) D("InitContour has started"); // Read contour from file + TIME_TYPE tstart=GET_TIME(); file=FOpenErr(fname,"r",ALL_POS); line=SkipComments(file); size=CHUNK_SIZE; @@ -565,6 +572,7 @@ static void InitContour(const char *fname,double *ratio,double *shSize) } } FCloseErr(file,fname,ALL_POS); + Timing_FileIO+=GET_TIME()-tstart; // Check number of points read if (nr<3) LogError(ONE_POS,"Contour from file %s contains less than three points",fname); diff --git a/src/timing.c b/src/timing.c index d916d2e8..d5c020e1 100644 --- a/src/timing.c +++ b/src/timing.c @@ -216,11 +216,11 @@ void FinalStatistics(void) fprintf(logfile, " communication: "FFORMT"\n",TO_SEC(Timing_ScatQuanComm)); #endif - fprintf (logfile, - " File I/O: "FFORMT"\n" - "Integration: "FFORMT"\n", - TO_SEC(Timing_FileIO),TO_SEC(Timing_Integration)); } + fprintf (logfile, + "File I/O: "FFORMT"\n",TO_SEC(Timing_FileIO)); + if (!prognosis) fprintf (logfile, + "Integration: "FFORMT"\n",TO_SEC(Timing_Integration)); // close logfile FCloseErr(logfile,F_LOG,ONE_POS); }