Store graph callbacks in a structure
[lttv.git] / lttv / lttv / sync / event_analysis_chull.c
index 367b97cf340406e57cff953e863e8626a6fc1819..257360183f3a888a7b8e66839c88c69c9a172ef0 100644 (file)
@@ -56,11 +56,12 @@ typedef enum
 static void initAnalysisCHull(SyncState* const syncState);
 static void destroyAnalysisCHull(SyncState* const syncState);
 
-static void analyzePacketCHull(SyncState* const syncState, Packet* const packet);
+static void analyzeMessageCHull(SyncState* const syncState, Message* const
+       message);
 static GArray* finalizeAnalysisCHull(SyncState* const syncState);
 static void printAnalysisStatsCHull(SyncState* const syncState);
-static void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const
-       syncState, const unsigned int i, const unsigned int j);
+static void writeAnalysisGraphsPlotsCHull(SyncState* const syncState, const
+       unsigned int i, const unsigned int j);
 
 // Functions specific to this module
 static void registerAnalysisCHull() __attribute__((constructor (101)));
@@ -106,12 +107,12 @@ static AnalysisModule analysisModuleCHull= {
        .name= "chull",
        .initAnalysis= &initAnalysisCHull,
        .destroyAnalysis= &destroyAnalysisCHull,
-       .analyzePacket= &analyzePacketCHull,
-       .analyzeExchange= NULL,
+       .analyzeMessage= &analyzeMessageCHull,
        .finalizeAnalysis= &finalizeAnalysisCHull,
        .printAnalysisStats= &printAnalysisStatsCHull,
-       .writeAnalysisGraphsPlots= &writeAnalysisGraphsPlotsCHull,
-       .writeAnalysisGraphsOptions= NULL,
+       .graphFunctions= {
+               .writeTraceTracePlots= &writeAnalysisGraphsPlotsCHull,
+       }
 };
 
 
@@ -165,7 +166,7 @@ static void initAnalysisCHull(SyncState* const syncState)
                analysisData->stats->allFactors= NULL;
        }
 
-       if (syncState->graphs)
+       if (syncState->graphsStream)
        {
                analysisData->graphsData= malloc(sizeof(AnalysisGraphsDataCHull));
                openGraphFiles(syncState);
@@ -191,7 +192,7 @@ static void openGraphFiles(SyncState* const syncState)
 
        analysisData= (AnalysisDataCHull*) syncState->analysisData;
 
-       cwd= changeToGraphDir(syncState->graphs);
+       cwd= changeToGraphDir(syncState->graphsDir);
 
        analysisData->graphsData->hullPoints= malloc(syncState->traceNb *
                sizeof(FILE**));
@@ -355,7 +356,7 @@ static void destroyAnalysisCHull(SyncState* const syncState)
                free(analysisData->stats);
        }
 
-       if (syncState->graphs)
+       if (syncState->graphsStream)
        {
                if (analysisData->graphsData->hullPoints != NULL)
                {
@@ -380,9 +381,9 @@ static void destroyAnalysisCHull(SyncState* const syncState)
  *
  * Args:
  *   syncState     container for synchronization data
- *   packet        structure containing the events
+ *   message       structure containing the events
  */
-static void analyzePacketCHull(SyncState* const syncState, Packet* const packet)
+static void analyzeMessageCHull(SyncState* const syncState, Message* const message)
 {
        AnalysisDataCHull* analysisData;
        Point* newPoint;
@@ -392,29 +393,29 @@ static void analyzePacketCHull(SyncState* const syncState, Packet* const packet)
        analysisData= (AnalysisDataCHull*) syncState->analysisData;
 
        newPoint= malloc(sizeof(Point));
-       if (packet->inE->traceNum < packet->outE->traceNum)
+       if (message->inE->traceNum < message->outE->traceNum)
        {
                // CA is inE->traceNum
-               newPoint->x= packet->inE->tsc;
-               newPoint->y= packet->outE->tsc;
+               newPoint->x= message->inE->cpuTime;
+               newPoint->y= message->outE->cpuTime;
                hullType= UPPER;
-               g_debug("Reception point hullArray[%lu][%lu] x= inE->tsc= %llu y= outE->tsc= %llu",
-                       packet->inE->traceNum, packet->outE->traceNum, newPoint->x,
+               g_debug("Reception point hullArray[%lu][%lu] x= inE->time= %llu y= outE->time= %llu",
+                       message->inE->traceNum, message->outE->traceNum, newPoint->x,
                        newPoint->y);
        }
        else
        {
                // CA is outE->traceNum
-               newPoint->x= packet->outE->tsc;
-               newPoint->y= packet->inE->tsc;
+               newPoint->x= message->outE->cpuTime;
+               newPoint->y= message->inE->cpuTime;
                hullType= LOWER;
-               g_debug("Send point hullArray[%lu][%lu] x= inE->tsc= %llu y= outE->tsc= %llu",
-                       packet->inE->traceNum, packet->outE->traceNum, newPoint->x,
+               g_debug("Send point hullArray[%lu][%lu] x= inE->time= %llu y= outE->time= %llu",
+                       message->inE->traceNum, message->outE->traceNum, newPoint->x,
                        newPoint->y);
        }
 
        hull=
-               analysisData->hullArray[packet->inE->traceNum][packet->outE->traceNum];
+               analysisData->hullArray[message->inE->traceNum][message->outE->traceNum];
 
        if (hull->length >= 1 && newPoint->x < ((Point*)
                        g_queue_peek_tail(hull))->x)
@@ -508,7 +509,7 @@ static GArray* finalizeAnalysisCHull(SyncState* const syncState)
 
        analysisData= (AnalysisDataCHull*) syncState->analysisData;
 
-       if (syncState->graphs)
+       if (syncState->graphsStream && analysisData->graphsData->hullPoints != NULL)
        {
                writeGraphFiles(syncState);
                closeGraphFiles(syncState);
@@ -518,14 +519,14 @@ static GArray* finalizeAnalysisCHull(SyncState* const syncState)
 
        factors= reduceFactors(syncState, allFactors);
 
-       if (syncState->stats || syncState->graphs)
+       if (syncState->stats || syncState->graphsStream)
        {
                if (syncState->stats)
                {
                        analysisData->stats->allFactors= allFactors;
                }
 
-               if (syncState->graphs)
+               if (syncState->graphsStream)
                {
                        analysisData->graphsData->allFactors= allFactors;
                }
@@ -1520,20 +1521,19 @@ static void getFactors(FactorsCHull** const allFactors, unsigned int** const
  * Write the analysis-specific graph lines in the gnuplot script.
  *
  * 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
  */
-void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
-       const unsigned int i, const unsigned int j)
+void writeAnalysisGraphsPlotsCHull(SyncState* const syncState, const unsigned
+       int i, const unsigned int j)
 {
        AnalysisDataCHull* analysisData;
        FactorsCHull* factorsCHull;
 
        analysisData= (AnalysisDataCHull*) syncState->analysisData;
 
-       fprintf(stream,
+       fprintf(syncState->graphsStream,
                "\t\"analysis_chull-%1$03d_to_%2$03d.data\" "
                        "title \"Lower half-hull\" with linespoints "
                        "linecolor rgb \"#015a01\" linetype 4 pointtype 8 pointsize 0.8, \\\n"
@@ -1545,7 +1545,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        factorsCHull= &analysisData->graphsData->allFactors[j][i];
        if (factorsCHull->type == EXACT)
        {
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%7g + %7g * x "
                                "title \"Exact conversion\" with lines "
                                "linecolor rgb \"black\" linetype 1, \\\n",
@@ -1553,17 +1553,17 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        }
        else if (factorsCHull->type == MIDDLE)
        {
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%.2f + %.10f * x "
                                "title \"Min conversion\" with lines "
                                "linecolor rgb \"black\" linetype 5, \\\n",
                                factorsCHull->min->offset, factorsCHull->min->drift);
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%.2f + %.10f * x "
                                "title \"Max conversion\" with lines "
                                "linecolor rgb \"black\" linetype 8, \\\n",
                                factorsCHull->max->offset, factorsCHull->max->drift);
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%.2f + %.10f * x "
                                "title \"Middle conversion\" with lines "
                                "linecolor rgb \"gray60\" linetype 1, \\\n",
@@ -1571,7 +1571,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        }
        else if (factorsCHull->type == FALLBACK)
        {
-               fprintf(stream,
+               fprintf(syncState->graphsStream,
                        "\t%.2f + %.10f * x "
                                "title \"Fallback conversion\" with lines "
                                "linecolor rgb \"gray60\" linetype 1, \\\n",
@@ -1581,7 +1581,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        {
                if (factorsCHull->min->drift != -INFINITY)
                {
-                       fprintf(stream,
+                       fprintf(syncState->graphsStream,
                                "\t%.2f + %.10f * x "
                                        "title \"Min conversion\" with lines "
                                        "linecolor rgb \"black\" linetype 5, \\\n",
@@ -1590,7 +1590,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
 
                if (factorsCHull->max->drift != INFINITY)
                {
-                       fprintf(stream,
+                       fprintf(syncState->graphsStream,
                                "\t%.2f + %.10f * x "
                                        "title \"Max conversion\" with lines "
                                        "linecolor rgb \"black\" linetype 8, \\\n",
@@ -1601,7 +1601,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
        {
                if (factorsCHull->min != NULL && factorsCHull->min->drift != -INFINITY)
                {
-                       fprintf(stream,
+                       fprintf(syncState->graphsStream,
                                "\t%.2f + %.10f * x "
                                        "title \"Min conversion\" with lines "
                                        "linecolor rgb \"black\" linetype 5, \\\n",
@@ -1610,7 +1610,7 @@ void writeAnalysisGraphsPlotsCHull(FILE* stream, SyncState* const syncState,
 
                if (factorsCHull->max != NULL && factorsCHull->max->drift != INFINITY)
                {
-                       fprintf(stream,
+                       fprintf(syncState->graphsStream,
                                "\t%.2f + %.10f * x "
                                        "title \"Max conversion\" with lines "
                                        "linecolor rgb \"black\" linetype 8, \\\n",
This page took 0.02776 seconds and 4 git commands to generate.