From d6ee500355b870e83d5cdbc431629999ec97794e Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Tue, 3 Nov 2009 13:57:36 -0500 Subject: [PATCH] Call the stats and graph functions from sync_chain Versus the former daisy chain method, this avoids having the analysis stats and graph functions called twice when there are many matching modules (via matching_distributor). Signed-off-by: Benjamin Poirier --- lttv/lttv/sync/event_analysis_chull.c | 2 +- lttv/lttv/sync/event_matching_broadcast.c | 9 +- lttv/lttv/sync/event_matching_tcp.c | 43 +-------- .../sync/event_processing_lttng_standard.c | 62 ++---------- lttv/lttv/sync/sync_chain_lttv.c | 96 +++++++++++++++---- lttv/modules/text/sync_chain_batch.c | 76 +++++++++++---- 6 files changed, 149 insertions(+), 139 deletions(-) diff --git a/lttv/lttv/sync/event_analysis_chull.c b/lttv/lttv/sync/event_analysis_chull.c index 0bea74a8..41fdbca4 100644 --- a/lttv/lttv/sync/event_analysis_chull.c +++ b/lttv/lttv/sync/event_analysis_chull.c @@ -510,7 +510,7 @@ static GArray* finalizeAnalysisCHull(SyncState* const syncState) analysisData= (AnalysisDataCHull*) syncState->analysisData; - if (syncState->graphs) + if (syncState->graphs && analysisData->graphsData->hullPoints != NULL) { writeGraphFiles(syncState); closeGraphFiles(syncState); diff --git a/lttv/lttv/sync/event_matching_broadcast.c b/lttv/lttv/sync/event_matching_broadcast.c index 32112014..297de2cd 100644 --- a/lttv/lttv/sync/event_matching_broadcast.c +++ b/lttv/lttv/sync/event_matching_broadcast.c @@ -286,8 +286,8 @@ static GArray* finalizeMatchingBroadcast(SyncState* const syncState) /* - * Print statistics related to matching and downstream modules. Must be - * called after finalizeMatching. + * Print statistics related to matching. Must be called after + * finalizeMatching. * * Args: * syncState container for synchronization data. @@ -318,9 +318,4 @@ static void printMatchingStatsBroadcast(SyncState* const syncState) matchingData->stats->totComplete * syncState->traceNb) / matchingData->stats->totIncomplete); } - - if (syncState->analysisModule->printAnalysisStats != NULL) - { - syncState->analysisModule->printAnalysisStats(syncState); - } } diff --git a/lttv/lttv/sync/event_matching_tcp.c b/lttv/lttv/sync/event_matching_tcp.c index a8fdf5f0..0202380c 100644 --- a/lttv/lttv/sync/event_matching_tcp.c +++ b/lttv/lttv/sync/event_matching_tcp.c @@ -45,8 +45,6 @@ static GArray* finalizeMatchingTCP(SyncState* const syncState); static void printMatchingStatsTCP(SyncState* const syncState); static void writeMatchingGraphsPlotsTCP(FILE* stream, SyncState* const syncState, const unsigned int i, const unsigned int j); -static void writeMatchingGraphsOptionsTCP(FILE* stream, SyncState* const - syncState, const unsigned int i, const unsigned int j); // Functions specific to this module static void registerMatchingTCP() __attribute__((constructor (101))); @@ -77,7 +75,7 @@ static MatchingModule matchingModuleTCP = { .finalizeMatching= &finalizeMatchingTCP, .printMatchingStats= &printMatchingStatsTCP, .writeMatchingGraphsPlots= &writeMatchingGraphsPlotsTCP, - .writeMatchingGraphsOptions= &writeMatchingGraphsOptionsTCP, + .writeMatchingGraphsOptions= NULL, }; @@ -275,8 +273,8 @@ static GArray* finalizeMatchingTCP(SyncState* const syncState) /* - * Print statistics related to matching and downstream modules. Must be - * called after finalizeMatching. + * Print statistics related to matching. Must be called after + * finalizeMatching. * * Args: * syncState container for synchronization data. @@ -318,11 +316,6 @@ static void printMatchingStatsTCP(SyncState* const syncState) printf("\ttotal synchronization exchanges: %u\n", matchingData->stats->totExchangeSync); } - - if (syncState->analysisModule->printAnalysisStats != NULL) - { - syncState->analysisModule->printAnalysisStats(syncState); - } } @@ -702,8 +695,7 @@ static void closeGraphDataFiles(SyncState* const syncState) /* - * Write the matching-specific graph lines in the gnuplot script. Call the - * downstream module's graph function. + * Write the matching-specific graph lines in the gnuplot script. * * Args: * stream: stream where to write the data @@ -721,31 +713,4 @@ static void writeMatchingGraphsPlotsTCP(FILE* stream, SyncState* const "\t\"matching_tcp-%2$03d_to_%1$03d.data\" " "title \"Received messages\" with points linetype 4 " "linecolor rgb \"#6699cc\" pointtype 11 pointsize 2, \\\n", i, j); - - if (syncState->analysisModule->writeAnalysisGraphsPlots != NULL) - { - syncState->analysisModule->writeAnalysisGraphsPlots(stream, syncState, - i, j); - } -} - - -/* - * Write the matching-specific options in the gnuplot script (none). Call the - * downstream module's options function. - * - * Args: - * stream: stream where to write the data - * syncState: container for synchronization data - * i: first trace number - * j: second trace number, garanteed to be larger than i - */ -static void writeMatchingGraphsOptionsTCP(FILE* stream, SyncState* const - syncState, const unsigned int i, const unsigned int j) -{ - if (syncState->analysisModule->writeAnalysisGraphsOptions != NULL) - { - syncState->analysisModule->writeAnalysisGraphsOptions(stream, - syncState, i, j); - } } diff --git a/lttv/lttv/sync/event_processing_lttng_standard.c b/lttv/lttv/sync/event_processing_lttng_standard.c index b79ca4af..8c20f975 100644 --- a/lttv/lttv/sync/event_processing_lttng_standard.c +++ b/lttv/lttv/sync/event_processing_lttng_standard.c @@ -47,8 +47,6 @@ static void destroyProcessingLTTVStandard(SyncState* const syncState); static void finalizeProcessingLTTVStandard(SyncState* const syncState); static void printProcessingStatsLTTVStandard(SyncState* const syncState); -static void writeProcessingGraphsPlotsLTTVStandard(FILE* stream, SyncState* - const syncState, const unsigned int i, const unsigned int j); static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState* const syncState, const unsigned int i, const unsigned int j); @@ -64,7 +62,7 @@ static ProcessingModule processingModuleLTTVStandard = { .destroyProcessing= &destroyProcessingLTTVStandard, .finalizeProcessing= &finalizeProcessingLTTVStandard, .printProcessingStats= &printProcessingStatsLTTVStandard, - .writeProcessingGraphsPlots= &writeProcessingGraphsPlotsLTTVStandard, + .writeProcessingGraphsPlots= NULL, .writeProcessingGraphsOptions= &writeProcessingGraphsOptionsLTTVStandard, }; @@ -224,15 +222,14 @@ static void finalizeProcessingLTTVStandard(SyncState* const syncState) /* - * Print statistics related to processing and downstream modules. Must be - * called after finalizeProcessing. + * Print statistics related to processing Must be called after + * finalizeProcessing. * * Args: * syncState container for synchronization data. */ static void printProcessingStatsLTTVStandard(SyncState* const syncState) { - unsigned int i; ProcessingDataLTTVStandard* processingData; if (!syncState->stats) @@ -261,24 +258,6 @@ static void printProcessingStatsLTTVStandard(SyncState* const syncState) printf("\tsent packets that are TCP: %d\n", processingData->stats->totOutE); } - - if (syncState->matchingModule->printMatchingStats != NULL) - { - syncState->matchingModule->printMatchingStats(syncState); - } - - printf("Resulting synchronization factors:\n"); - for (i= 0; i < syncState->traceNb; i++) - { - LttTrace* t; - - t= processingData->traceSetContext->traces[i]->t; - - printf("\ttrace %u drift= %g offset= %g (%f) start time= %ld.%09ld\n", - i, t->drift, t->offset, (double) tsc_to_uint64(t->freq_scale, - t->start_freq, t->offset) / NANOSECONDS_PER_SECOND, - t->start_time_from_tsc.tv_sec, t->start_time_from_tsc.tv_nsec); - } } @@ -670,29 +649,7 @@ static gboolean processEventLTTVStandard(void* hookData, void* callData) /* - * Write the processing-specific graph lines in the gnuplot script (none at - * the moment). Call the downstream module's graph function. - * - * Args: - * stream: stream where to write the data - * syncState: container for synchronization data - * i: first trace number - * j: second trace number, garanteed to be larger than i - */ -static void writeProcessingGraphsPlotsLTTVStandard(FILE* stream, SyncState* - const syncState, const unsigned int i, const unsigned int j) -{ - if (syncState->matchingModule->writeMatchingGraphsPlots != NULL) - { - syncState->matchingModule->writeMatchingGraphsPlots(stream, syncState, - i, j); - } -} - - -/* - * Write the processing-specific options in the gnuplot script. Call the - * downstream module's options function. + * Write the processing-specific options in the gnuplot script. * * Args: * stream: stream where to write the data @@ -712,6 +669,11 @@ static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState* traceJ= processingData->traceSetContext->traces[j]->t; fprintf(stream, + "set key inside right bottom\n" + "set xlabel \"Clock %1$u\"\n" + "set xtics nomirror\n" + "set ylabel \"Clock %3$u\"\n" + "set ytics nomirror\n" "set x2label \"Clock %1$d (s)\"\n" "set x2range [GPVAL_X_MIN / %2$.1f : GPVAL_X_MAX / %2$.1f]\n" "set x2tics\n" @@ -719,10 +681,4 @@ static void writeProcessingGraphsOptionsLTTVStandard(FILE* stream, SyncState* "set y2range [GPVAL_Y_MIN / %4$.1f : GPVAL_Y_MAX / %4$.1f]\n" "set y2tics\n", i, (double) traceI->start_freq / traceI->freq_scale, j, (double) traceJ->start_freq / traceJ->freq_scale); - - if (syncState->matchingModule->writeMatchingGraphsOptions != NULL) - { - syncState->matchingModule->writeMatchingGraphsOptions(stream, - syncState, i, j); - } } diff --git a/lttv/lttv/sync/sync_chain_lttv.c b/lttv/lttv/sync/sync_chain_lttv.c index cd8532a9..9b2b8fe2 100644 --- a/lttv/lttv/sync/sync_chain_lttv.c +++ b/lttv/lttv/sync/sync_chain_lttv.c @@ -170,6 +170,7 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) struct rusage startUsage, endUsage; GList* result; FILE* graphsStream; + unsigned int i, j; int retval; if (!optionSync.present) @@ -285,8 +286,6 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) // Write graphs file if (graphsStream != NULL) { - unsigned int i, j; - fprintf(graphsStream, "#!/usr/bin/gnuplot\n\n" "set terminal postscript eps color size 8in,6in\n"); @@ -296,19 +295,43 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) { for (j= i + 1; j < syncState->traceNb; j++) { - long pos; + long pos1, pos2, trunc; fprintf(graphsStream, "\nset output \"%03d-%03d.eps\"\n" "plot \\\n", i, j); - syncState->processingModule->writeProcessingGraphsPlots(graphsStream, - syncState, i, j); + if (syncState->processingModule->writeProcessingGraphsPlots) + { + syncState->processingModule->writeProcessingGraphsPlots(graphsStream, + syncState, i, j); + } + if (syncState->matchingModule->writeMatchingGraphsPlots) + { + syncState->matchingModule->writeMatchingGraphsPlots(graphsStream, + syncState, i, j); + } + if (syncState->analysisModule->writeAnalysisGraphsPlots) + { + syncState->analysisModule->writeAnalysisGraphsPlots(graphsStream, + syncState, i, j); + } - // Remove the ", \\\n" from the last graph plot line fflush(graphsStream); - pos= ftell(graphsStream); - if (ftruncate(fileno(graphsStream), pos - 4) == -1) + pos2= ftell(graphsStream); + if (pos1 != pos2) + { + // Remove the ", \\\n" from the last graph plot line + trunc= pos2 - 4; + } + else + { + // Remove the "plot \\\n" line to avoid creating an invalid + // gnuplot script + trunc= pos2 - 7; + } + + if (ftruncate(fileno(graphsStream), trunc) == -1) { g_error(strerror(errno)); } @@ -318,19 +341,29 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) } fprintf(graphsStream, - "\nset output \"%1$03d-%2$03d.eps\"\n" - "set key inside right bottom\n" - "set title \"\"\n" - "set xlabel \"Clock %1$u\"\n" - "set xtics nomirror\n" - "set ylabel \"Clock %2$u\"\n" - "set ytics nomirror\n", i, j); + "\nset output \"%03d-%03d.eps\"\n" + "set title \"\"\n", i, j); - syncState->processingModule->writeProcessingGraphsOptions(graphsStream, - syncState, i, j); + if (syncState->processingModule->writeProcessingGraphsOptions) + { + syncState->processingModule->writeProcessingGraphsOptions(graphsStream, + syncState, i, j); + } + if (syncState->matchingModule->writeMatchingGraphsOptions) + { + syncState->matchingModule->writeMatchingGraphsOptions(graphsStream, + syncState, i, j); + } + if (syncState->analysisModule->writeAnalysisGraphsOptions) + { + syncState->analysisModule->writeAnalysisGraphsOptions(graphsStream, + syncState, i, j); + } - fprintf(graphsStream, - "replot\n"); + if (pos1 != pos2) + { + fprintf(graphsStream, "replot\n"); + } } } @@ -344,6 +377,31 @@ void syncTraceset(LttvTracesetContext* const traceSetContext) { syncState->processingModule->printProcessingStats(syncState); } + if (syncState->matchingModule->printMatchingStats != NULL) + { + syncState->matchingModule->printMatchingStats(syncState); + } + if (syncState->analysisModule->printAnalysisStats != NULL) + { + syncState->analysisModule->printAnalysisStats(syncState); + } + + if (optionSyncStats.present) + { + printf("Resulting synchronization factors:\n"); + for (i= 0; i < syncState->traceNb; i++) + { + LttTrace* t; + + t= traceSetContext->traces[i]->t; + + printf("\ttrace %u drift= %g offset= %g (%f) start time= %ld.%09ld\n", + i, t->drift, t->offset, (double) tsc_to_uint64(t->freq_scale, + t->start_freq, t->offset) / NANOSECONDS_PER_SECOND, + t->start_time_from_tsc.tv_sec, + t->start_time_from_tsc.tv_nsec); + } + } syncState->processingModule->destroyProcessing(syncState); if (syncState->matchingModule != NULL) diff --git a/lttv/modules/text/sync_chain_batch.c b/lttv/modules/text/sync_chain_batch.c index 3dfc7287..b3f873ca 100644 --- a/lttv/modules/text/sync_chain_batch.c +++ b/lttv/modules/text/sync_chain_batch.c @@ -124,7 +124,7 @@ static void init() "synchronization points", "none", LTTV_OPT_NONE, &optionEvalGraphs, NULL, NULL); - retval= snprintf(graphsDir, sizeof(graphsDir), "graphs-%d", getpid()); + retval= snprintf(graphsDir, sizeof(graphsDir), "eval-graphs-%d", getpid()); if (retval > sizeof(graphsDir) - 1) { graphsDir[sizeof(graphsDir) - 1]= '\0'; @@ -339,7 +339,8 @@ void setupSyncChain(LttvTracesetContext* const traceSetContext) syncState->analysisModule->initAnalysis(syncState); syncState->matchingData= NULL; - result= g_queue_find_custom(&matchingModules, "broadcast", &gcfCompareMatching); + result= g_queue_find_custom(&matchingModules, "distributor", + &gcfCompareMatching); syncState->matchingModule= (MatchingModule*) result->data; syncState->matchingModule->initMatching(syncState); @@ -363,6 +364,7 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext) SyncState* syncState; struct timeval endTime; struct rusage endUsage; + unsigned int i, j; int retval; tracesetChainState= g_hash_table_lookup(tracesetChainStates, traceSetContext); @@ -373,8 +375,6 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext) // Write graphs file if (tracesetChainState->graphsStream != NULL) { - unsigned int i, j; - fprintf(tracesetChainState->graphsStream, "#!/usr/bin/gnuplot\n\n" "set terminal postscript eps color size 8in,6in\n"); @@ -384,19 +384,34 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext) { for (j= i + 1; j < syncState->traceNb; j++) { - long pos; + long pos1, pos2, trunc; fprintf(tracesetChainState->graphsStream, "\nset output \"%03d-%03d.eps\"\n" "plot \\\n", i, j); + pos1= ftell(tracesetChainState->graphsStream); - syncState->processingModule->writeProcessingGraphsPlots(tracesetChainState->graphsStream, - syncState, i, j); + if (syncState->analysisModule->writeAnalysisGraphsPlots) + { + syncState->analysisModule->writeAnalysisGraphsPlots(tracesetChainState->graphsStream, + syncState, i, j); + } - // Remove the ", \\\n" from the last graph plot line fflush(tracesetChainState->graphsStream); - pos= ftell(tracesetChainState->graphsStream); - if (ftruncate(fileno(tracesetChainState->graphsStream), pos - 4) == -1) + pos2= ftell(tracesetChainState->graphsStream); + if (pos1 != pos2) + { + // Remove the ", \\\n" from the last graph plot line + trunc= pos2 - 4; + } + else + { + // Remove the "plot \\\n" line to avoid creating an invalid + // gnuplot script + trunc= pos2 - 7; + } + + if (ftruncate(fileno(tracesetChainState->graphsStream), trunc) == -1) { g_error(strerror(errno)); } @@ -407,18 +422,18 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext) fprintf(tracesetChainState->graphsStream, "\nset output \"%1$03d-%2$03d.eps\"\n" - "set key inside right bottom\n" - "set title \"\"\n" - "set xlabel \"Clock %1$u\"\n" - "set xtics nomirror\n" - "set ylabel \"Clock %2$u\"\n" - "set ytics nomirror\n", i, j); + "set title \"\"\n", i, j); - syncState->processingModule->writeProcessingGraphsOptions(tracesetChainState->graphsStream, - syncState, i, j); + if (syncState->analysisModule->writeAnalysisGraphsOptions) + { + syncState->analysisModule->writeAnalysisGraphsOptions(tracesetChainState->graphsStream, + syncState, i, j); + } - fprintf(tracesetChainState->graphsStream, - "replot\n"); + if (pos1 != pos2) + { + fprintf(tracesetChainState->graphsStream, "replot\n"); + } } } @@ -432,6 +447,27 @@ void teardownSyncChain(LttvTracesetContext* const traceSetContext) { syncState->processingModule->printProcessingStats(syncState); } + if (syncState->matchingModule->printMatchingStats != NULL) + { + syncState->matchingModule->printMatchingStats(syncState); + } + if (syncState->analysisModule->printAnalysisStats != NULL) + { + syncState->analysisModule->printAnalysisStats(syncState); + } + + printf("Resulting synchronization factors:\n"); + for (i= 0; i < syncState->traceNb; i++) + { + LttTrace* t; + + t= traceSetContext->traces[i]->t; + + printf("\ttrace %u drift= %g offset= %g (%f) start time= %ld.%09ld\n", + i, t->drift, t->offset, (double) tsc_to_uint64(t->freq_scale, + t->start_freq, t->offset) / NANOSECONDS_PER_SECOND, + t->start_time_from_tsc.tv_sec, t->start_time_from_tsc.tv_nsec); + } syncState->processingModule->destroyProcessing(syncState); if (syncState->matchingModule != NULL) -- 2.34.1