Commit 769f0f35 authored by Reinhard Prix's avatar Reinhard Prix
Browse files

ComputeFstat: improved control of header-printing for timing-output

- refs #4488
Original: 970032a6c4cddb6be72fb687114fd9b08efe8d3c
parent 8ef6ebe6
......@@ -697,7 +697,14 @@ int MAIN( int argc, char *argv[]) {
} /* end of logging */
tic_Start = GETTIME();
BOOLEAN printHeader = 0;
if ( uvar_outputTimingDetails != NULL ) {
FILE *tmp;
if ( (tmp = fopen ( uvar_outputTimingDetails, "r" )) == NULL ) {
printHeader = 1;
} else {
fclose (tmp );
}
XLAL_CHECK ( (usefulParams.timingDetailsFP = fopen ( uvar_outputTimingDetails, "wb" )) != NULL, XLAL_ESYS, "Failed to open '%s' for writing\n", uvar_outputTimingDetails );
} // if uvar_outputTimingDetails
......@@ -1529,7 +1536,7 @@ int MAIN( int argc, char *argv[]) {
return xlalErrno;
}
if ( usefulParams.timingDetailsFP != NULL ) {
XLAL_CHECK ( AppendFstatTimingInfo2File ( usefulParams.Fstat_in_vec->data[k], usefulParams.timingDetailsFP ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( AppendFstatTimingInfo2File ( usefulParams.Fstat_in_vec->data[k], usefulParams.timingDetailsFP, printHeader ) == XLAL_SUCCESS, XLAL_EFUNC );
}
/* if single-only flag is given, add +4 to F-statistic */
if ( uvar_SignalOnly ) {
......
......@@ -1020,18 +1020,18 @@ XLALGetFstatTiming ( const FstatInput* input, REAL8 *tauF1Buf, REAL8 *tauF1NoBuf
} // XLALGetFstatTiming()
int
AppendFstatTimingInfo2File ( const FstatInput* input, FILE *fp )
AppendFstatTimingInfo2File ( const FstatInput* input, FILE *fp, BOOLEAN printHeader )
{
XLAL_CHECK ( input != NULL, XLAL_EINVAL );
XLAL_CHECK ( fp != NULL, XLAL_EINVAL );
if ( input->method < FMETHOD_RESAMP_GENERIC )
{
XLAL_CHECK ( AppendFstatTimingInfo2File_Demod ( input->method_data, fp ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( AppendFstatTimingInfo2File_Demod ( input->method_data, fp, printHeader ) == XLAL_SUCCESS, XLAL_EFUNC );
}
else
{
XLAL_CHECK ( AppendFstatTimingInfo2File_Resamp ( input->method_data, fp ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( AppendFstatTimingInfo2File_Resamp ( input->method_data, fp, printHeader ) == XLAL_SUCCESS, XLAL_EFUNC );
}
return XLAL_SUCCESS;
......
......@@ -298,7 +298,7 @@ const MultiLIGOTimeGPSVector* XLALGetFstatInputTimestamps ( const FstatInput* in
const MultiNoiseWeights* XLALGetFstatInputNoiseWeights ( const FstatInput* input );
const MultiDetectorStateSeries* XLALGetFstatInputDetectorStates ( const FstatInput* input );
int XLALGetFstatTiming ( const FstatInput* input, REAL8 *tauF1Buf, REAL8 *tauF1NoBuf );
int AppendFstatTimingInfo2File ( const FstatInput* input, FILE *fp );
int AppendFstatTimingInfo2File ( const FstatInput* input, FILE *fp, BOOLEAN printHeader );
#ifdef SWIG // SWIG interface directives
SWIGLAL(INOUT_STRUCTS(FstatResults**, Fstats));
......
......@@ -391,20 +391,16 @@ XLALGetFstatTiming_Demod ( const void* method_data, REAL8 *tauF1Buf, REAL8 *tauF
// append detailed (method-specific) timing info to given file
int
AppendFstatTimingInfo2File_Demod ( const void* method_data, FILE *fp )
AppendFstatTimingInfo2File_Demod ( const void* method_data, FILE *fp, BOOLEAN printHeader )
{
XLAL_CHECK ( method_data != NULL, XLAL_EINVAL );
XLAL_CHECK ( fp != NULL, XLAL_EINVAL );
const DemodMethodData *demod = (const DemodMethodData *)method_data;
// print header on first call
static BOOLEAN print_header = 1;
if ( print_header ) {
if ( printHeader ) {
fprintf (fp, "%%%%%8s %4s %10s ", "Nfreq", "Ndet", "Nsft" );
fprintf (fp, "%10s %10s %10s %10s %10s\n",
"tauTotal", "tauBary", "tauF1NoBuf", "tauF1Buf", "tauF0Demod" );
print_header = 0;
}
const DemodTimingInfo *ti = &(demod->timingInfo);
......
......@@ -1022,16 +1022,14 @@ XLALGetFstatTiming_Resamp ( const void* method_data, REAL8 *tauF1Buf, REAL8 *tau
// append detailed (method-specific) timing info to given file
int
AppendFstatTimingInfo2File_Resamp ( const void* method_data, FILE *fp )
AppendFstatTimingInfo2File_Resamp ( const void* method_data, FILE *fp, BOOLEAN printHeader )
{
XLAL_CHECK ( method_data != NULL, XLAL_EINVAL );
XLAL_CHECK ( fp != NULL, XLAL_EINVAL );
const ResampMethodData *resamp = (const ResampMethodData *)method_data;
// print header on first call
static BOOLEAN print_header = 1;
if ( print_header ) {
// print header if requested
if ( printHeader ) {
fprintf (fp, "%%%% ----- Resampling F-stat timing: -----\n");
fprintf (fp, "%%%% Measured time (in seconds) per F-stat frequency bin per detector (excluding barycentering):\n");
fprintf (fp, "%%%% tau_RS = (TauTotal - TauBary) / NFbin\n");
......@@ -1044,7 +1042,6 @@ AppendFstatTimingInfo2File_Resamp ( const void* method_data, FILE *fp )
fprintf (fp, "%%%%%8s %8s %8s %6s %6s", "NFbin", "NsFFT0", "l2NsFFT", "Ndet", "R" );
fprintf (fp, " %10s %10s %10s %10s %10s %10s", "TauTotal", "tau_RS", "tau_Fbin", "tau_FFT", "tau_spin", "tau_bary" );
fprintf (fp, "\n");
print_header = 0;
}
const ResampTimingInfo *ti = &(resamp->timingInfo);
......
......@@ -63,8 +63,8 @@ typedef struct {
// ---------- Shared internal functions ---------- //
int XLALGetFstatTiming_Demod ( const void* method_data, REAL8 *tauF1Buf, REAL8 *tauF1NoBuf );
int XLALGetFstatTiming_Resamp ( const void* method_data, REAL8 *tauF1Buf, REAL8 *tauF1NoBuf );
int AppendFstatTimingInfo2File_Demod ( const void* method_data, FILE *fp );
int AppendFstatTimingInfo2File_Resamp ( const void *method_data, FILE *fp );
int AppendFstatTimingInfo2File_Demod ( const void* method_data, FILE *fp, BOOLEAN printHeader );
int AppendFstatTimingInfo2File_Resamp ( const void *method_data, FILE *fp, BOOLEAN printHeader );
static inline REAL4
XLALComputeFstatFromFaFb ( COMPLEX8 Fa, COMPLEX8 Fb, REAL4 A, REAL4 B, REAL4 C, REAL4 E, REAL4 Dinv )
......
......@@ -186,11 +186,17 @@ main ( int argc, char *argv[] )
optionalArgs.collectTiming = 1;
FILE *timingLogFILE = NULL;
BOOLEAN printHeader = 0;
if ( uvar->outputInfo != NULL )
{
FILE *tmp;
if ( (tmp = fopen ( uvar->outputInfo, "r" )) == NULL ) {
printHeader = 1;
} else {
fclose (tmp );
}
XLAL_CHECK ( (timingLogFILE = fopen (uvar->outputInfo, "ab")) != NULL, XLAL_ESYS, "Failed to open '%s' for appending\n", uvar->outputInfo );
}
FstatInputVector *inputs;
FstatQuantities whatToCompute = (FSTATQ_2F | FSTATQ_2F_PER_DET);
FstatResults *results = NULL;
......@@ -239,7 +245,7 @@ main ( int argc, char *argv[] )
tauF1Buf_i += Fstat_tauF1Buf;
// ----- output timing details to file if requested
if ( timingLogFILE != NULL ) {
XLAL_CHECK ( AppendFstatTimingInfo2File ( inputs->data[l], timingLogFILE ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( AppendFstatTimingInfo2File ( inputs->data[l], timingLogFILE, printHeader ) == XLAL_SUCCESS, XLAL_EFUNC );
}
} // for l < numSegments
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment