Fixes for building without libglpk
[lttv.git] / lttv / lttv / sync / event_analysis_eval.c
index 88d732bb4bbace6ec012a687a3f3faf49776db7b..0c0b7b51a80e86fc3cb48cbf104e9bb14aca369c 100644 (file)
@@ -111,6 +111,7 @@ static void writeHistogram(FILE* graphsStream, const struct RttKey* rttKey,
 static void updateBounds(Bounds** const bounds, Event* const e1, Event* const
        e2);
 
+static void finalizeAnalysisEvalLP(SyncState* const syncState);
 // The next group of functions is only needed when computing synchronization
 // accuracy.
 #ifdef HAVE_LIBGLPK
@@ -121,9 +122,6 @@ static Factors* calculateFactors(glp_prob* const lp, const int direction);
 static void calculateCompleteFactors(glp_prob* const lp, FactorsCHull*
        factors);
 static FactorsCHull** createAllFactors(const unsigned int traceNb);
-static inline void finalizeAnalysisEvalLP(SyncState* const syncState);
-#else
-static void finalizeAnalysisEvalLP(SyncState* const syncState);
 #endif
 
 
@@ -150,7 +148,6 @@ static AnalysisModule analysisModuleEval= {
 static ModuleOption optionEvalRttFile= {
        .longName= "eval-rtt-file",
        .hasArg= REQUIRED_ARG,
-       {.arg= NULL},
        .optionHelp= "specify the file containing RTT information",
        .argHelp= "FILE",
 };
@@ -309,7 +306,7 @@ static AnalysisHistogramEval* constructAnalysisHistogramEval(const char* const
        convertIP(saddr, rttKey->saddr);
        convertIP(daddr, rttKey->daddr);
 
-       cwd= changeToGraphDir(graphsDir);
+       cwd= changeToGraphsDir(graphsDir);
 
        for (i= 0; i < sizeof(loopValues) / sizeof(*loopValues); i++)
        {
@@ -532,7 +529,7 @@ static void writeHistogram(FILE* graphsStream, const struct RttKey* rttKey,
  */
 static void destroyAnalysisEval(SyncState* const syncState)
 {
-       unsigned int i, j;
+       unsigned int i;
        AnalysisDataEval* analysisData;
 
        analysisData= (AnalysisDataEval*) syncState->analysisData;
@@ -582,10 +579,12 @@ static void destroyAnalysisEval(SyncState* const syncState)
 #ifdef HAVE_LIBGLPK
                for (i= 0; i < syncState->traceNb; i++)
                {
+                       unsigned int j;
+
                        for (j= 0; j < i; j++)
                        {
                                // There seems to be a memory leak in glpk, valgrind reports a
-                               // loss even if the problem is deleted
+                               // loss (reachable) even if the problem is deleted
                                glp_delete_prob(graphs->lps[i][j]);
                        }
                        free(graphs->lps[i]);
@@ -986,6 +985,7 @@ static void printAnalysisStatsEval(SyncState* const syncState)
        g_hash_table_foreach(analysisData->stats->exchangeRtt,
                &ghfPrintExchangeRtt, analysisData->rttInfo);
 
+#ifdef HAVE_LIBGLPK
        printf("\tConvex hull factors comparisons:\n"
                "\t\tTrace pair  Factors type  Differences (lp - chull)\n"
                "\t\t                          a0                    a1\n"
@@ -1022,6 +1022,7 @@ static void printAnalysisStatsEval(SyncState* const syncState)
                        }
                }
        }
+#endif
 }
 
 
@@ -1725,37 +1726,36 @@ static FactorsCHull** createAllFactors(const unsigned int traceNb)
  * Compute synchronization factors using a linear programming approach.
  * Compute the factors using analysis_chull. Compare the two.
  *
- * There are two definitions of this function. The empty one is used when the
- * solver library, glpk, is not available at build time. In that case, nothing
- * is actually produced.
+ * When the solver library, glpk, is not available at build time, only compute
+ * the factors using analysis_chull. This is to make sure that module runs its
+ * finalize function so that its graph functions can be called later.
  *
  * Args:
  *   syncState:    container for synchronization data
  */
-#ifndef HAVE_LIBGLPK
-static inline void finalizeAnalysisEvalLP(SyncState* const syncState)
-{
-}
-#else
 static void finalizeAnalysisEvalLP(SyncState* const syncState)
 {
-       unsigned int i, j;
        AnalysisDataEval* analysisData= syncState->analysisData;
+#ifdef HAVE_LIBGLPK
+       unsigned int i, j;
        AnalysisDataCHull* chAnalysisData= analysisData->chullSS->analysisData;
-       FactorsCHull** lpFactorsArray= createAllFactors(syncState->traceNb);
-       FactorsCHull* lpFactors;
+       FactorsCHull** lpFactorsArray;
 
        if (!syncState->stats && !syncState->graphsStream)
        {
                return;
        }
 
+       /* Because of matching_distributor, this analysis may be called twice.
+        * Only run it once */
        if ((syncState->graphsStream && analysisData->graphs->lps != NULL) ||
                (syncState->stats && analysisData->stats->chFactorsArray != NULL))
        {
                return;
        }
 
+       lpFactorsArray= createAllFactors(syncState->traceNb);
+
        if (syncState->stats)
        {
                analysisData->stats->chFactorsArray=
@@ -1795,15 +1795,14 @@ static void finalizeAnalysisEvalLP(SyncState* const syncState)
                        else
                        {
                                glp_delete_prob(lp);
-                               destroyFactorsCHull(lpFactors);
                        }
                }
        }
+#endif
 
        g_array_free(analysisData->chullSS->analysisModule->finalizeAnalysis(analysisData->chullSS),
                TRUE);
 }
-#endif
 
 
 /*
@@ -1846,7 +1845,7 @@ static void writeAnalysisTraceTimeBackPlotsEval(SyncState* const syncState,
                snprintf(fileName, 40, "analysis_eval_accuracy-%03u_and_%03u.data", i, j);
                fileName[sizeof(fileName) - 1]= '\0';
 
-               cwd= changeToGraphDir(syncState->graphsDir);
+               cwd= changeToGraphsDir(syncState->graphsDir);
 
                if ((fp= fopen(fileName, "w")) == NULL)
                {
This page took 0.024776 seconds and 4 git commands to generate.