Call the stats and graph functions from sync_chain
authorBenjamin Poirier <benjamin.poirier@polymtl.ca>
Tue, 3 Nov 2009 18:57:36 +0000 (13:57 -0500)
committerBenjamin Poirier <benjamin.poirier@polymtl.ca>
Fri, 18 Dec 2009 19:03:25 +0000 (14:03 -0500)
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 <benjamin.poirier@polymtl.ca>
lttv/lttv/sync/event_analysis_chull.c
lttv/lttv/sync/event_matching_broadcast.c
lttv/lttv/sync/event_matching_tcp.c
lttv/lttv/sync/event_processing_lttng_standard.c
lttv/lttv/sync/sync_chain_lttv.c
lttv/modules/text/sync_chain_batch.c

index 0bea74a879f325d34f9b2d5dc2cabc33e7488d80..41fdbca4c7764a45d19ed463232f8199c7bab709 100644 (file)
@@ -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);
index 32112014ca956302c8ea4d83be31950aa7be1219..297de2cd39033c79f53765e62312c622dac749c5 100644 (file)
@@ -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);
-       }
 }
index a8fdf5f007683630abfb967c0e29ac1a7889ad9f..0202380ccb6f2dca652c6cbe6702d9cba5bee65a 100644 (file)
@@ -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);
-       }
 }
index b79ca4af27d3cab4545eb79b8dc037d0280ef8c8..8c20f975d4bdf054acb3b38455abc9feaa5934bd 100644 (file)
@@ -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);
-       }
 }
index cd8532a990c5eed3ff640dc19ec807fedb3dd17a..9b2b8fe26f378ebe0ac4adcb8354b971bbcd9d1a 100644 (file)
@@ -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)
index 3dfc72878591cd7472c68829c08de0253f410166..b3f873ca76eceeb4719f9022c39e472265c02b8c 100644 (file)
@@ -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)
This page took 0.032556 seconds and 4 git commands to generate.