From c6356aa749f534f9bc0aa6315d41bff0e69a6ef9 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Tue, 24 Nov 2009 16:17:51 -0500 Subject: [PATCH] Have callbacks for "background" and "foreground" graphs Allows easier composition of many functions on a single graph. Signed-off-by: Benjamin Poirier --- lttv/lttv/sync/event_analysis_chull.c | 3 +- lttv/lttv/sync/event_analysis_eval.c | 61 ++++++++++++++------ lttv/lttv/sync/event_analysis_linreg.c | 2 +- lttv/lttv/sync/event_matching_broadcast.c | 2 +- lttv/lttv/sync/event_matching_distributor.c | 62 ++++++++++++++++++--- lttv/lttv/sync/event_matching_tcp.c | 10 ++-- lttv/lttv/sync/graph_functions.c | 58 ++++++++++++------- lttv/lttv/sync/graph_functions.h | 6 +- 8 files changed, 151 insertions(+), 53 deletions(-) diff --git a/lttv/lttv/sync/event_analysis_chull.c b/lttv/lttv/sync/event_analysis_chull.c index 50bb7ab5..e5da4c44 100644 --- a/lttv/lttv/sync/event_analysis_chull.c +++ b/lttv/lttv/sync/event_analysis_chull.c @@ -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 */ diff --git a/lttv/lttv/sync/event_analysis_eval.c b/lttv/lttv/sync/event_analysis_eval.c index ab4cffbe..63dd0e87 100644 --- a/lttv/lttv/sync/event_analysis_eval.c +++ b/lttv/lttv/sync/event_analysis_eval.c @@ -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); } diff --git a/lttv/lttv/sync/event_analysis_linreg.c b/lttv/lttv/sync/event_analysis_linreg.c index a79559e6..764a635f 100644 --- a/lttv/lttv/sync/event_analysis_linreg.c +++ b/lttv/lttv/sync/event_analysis_linreg.c @@ -75,7 +75,7 @@ static AnalysisModule analysisModuleLinReg= { .finalizeAnalysis= &finalizeAnalysisLinReg, .printAnalysisStats= &printAnalysisStatsLinReg, .graphFunctions= { - .writeTraceTracePlots= &writeAnalysisGraphsPlotsLinReg, + .writeTraceTraceForePlots= &writeAnalysisGraphsPlotsLinReg, } }; diff --git a/lttv/lttv/sync/event_matching_broadcast.c b/lttv/lttv/sync/event_matching_broadcast.c index 7579a4ac..ca5375b7 100644 --- a/lttv/lttv/sync/event_matching_broadcast.c +++ b/lttv/lttv/sync/event_matching_broadcast.c @@ -67,7 +67,7 @@ static MatchingModule matchingModuleBroadcast = { .finalizeMatching= &finalizeMatchingBroadcast, .printMatchingStats= &printMatchingStatsBroadcast, .graphFunctions= { - .writeTraceTimePlots= &writeMatchingGraphsPlotsBroadcast, + .writeTraceTimeForePlots= &writeMatchingGraphsPlotsBroadcast, } }; diff --git a/lttv/lttv/sync/event_matching_distributor.c b/lttv/lttv/sync/event_matching_distributor.c index 9eeaff7c..4bb7e68c 100644 --- a/lttv/lttv/sync/event_matching_distributor.c +++ b/lttv/lttv/sync/event_matching_distributor.c @@ -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}); } diff --git a/lttv/lttv/sync/event_matching_tcp.c b/lttv/lttv/sync/event_matching_tcp.c index f7692212..45255e32 100644 --- a/lttv/lttv/sync/event_matching_tcp.c +++ b/lttv/lttv/sync/event_matching_tcp.c @@ -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\" " diff --git a/lttv/lttv/sync/graph_functions.c b/lttv/lttv/sync/graph_functions.c index ca5be5ea..48b66a3c 100644 --- a/lttv/lttv/sync/graph_functions.c +++ b/lttv/lttv/sync/graph_functions.c @@ -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) { diff --git a/lttv/lttv/sync/graph_functions.h b/lttv/lttv/sync/graph_functions.h index d0b76948..55f9a13b 100644 --- a/lttv/lttv/sync/graph_functions.h +++ b/lttv/lttv/sync/graph_functions.h @@ -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; -- 2.34.1