27 #include <lal/LogPrintf.h>
28 #include <lal/UserInputParse.h>
114 static inline double cpu_time(
void );
142 const WeaveStatisticsParams *statistics_params
147 WeaveSearchTiming *tim =
XLALCalloc( 1,
sizeof( *tim ) );
151 tim->detailed_timing = detailed_timing;
152 tim->statistics_params = statistics_params;
164 WeaveSearchTiming *tim
176 WeaveSearchTiming *tim
191 tim->wall_total = wall_now;
192 tim->cpu_total = cpu_now;
194 tim->section_cpu_times[
i] = 0;
197 tim->statistic_cpu_times[
i] = 0;
203 tim->curr_section_cpu_time = cpu_now;
213 WeaveSearchTiming *tim,
214 double *wall_elapsed,
232 *wall_elapsed = wall_now - tim->wall_total;
233 *cpu_elapsed = cpu_now - tim->cpu_total;
243 WeaveSearchTiming *tim,
262 tim->section_cpu_times[tim->curr_section] += cpu_now - tim->curr_section_cpu_time;
265 tim->wall_total = wall_now - tim->wall_total;
266 tim->cpu_total = cpu_now - tim->cpu_total;
276 *wall_total = tim->wall_total;
277 *cpu_total = tim->cpu_total;
287 WeaveSearchTiming *tim,
304 tim->section_cpu_times[prev_section] += cpu_now - tim->curr_section_cpu_time;
308 tim->curr_section = next_section;
312 tim->curr_section_cpu_time = cpu_now;
323 WeaveSearchTiming *tim,
339 if ( prev_statistic & tim->statistics_params->all_statistics_to_compute ) {
341 tim->statistic_cpu_times[
XLAL_BIT2IDX( tim->curr_statistic )] += cpu_now - tim->curr_statistic_cpu_time;
345 tim->curr_statistic = next_statistic;
348 if ( next_statistic & tim->statistics_params->all_statistics_to_compute ) {
349 tim->statistic_section[
XLAL_BIT2IDX( next_statistic )] = tim->curr_section;
350 tim->curr_statistic_cpu_time = cpu_now;
362 const WeaveSearchTiming *tim,
363 const WeaveCacheQueries *queries
377 if ( !tim->detailed_timing ) {
382 UINT8 coh_nres = 0, coh_ntmpl = 0, semi_ntmpl = 0;
397 const double section_cpu_time = tim->section_cpu_times[
i];
411 BOOLEAN statistics_computed = 0;
412 double section_cpu_time_remain = section_cpu_time;
414 const double statistic_cpu_time = tim->statistic_cpu_times[
j];
415 if ( tim->statistic_section[
j] ==
i && statistic_cpu_time > 0 ) {
416 statistics_computed = 1;
419 UINT8 statistic_denom = 1;
421 const size_t statistic_name_len = strlen( statistic_name );
422 if ( statistic_name_len > 4 && strcmp( statistic_name + statistic_name_len - 4,
"_det" ) == 0 ) {
425 statistic_denom = tim->statistics_params->detectors->length;
433 snprintf( keyword,
sizeof( keyword ),
"cpu %s %s",
cpu_sections[
i].
name, statistic_name );
434 snprintf(
comment,
sizeof(
comment ),
"%s CPU time", statistic_name );
439 if ( section_denom > 0 ) {
443 snprintf( keyword,
sizeof( keyword ),
"tau %s %s_%s",
cpu_sections[
i].
name, statistic_name, section_denom_name );
444 snprintf(
comment,
sizeof(
comment ),
"%s timing constant", statistic_name );
449 section_cpu_time_remain -= statistic_cpu_time;
454 if ( statistics_computed ) {
463 }
else if ( section_denom > 0 ) {
468 snprintf( keyword,
sizeof( keyword ),
"tau %s_%s",
cpu_sections[
i].
name, section_denom_name );
int XLALWeaveCacheQueriesGetCounts(const WeaveCacheQueries *queries, UINT8 *coh_nres, UINT8 *coh_ntmpl, UINT8 *semi_ntmpl)
Get number of computed coherent results, and number of coherent and semicoherent templates.
int XLALFITSHeaderWriteREAL8(FITSFile UNUSED *file, const CHAR UNUSED *key, const REAL8 UNUSED value, const CHAR UNUSED *comment)
int XLALWeaveSearchTimingStatistic(WeaveSearchTiming *tim, const WeaveStatisticType prev_statistic, const WeaveStatisticType next_statistic)
Change the search statistic currently being timed.
int XLALWeaveSearchTimingElapsed(WeaveSearchTiming *tim, double *wall_elapsed, double *cpu_elapsed)
Return elapsed wall and CPU times since start of search timing.
int XLALWeaveSearchTimingWriteInfo(FITSFile *file, const WeaveSearchTiming *tim, const WeaveCacheQueries *queries)
Write information from search timing to a FITS file.
int XLALWeaveSearchTimingStop(WeaveSearchTiming *tim, double *wall_total, double *cpu_total)
Stop timing of search.
int XLALWeaveSearchTimingSection(WeaveSearchTiming *tim, const WeaveSearchTimingSection prev_section, const WeaveSearchTimingSection next_section)
Change the search section currently being timed.
const struct @1 cpu_sections[WEAVE_SEARCH_TIMING_MAX]
Parameters of search timing sections.
const char * denom_names[WEAVE_SEARCH_DENOM_MAX]
Names of denominator to use for timing constants.
void XLALWeaveSearchTimingDestroy(WeaveSearchTiming *tim)
Destroy a search timing structure.
static double cpu_time(void)
Return CPU time in seconds.
static double wall_time(void)
Return wall time in seconds.
int XLALWeaveSearchTimingStart(WeaveSearchTiming *tim)
Start timing of search.
WeaveSearchTimingDenominator
Denominator to use for timing constants.
@ WEAVE_SEARCH_DENOM_NONE
@ WEAVE_SEARCH_DENOM_PSTOP
Per semicoherent templates, per number of toplists.
@ WEAVE_SEARCH_DENOM_PSSM1
Per number of semicoherent templates, per number of segments (minus 1)
@ WEAVE_SEARCH_DENOM_PCOH
Per number of computed coherent results.
@ WEAVE_SEARCH_DENOM_PSEMI
Per number of semicoherent templates.
@ WEAVE_SEARCH_DENOM_PSSEG
Per number of semicoherent templates, per number of segments.
WeaveSearchTiming * XLALWeaveSearchTimingCreate(const BOOLEAN detailed_timing, const WeaveStatisticsParams *statistics_params)
Create a search timing structure.
const WeaveSearchTimingDenominator denom
Module which collects search timings and builds a timing model.
@ WEAVE_SEARCH_TIMING_COH
Computation of coherent results section.
@ WEAVE_SEARCH_TIMING_MAX
@ WEAVE_SEARCH_TIMING_OUTPUT
Result output section.
@ WEAVE_SEARCH_TIMING_SEMISEG
Computation of per-segment semicoherent results section.
@ WEAVE_SEARCH_TIMING_ITER
Parameter space iteration section.
@ WEAVE_SEARCH_TIMING_QUERY
Cache queries section.
@ WEAVE_SEARCH_TIMING_CKPT
Checkpointing section.
@ WEAVE_SEARCH_TIMING_OTHER
Unaccounted section.
@ WEAVE_SEARCH_TIMING_CMPL
Completion-loop section.
@ WEAVE_SEARCH_TIMING_SEMI
Computation of semicoherent results section.
enum tagWeaveSearchTimingSection WeaveSearchTimingSection
enum tagWeaveStatisticType WeaveStatisticType
@ WEAVE_STATISTIC_MAX
Marker +1 of maximal combined valid statistics value.
#define WEAVE_STATISTIC_NAME(ws)
Names of all possible statistics.
struct tagFITSFile FITSFile
Representation of a FITS file.
void * XLALCalloc(size_t m, size_t n)
REAL8 XLALGetCPUTime(void)
REAL8 XLALGetTimeOfDay(void)
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_NULL(assertion,...)
Container for timings and other information for a timing model.
double cpu_total
Total CPU time.
double statistic_cpu_times[XLAL_BIT2IDX(WEAVE_STATISTIC_MAX)]
CPU time taken by various coherent/semicoherent statistics.
double curr_section_cpu_time
CPU time for current section being timed.
WeaveStatisticType curr_statistic
Current statistic being timed.
WeaveSearchTimingSection statistic_section[XLAL_BIT2IDX(WEAVE_STATISTIC_MAX)]
Section in which each statistic is timed.
const WeaveStatisticsParams * statistics_params
Struct holding all parameters for which statistics to output and compute, when, and how.
size_t ntoplists
Number of output results toplists.
double section_cpu_times[WEAVE_SEARCH_TIMING_MAX]
CPU time taken by various sections.
double wall_total
Total wall time.
double curr_statistic_cpu_time
CPU time for current statistic being timed.
WeaveSearchTimingSection curr_section
Current section being timed.
BOOLEAN detailed_timing
Whether to record detailed timing information.