]> git.lttng.org Git - lttv.git/commitdiff
Have callbacks for "background" and "foreground" graphs
authorBenjamin Poirier <benjamin.poirier@polymtl.ca>
Tue, 24 Nov 2009 21:17:51 +0000 (16:17 -0500)
committerBenjamin Poirier <benjamin.poirier@polymtl.ca>
Fri, 18 Dec 2009 19:04:17 +0000 (14:04 -0500)
Allows easier composition of many functions on a single graph.

Signed-off-by: Benjamin Poirier <benjamin.poirier@polymtl.ca>
lttv/lttv/sync/event_analysis_chull.c
lttv/lttv/sync/event_analysis_eval.c
lttv/lttv/sync/event_analysis_linreg.c
lttv/lttv/sync/event_matching_broadcast.c
lttv/lttv/sync/event_matching_distributor.c
lttv/lttv/sync/event_matching_tcp.c
lttv/lttv/sync/graph_functions.c
lttv/lttv/sync/graph_functions.h

index 50bb7ab5d6dba2654d0ba5a73596b7bf9b96e2db..e5da4c446ebb5eaea10a01efd1b9852a827c4bb9 100644 (file)
@@ -107,7 +107,7 @@ static AnalysisModule analysisModuleCHull= {
        .finalizeAnalysis= &finalizeAnalysisCHull,
        .printAnalysisStats= &printAnalysisStatsCHull,
        .graphFunctions= {
-               .writeTraceTracePlots= &writeAnalysisGraphsPlotsCHull,
+               .writeTraceTraceForePlots= &writeAnalysisGraphsPlotsCHull,
        }
 };
 
@@ -120,6 +120,7 @@ const char* const approxNames[]= {
        [SCREWED]= "Screwed",
 };
 
+
 /*
  * Analysis module registering function
  */
index ab4cffbef0469e807588e9fecd3d48299e705d19..63dd0e876fa025454c9781797fd67cead5d90016 100644 (file)
@@ -70,8 +70,10 @@ static GArray* finalizeAnalysisEval(SyncState* const syncState);
 static void printAnalysisStatsEval(SyncState* const syncState);
 static void writeAnalysisTraceTimePlotsEval(SyncState* const syncState, const
        unsigned int i, const unsigned int j);
-static void writeAnalysisTraceTracePlotsEval(SyncState* const syncState, const
-       unsigned int i, const unsigned int j);
+static void writeAnalysisTraceTraceBackPlotsEval(SyncState* const syncState,
+       const unsigned int i, const unsigned int j);
+static void writeAnalysisTraceTraceForePlotsEval(SyncState* const syncState,
+       const unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerAnalysisEval() __attribute__((constructor (102)));
@@ -104,15 +106,18 @@ static void dumpBinToFile(const struct Bins* const bins, FILE* const file);
 static void writeHistogram(FILE* graphsStream, const struct RttKey* rttKey,
        double* minRtt, AnalysisHistogramEval* const histogram);
 
-static void updateBounds(Bounds** const bounds, Event* const e1, Event* const e2);
+static void updateBounds(Bounds** const bounds, Event* const e1, Event* const
+       e2);
 
 // The next group of functions is only needed when computing synchronization
 // accuracy.
 #ifdef HAVE_LIBGLPK
-static glp_prob* lpCreateProblem(GQueue* const lowerHull, GQueue* const upperHull);
+static glp_prob* lpCreateProblem(GQueue* const lowerHull, GQueue* const
+       upperHull);
 static void gfLPAddRow(gpointer data, gpointer user_data);
 static Factors* calculateFactors(glp_prob* const lp, const int direction);
-static void calculateCompleteFactors(glp_prob* const lp, FactorsCHull* factors);
+static void calculateCompleteFactors(glp_prob* const lp, FactorsCHull*
+       factors);
 static FactorsCHull** createAllFactors(const unsigned int traceNb);
 static inline void finalizeAnalysisEvalLP(SyncState* const syncState);
 #else
@@ -133,8 +138,9 @@ static AnalysisModule analysisModuleEval= {
        .finalizeAnalysis= &finalizeAnalysisEval,
        .printAnalysisStats= &printAnalysisStatsEval,
        .graphFunctions= {
-               .writeTraceTimePlots= &writeAnalysisTraceTimePlotsEval,
-               .writeTraceTracePlots= &writeAnalysisTraceTracePlotsEval,
+               .writeTraceTimeBackPlots= &writeAnalysisTraceTimePlotsEval,
+               .writeTraceTraceBackPlots= &writeAnalysisTraceTraceBackPlotsEval,
+               .writeTraceTraceForePlots= &writeAnalysisTraceTraceForePlotsEval,
        }
 };
 
@@ -1456,7 +1462,8 @@ static uint32_t normalTotal(struct Bins* const bins)
  *   bounds:       the array containing all the trace-pair bounds
  *   e1, e2:       the two related events
  */
-static void updateBounds(Bounds** const bounds, Event* const e1, Event* const e2)
+static void updateBounds(Bounds** const bounds, Event* const e1, Event* const
+       e2)
 {
        unsigned int traceI, traceJ;
        uint64_t messageTime;
@@ -1501,7 +1508,8 @@ static void updateBounds(Bounds** const bounds, Event* const e1, Event* const e2
  *   A new glp_prob*, this problem must be freed by the caller with
  *   glp_delete_prob()
  */
-static glp_prob* lpCreateProblem(GQueue* const lowerHull, GQueue* const upperHull)
+static glp_prob* lpCreateProblem(GQueue* const lowerHull, GQueue* const
+       upperHull)
 {
        unsigned int it;
        const int zero= 0;
@@ -1809,8 +1817,8 @@ static void finalizeAnalysisEvalLP(SyncState* const syncState)
  *   j:            second trace number, garanteed to be larger than i
  */
 #ifndef HAVE_LIBGLPK
-static inline void writeAccuracyGraphs(SyncState* const syncState, const unsigned int
-       i, const unsigned int j)
+static inline void writeAccuracyGraphs(SyncState* const syncState, const
+       unsigned int i, const unsigned int j)
 {
 }
 #else
@@ -1957,11 +1965,17 @@ static void writeAnalysisTraceTimePlotsEval(SyncState* const syncState, const
 }
 
 
-static void writeAnalysisTraceTracePlotsEval(SyncState* const syncState, const
-       unsigned int i, const unsigned int j)
+/*
+ * Write the analysis-specific graph lines in the gnuplot script.
+ *
+ * Args:
+ *   syncState:    container for synchronization data
+ *   i:            first trace number
+ *   j:            second trace number, garanteed to be larger than i
+ */
+static void writeAnalysisTraceTraceBackPlotsEval(SyncState* const syncState,
+       const unsigned int i, const unsigned int j)
 {
-       AnalysisDataEval* analysisData= syncState->analysisData;
-
 #ifdef HAVE_LIBGLPK
        fprintf(syncState->graphsStream,
                "\t\"analysis_eval_accuracy-%1$03u_and_%2$03u.data\" "
@@ -1970,7 +1984,22 @@ static void writeAnalysisTraceTracePlotsEval(SyncState* const syncState, const
                "with filledcurves linewidth 2 linetype 1 "
                "linecolor rgb \"black\" fill solid 0.25 noborder, \\\n", i, j);
 #endif
+}
+
+
+/*
+ * Write the analysis-specific graph lines in the gnuplot script.
+ *
+ * Args:
+ *   syncState:    container for synchronization data
+ *   i:            first trace number
+ *   j:            second trace number, garanteed to be larger than i
+ */
+static void writeAnalysisTraceTraceForePlotsEval(SyncState* const syncState,
+       const unsigned int i, const unsigned int j)
+{
+       AnalysisDataEval* analysisData= syncState->analysisData;
 
-       analysisData->chullSS->analysisModule->graphFunctions.writeTraceTracePlots(analysisData->chullSS,
+       analysisData->chullSS->analysisModule->graphFunctions.writeTraceTraceForePlots(analysisData->chullSS,
                i, j);
 }
index a79559e646ab034c486bfa094bfe7df718e71c90..764a635fa5e536f127a015adb51d6d13d163662d 100644 (file)
@@ -75,7 +75,7 @@ static AnalysisModule analysisModuleLinReg= {
        .finalizeAnalysis= &finalizeAnalysisLinReg,
        .printAnalysisStats= &printAnalysisStatsLinReg,
        .graphFunctions= {
-               .writeTraceTracePlots= &writeAnalysisGraphsPlotsLinReg,
+               .writeTraceTraceForePlots= &writeAnalysisGraphsPlotsLinReg,
        }
 };
 
index 7579a4ac65f6724fdc2751b210c56c6485531784..ca5375b794bb618e0c4ce90d3d98d20d8012f0d8 100644 (file)
@@ -67,7 +67,7 @@ static MatchingModule matchingModuleBroadcast = {
        .finalizeMatching= &finalizeMatchingBroadcast,
        .printMatchingStats= &printMatchingStatsBroadcast,
        .graphFunctions= {
-               .writeTraceTimePlots= &writeMatchingGraphsPlotsBroadcast,
+               .writeTraceTimeForePlots= &writeMatchingGraphsPlotsBroadcast,
        }
 };
 
index 9eeaff7c441f0b9abff9038f600836097f0d7672..4bb7e68cd50dd9158dadd414b4c4b0cd642795a6 100644 (file)
@@ -54,11 +54,15 @@ static void matchEventDistributor(SyncState* const syncState, Event* const
        event);
 static GArray* finalizeMatchingDistributor(SyncState* const syncState);
 static void printMatchingStatsDistributor(SyncState* const syncState);
-static void writeMatchingTraceTracePlotsDistributor(SyncState* const
+static void writeMatchingTraceTraceForePlotsDistributor(SyncState* const
+       syncState, const unsigned int i, const unsigned int j);
+static void writeMatchingTraceTraceBackPlotsDistributor(SyncState* const
        syncState, const unsigned int i, const unsigned int j);
 static void writeMatchingTraceTraceOptionsDistributor(SyncState* const
        syncState, const unsigned int i, const unsigned int j);
-static void writeMatchingTraceTimePlotsDistributor(SyncState* const
+static void writeMatchingTraceTimeForePlotsDistributor(SyncState* const
+       syncState, const unsigned int i, const unsigned int j);
+static void writeMatchingTraceTimeBackPlotsDistributor(SyncState* const
        syncState, const unsigned int i, const unsigned int j);
 static void writeMatchingTraceTimeOptionsDistributor(SyncState* const
        syncState, const unsigned int i, const unsigned int j);
@@ -84,9 +88,13 @@ static MatchingModule matchingModuleDistributor = {
        .finalizeMatching= &finalizeMatchingDistributor,
        .printMatchingStats= &printMatchingStatsDistributor,
        .graphFunctions= {
-               .writeTraceTracePlots= &writeMatchingTraceTracePlotsDistributor,
+               .writeTraceTraceForePlots=
+                       &writeMatchingTraceTraceForePlotsDistributor,
+               .writeTraceTraceBackPlots=
+                       &writeMatchingTraceTraceBackPlotsDistributor,
                .writeTraceTraceOptions= &writeMatchingTraceTraceOptionsDistributor,
-               .writeTraceTimePlots= &writeMatchingTraceTimePlotsDistributor,
+               .writeTraceTimeForePlots= &writeMatchingTraceTimeForePlotsDistributor,
+               .writeTraceTimeBackPlots= &writeMatchingTraceTimeBackPlotsDistributor,
                .writeTraceTimeOptions= &writeMatchingTraceTimeOptionsDistributor,
        },
 };
@@ -218,14 +226,52 @@ static void printMatchingStatsDistributor(SyncState* const syncState)
  *   i:            first trace number
  *   j:            second trace number, garanteed to be larger than i
  */
-static void writeMatchingTraceTracePlotsDistributor(SyncState* const
+static void writeMatchingTraceTraceForePlotsDistributor(SyncState* const
+       syncState, const unsigned int i, const unsigned int j)
+{
+       MatchingDataDistributor* matchingData= syncState->matchingData;
+
+       g_queue_foreach(matchingData->distributedModules, &gfGraphFunctionCall,
+               &(struct GraphAggregate) {offsetof(MatchingModule,
+                       graphFunctions.writeTraceTraceForePlots), i, j});
+}
+
+
+/*
+ * Call the distributed graph lines functions (when they exist).
+ *
+ * Args:
+ *   syncState:    container for synchronization data
+ *   i:            first trace number
+ *   j:            second trace number, garanteed to be larger than i
+ */
+static void writeMatchingTraceTraceBackPlotsDistributor(SyncState* const
+       syncState, const unsigned int i, const unsigned int j)
+{
+       MatchingDataDistributor* matchingData= syncState->matchingData;
+
+       g_queue_foreach(matchingData->distributedModules, &gfGraphFunctionCall,
+               &(struct GraphAggregate) {offsetof(MatchingModule,
+                       graphFunctions.writeTraceTraceBackPlots), i, j});
+}
+
+
+/*
+ * Call the distributed graph lines functions (when they exist).
+ *
+ * Args:
+ *   syncState:    container for synchronization data
+ *   i:            first trace number
+ *   j:            second trace number, garanteed to be larger than i
+ */
+static void writeMatchingTraceTimeForePlotsDistributor(SyncState* const
        syncState, const unsigned int i, const unsigned int j)
 {
        MatchingDataDistributor* matchingData= syncState->matchingData;
 
        g_queue_foreach(matchingData->distributedModules, &gfGraphFunctionCall,
                &(struct GraphAggregate) {offsetof(MatchingModule,
-                       graphFunctions.writeTraceTracePlots), i, j});
+                       graphFunctions.writeTraceTimeForePlots), i, j});
 }
 
 
@@ -237,14 +283,14 @@ static void writeMatchingTraceTracePlotsDistributor(SyncState* const
  *   i:            first trace number
  *   j:            second trace number, garanteed to be larger than i
  */
-static void writeMatchingTraceTimePlotsDistributor(SyncState* const
+static void writeMatchingTraceTimeBackPlotsDistributor(SyncState* const
        syncState, const unsigned int i, const unsigned int j)
 {
        MatchingDataDistributor* matchingData= syncState->matchingData;
 
        g_queue_foreach(matchingData->distributedModules, &gfGraphFunctionCall,
                &(struct GraphAggregate) {offsetof(MatchingModule,
-                       graphFunctions.writeTraceTimePlots), i, j});
+                       graphFunctions.writeTraceTimeBackPlots), i, j});
 }
 
 
index f769221226b2b1deae8bdeba37a26c74b8bd48b2..45255e32516b8c15ab14b98631541cc95b595142 100644 (file)
@@ -43,8 +43,8 @@ static void destroyMatchingTCP(SyncState* const syncState);
 static void matchEventTCP(SyncState* const syncState, Event* const event);
 static GArray* finalizeMatchingTCP(SyncState* const syncState);
 static void printMatchingStatsTCP(SyncState* const syncState);
-static void writeMatchingGraphsPlotsTCP(SyncState* const syncState, const
-       unsigned int i, const unsigned int j);
+static void writeMatchingGraphsPlotsTCPMessages(SyncState* const syncState,
+       const unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerMatchingTCP() __attribute__((constructor (101)));
@@ -75,7 +75,7 @@ static MatchingModule matchingModuleTCP = {
        .finalizeMatching= &finalizeMatchingTCP,
        .printMatchingStats= &printMatchingStatsTCP,
        .graphFunctions= {
-               .writeTraceTracePlots= &writeMatchingGraphsPlotsTCP,
+               .writeTraceTraceForePlots= &writeMatchingGraphsPlotsTCPMessages,
        }
 };
 
@@ -703,8 +703,8 @@ static void closeGraphDataFiles(SyncState* const syncState)
  *   i:            first trace number
  *   j:            second trace number, garanteed to be larger than i
  */
-static void writeMatchingGraphsPlotsTCP(SyncState* const syncState, const
-       unsigned int i, const unsigned int j)
+static void writeMatchingGraphsPlotsTCPMessages(SyncState* const syncState,
+       const unsigned int i, const unsigned int j)
 {
        fprintf(syncState->graphsStream,
                "\t\"matching_tcp-%1$03d_to_%2$03d.data\" "
index ca5be5ea1f88558fdea115f919972d7ba8b2087f..48b66a3cd4bbb54b1945e870dbec53711dd1600d 100644 (file)
@@ -30,7 +30,7 @@
 
 void writeGraphsScript(SyncState* const syncState)
 {
-       unsigned int i, j, k, l;
+       unsigned int i, j, k, l, m;
        long pos1, pos2;
        const GraphFunctions* moduleGraphFunctions[]= {
                &syncState->processingModule->graphFunctions,
@@ -38,17 +38,31 @@ void writeGraphsScript(SyncState* const syncState)
                &syncState->analysisModule->graphFunctions,
        };
        const struct {
-               size_t plotsOffset,
-                          optionsOffset;
                char* name;
-       } funcTypes[]= {
-               {offsetof(GraphFunctions, writeTraceTracePlots),
-                       offsetof(GraphFunctions, writeTraceTraceOptions), "TraceTrace"},
-               {offsetof(GraphFunctions, writeTraceTimePlots),
-                       offsetof(GraphFunctions, writeTraceTimeOptions), "TraceTime"},
+               size_t plotsOffsets[2];
+               size_t optionsOffset;
+       } graphTypes[]= {
+               {
+                       "TraceTrace",
+                       {
+                               offsetof(GraphFunctions, writeTraceTraceBackPlots),
+                               offsetof(GraphFunctions, writeTraceTraceForePlots),
+                       },
+                       offsetof(GraphFunctions, writeTraceTraceOptions),
+               },
+               {
+                       "TraceTime",
+                       {
+                               offsetof(GraphFunctions, writeTraceTimeBackPlots),
+                               offsetof(GraphFunctions, writeTraceTimeForePlots),
+                       },
+                       offsetof(GraphFunctions, writeTraceTimeOptions),
+               },
        };
 
        fprintf(syncState->graphsStream, "\n");
+
+       // Write variables
        pos1= ftell(syncState->graphsStream);
        for (i= 0; i < syncState->traceNb; i++)
        {
@@ -72,7 +86,8 @@ void writeGraphsScript(SyncState* const syncState)
                fprintf(syncState->graphsStream, "\n");
        }
 
-       for (l= 0; l < sizeof(funcTypes) / sizeof(*funcTypes); l++)
+       // Write plots and options
+       for (l= 0; l < sizeof(graphTypes) / sizeof(*graphTypes); l++)
        {
                // Cover the upper triangular matrix, i is the reference node.
                for (i= 0; i < syncState->traceNb; i++)
@@ -84,19 +99,24 @@ void writeGraphsScript(SyncState* const syncState)
                                fprintf(syncState->graphsStream,
                                        "reset\n"
                                        "set output \"%03d-%03d-%s.eps\"\n"
-                                       "plot \\\n", i, j, funcTypes[l].name);
+                                       "plot \\\n", i, j, graphTypes[l].name);
 
                                pos1= ftell(syncState->graphsStream);
 
-                               for (k= 0; k < sizeof(moduleGraphFunctions) /
-                                       sizeof(*moduleGraphFunctions); k++)
+                               for (m= 0; m < sizeof(graphTypes[l].plotsOffsets) /
+                                       sizeof(*graphTypes[l].plotsOffsets); m++)
                                {
-                                       GraphFunction** writePlots= (void*)
-                                               moduleGraphFunctions[k] + funcTypes[l].plotsOffset;
-
-                                       if (*writePlots)
+                                       for (k= 0; k < sizeof(moduleGraphFunctions) /
+                                               sizeof(*moduleGraphFunctions); k++)
                                        {
-                                               (*writePlots)(syncState, i, j);
+                                               GraphFunction** writePlots= (void*)
+                                                       moduleGraphFunctions[k] +
+                                                       graphTypes[l].plotsOffsets[m];
+
+                                               if (*writePlots)
+                                               {
+                                                       (*writePlots)(syncState, i, j);
+                                               }
                                        }
                                }
 
@@ -125,13 +145,13 @@ void writeGraphsScript(SyncState* const syncState)
 
                                fprintf(syncState->graphsStream,
                                        "\nset output \"%03d-%03d-%s.eps\"\n"
-                                       "set title \"\"\n", i, j, funcTypes[l].name);
+                                       "set title \"\"\n", i, j, graphTypes[l].name);
 
                                for (k= 0; k < sizeof(moduleGraphFunctions) /
                                        sizeof(*moduleGraphFunctions); k++)
                                {
                                        GraphFunction** writeOptions= (void*)
-                                               moduleGraphFunctions[k] + funcTypes[l].optionsOffset;
+                                               moduleGraphFunctions[k] + graphTypes[l].optionsOffset;
 
                                        if (*writeOptions)
                                        {
index d0b76948ee6e213530e75da7e497b58c34610acc..55f9a13b6e4dfe6046d012f5405d1ea2b2cf866a 100644 (file)
@@ -31,11 +31,13 @@ typedef struct
        GraphVariableFunction* writeVariables;
        /* This is for graphs where the data on both axis is in the range of
         * timestamps */
-       GraphFunction* writeTraceTracePlots;
+       GraphFunction* writeTraceTraceForePlots;
+       GraphFunction* writeTraceTraceBackPlots;
        GraphFunction* writeTraceTraceOptions;
        /* This is for graphs where the data on the abscissa is in the range of
         * timestamps and the ordinates is in the range of timestamp deltas */
-       GraphFunction* writeTraceTimePlots;
+       GraphFunction* writeTraceTimeForePlots;
+       GraphFunction* writeTraceTimeBackPlots;
        GraphFunction* writeTraceTimeOptions;
 } GraphFunctions;
 
This page took 0.03367 seconds and 4 git commands to generate.