Skip to content

Commit

Permalink
Timing of I/O is now additionally incremented in several places of th…
Browse files Browse the repository at this point in the history
…e code. The result is shown even when -prognosis is used.
  • Loading branch information
myurkin committed May 18, 2012
1 parent 75241f1 commit 11b7d21
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/CalculateE.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/GenerateB.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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_...')
Expand Down
2 changes: 2 additions & 0 deletions src/calculator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/crosssec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

//=====================================================================
Expand All @@ -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
Expand All @@ -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;
}

//=====================================================================
Expand All @@ -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;

Expand Down Expand Up @@ -498,6 +503,7 @@ void ReadScatGridParms(const char * restrict fname)
fprintf(logfile,"\n");
}
D("ReadScatGridParms finished");
Timing_FileIO+=GET_TIME()-tstart;
}

//=====================================================================*/
Expand Down
8 changes: 8 additions & 0 deletions src/make_particle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

//===========================================================
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

//===========================================================
Expand All @@ -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;

Expand Down Expand Up @@ -449,6 +454,7 @@ static void ReadDipFile(const char * restrict fname)
}
}
FCloseErr(dipfile,fname,ALL_POS);
Timing_FileIO+=GET_TIME()-tstart;
}

//==========================================================
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions src/timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 11b7d21

Please sign in to comment.