Commit c4a6b558 authored by Reinhard Prix's avatar Reinhard Prix
Browse files

ComputeFstat_Resamp: new API to export timing coefficients tauF1Buf, tauF1NoBuf

- use those in ComputeFstatBenchmark, improved output
- refs #1954
Original: e8d2349839272b652295e8cea3a8ecacc821b31f
parent 55e8fe4d
...@@ -136,9 +136,12 @@ XLALComputeFaFb_Resamp ( FstatWorkspace *ws, ...@@ -136,9 +136,12 @@ XLALComputeFaFb_Resamp ( FstatWorkspace *ws,
const COMPLEX8TimeSeries *TimeSeries_SRC_b const COMPLEX8TimeSeries *TimeSeries_SRC_b
); );
int XLALAppendResampInfo2File ( FILE *fp, const FstatInput *input );
static FstatWorkspace *XLALCreateFstatWorkspace ( UINT4 numSamplesSRC, UINT4 numSamplesFFT ); static FstatWorkspace *XLALCreateFstatWorkspace ( UINT4 numSamplesSRC, UINT4 numSamplesFFT );
// pseudo-internal: don't export API but allow using them from test/benchmark codes
int XLALAppendResampInfo2File ( FILE *fp, const FstatInput *input );
int XLALGetResampTimingInfo ( REAL8 *tauF1NoBuf, REAL8 *tauF1Buf, const FstatInput *input );
// ==================== function definitions ==================== // ==================== function definitions ====================
// ---------- exported API functions ---------- // ---------- exported API functions ----------
...@@ -218,6 +221,22 @@ XLALDestroyFstatWorkspace ( FstatWorkspace *ws ) ...@@ -218,6 +221,22 @@ XLALDestroyFstatWorkspace ( FstatWorkspace *ws )
} // XLALDestroyFstatWorkspace() } // XLALDestroyFstatWorkspace()
// return resampling timing coefficients 'tauF1' for buffered and unbuffered calls
int
XLALGetResampTimingInfo ( REAL8 *tauF1NoBuf, REAL8 *tauF1Buf, const FstatInput *input )
{
XLAL_CHECK ( input != NULL, XLAL_EINVAL );
XLAL_CHECK ( input->resamp != NULL, XLAL_EINVAL );
XLAL_CHECK ( input->resamp->ws != NULL, XLAL_EINVAL );
const ResampTimingInfo *ti = &(input->resamp->ws->timingInfo);
(*tauF1NoBuf) = ti->tauF1NoBuf;
(*tauF1Buf) = ti->tauF1Buf;
return XLAL_SUCCESS;
} // XLALGetResampTimingInfo()
/// debug/optimizer helper function: dump internal info from resampling code into a file /// debug/optimizer helper function: dump internal info from resampling code into a file
/// if called with input==NULL, output a header-comment-line /// if called with input==NULL, output a header-comment-line
int int
......
...@@ -52,6 +52,7 @@ typedef struct ...@@ -52,6 +52,7 @@ typedef struct
} UserInput_t; } UserInput_t;
int XLALAppendResampInfo2File ( FILE *fp, const FstatInput *input ); int XLALAppendResampInfo2File ( FILE *fp, const FstatInput *input );
int XLALGetResampTimingInfo ( REAL8 *tauF1NoBuf, REAL8 *tauF1Buf, const FstatInput *input );
// ---------- main ---------- // ---------- main ----------
int int
...@@ -198,6 +199,8 @@ main ( int argc, char *argv[] ) ...@@ -198,6 +199,8 @@ main ( int argc, char *argv[] )
FstatInputVector *inputs; FstatInputVector *inputs;
FstatQuantities whatToCompute = (FSTATQ_2F | FSTATQ_2F_PER_DET); FstatQuantities whatToCompute = (FSTATQ_2F | FSTATQ_2F_PER_DET);
FstatResults *results = NULL; FstatResults *results = NULL;
REAL8 tauF1NoBuf = 0;
REAL8 tauF1Buf = 0;
// ---------- main loop over repeated trials ---------- // ---------- main loop over repeated trials ----------
for ( INT4 i = 0; i < uvar->numTrials; i ++ ) for ( INT4 i = 0; i < uvar->numTrials; i ++ )
{ {
...@@ -231,41 +234,43 @@ main ( int argc, char *argv[] ) ...@@ -231,41 +234,43 @@ main ( int argc, char *argv[] )
} }
// ----- compute Fstatistics over segments // ----- compute Fstatistics over segments
REAL8 tauFSumUnbuffered = 0; REAL8 tauF1NoBuf_i = 0;
REAL8 tauFSumBuffered = 0; REAL8 tauF1Buf_i = 0;
for ( INT4 l = 0; l < uvar->numSegments; l ++ ) for ( INT4 l = 0; l < uvar->numSegments; l ++ )
{ {
REAL8 tic = XLALGetTimeOfDay();
XLAL_CHECK ( XLALComputeFstat ( &results, inputs->data[l], &Doppler, numFreqBins_i, whatToCompute ) == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK ( XLALComputeFstat ( &results, inputs->data[l], &Doppler, numFreqBins_i, whatToCompute ) == XLAL_SUCCESS, XLAL_EFUNC );
REAL8 toc = XLALGetTimeOfDay();
tauFSumUnbuffered += ( toc - tic );
// ----- output more details if requested [only from first segment] // ----- output timing details if requested
if ( (l == 0) && (fpInfo != NULL) ) { if ( (fpInfo != NULL) ) {
XLALAppendResampInfo2File ( fpInfo, inputs->data[0] ); XLALAppendResampInfo2File ( fpInfo, inputs->data[l] );
} }
REAL8 tauF1NoBuf_il, tauF1Buf_il;
if ( uvar->runBuffered ) XLAL_CHECK ( XLALGetResampTimingInfo ( &tauF1NoBuf_il, &tauF1Buf_il, inputs->data[l] ) == XLAL_SUCCESS, XLAL_EFUNC );
{ tauF1NoBuf_i += tauF1NoBuf_il;
tic = XLALGetTimeOfDay(); tauF1Buf_i += tauF1Buf_il;
XLAL_CHECK ( XLALComputeFstat ( &results, inputs->data[l], &Doppler, numFreqBins_i, whatToCompute ) == XLAL_SUCCESS, XLAL_EFUNC );
toc = XLALGetTimeOfDay();
tauFSumBuffered += ( toc - tic );
}
} // for l < numSegments } // for l < numSegments
REAL8 tauF1Unbuffered = tauFSumUnbuffered / ( uvar->numSegments * numFreqBins_i * numDetectors );
REAL8 tauF1Buffered = tauFSumBuffered / ( uvar->numSegments * numFreqBins_i * numDetectors ); tauF1NoBuf_i /= uvar->numSegments;
tauF1Buf_i /= uvar->numSegments;
REAL8 memMaxCompute = XLALGetPeakHeapUsageMB() - memBase; REAL8 memMaxCompute = XLALGetPeakHeapUsageMB() - memBase;
fprintf (stderr, "%-15s: tauF1Buffered = %.2g s, tauF1Unbuffered = %.2g s, memSFTs = %.1f MB, memMaxCompute = %.1f MB\n", tauF1Buf += tauF1Buf_i;
XLALGetFstatMethodName ( FstatMethod ), (tauF1Buffered > 0) ? tauF1Buffered : -1, tauF1Unbuffered, memSFTs, memMaxCompute ); tauF1NoBuf += tauF1NoBuf_i;
fprintf (stderr, "%-15s: tauF1Buf = %.2g s, tauF1NoBuf = %.2g s, memSFTs = %.1f MB, memMaxCompute = %.1f MB\n",
XLALGetFstatMethodName ( FstatMethod ), tauF1Buf_i, tauF1NoBuf_i, memSFTs, memMaxCompute );
XLALDestroyFstatInputVector ( inputs ); XLALDestroyFstatInputVector ( inputs );
XLALDestroyFstatWorkspace ( sharedWorkspace ); XLALDestroyFstatWorkspace ( sharedWorkspace );
optionalArgs.sharedWorkspace = NULL; optionalArgs.sharedWorkspace = NULL;
} // for i < numTrials } // for i < numTrials
tauF1Buf /= uvar->numTrials;
tauF1NoBuf /= uvar->numTrials;
fprintf (stderr, "\nAveraged timings: <tauF1Buf> = %.2g s, <tauF1NoBuf> = %.2g s\n", tauF1Buf, tauF1NoBuf );
// ----- free memory ---------- // ----- free memory ----------
if ( fpInfo != NULL ) { if ( fpInfo != NULL ) {
fclose ( fpInfo ); fclose ( fpInfo );
......
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