X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttv%2Flttv%2Fsync%2Fevent_analysis_eval.c;h=0872eb6dd8aa7c7762e7606e87963009320de1eb;hb=277e5b535febfb81a5e9485b0d008e148b6979ac;hp=3c1b110aeeee1e7f766cd7805952b60694c90566;hpb=c55718515f6dddfd3584160b16c4a59f377782da;p=lttv.git diff --git a/lttv/lttv/sync/event_analysis_eval.c b/lttv/lttv/sync/event_analysis_eval.c index 3c1b110a..0872eb6d 100644 --- a/lttv/lttv/sync/event_analysis_eval.c +++ b/lttv/lttv/sync/event_analysis_eval.c @@ -1,19 +1,18 @@ /* This file is part of the Linux Trace Toolkit viewer - * Copyright (C) 2009 Benjamin Poirier + * Copyright (C) 2009, 2010 Benjamin Poirier * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License Version 2 as - * published by the Free Software Foundation; + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or (at + * your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . */ #define _GNU_SOURCE @@ -78,7 +77,6 @@ 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))); static guint ghfRttKeyHash(gconstpointer key); static gboolean gefRttKeyEqual(gconstpointer a, gconstpointer b); static void gdnDestroyRttKey(gpointer data); @@ -111,6 +109,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 +120,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 +146,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", }; @@ -159,7 +154,7 @@ static ModuleOption optionEvalRttFile= { /* * Analysis module registering function */ -static void registerAnalysisEval() +void registerAnalysisEval() { binBase= exp10(6. / (BIN_NB - 3)); @@ -309,7 +304,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 +527,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 +577,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]); @@ -625,8 +622,7 @@ static void analyzeMessageEval(SyncState* const syncState, Message* const message) { AnalysisDataEval* analysisData= syncState->analysisData; - MessageStats* messageStats= - &analysisData->stats->messageStats[message->outE->traceNum][message->inE->traceNum]; + MessageStats* messageStats; double* rtt; double tt; struct RttKey rttKey; @@ -635,6 +631,8 @@ static void analyzeMessageEval(SyncState* const syncState, Message* const if (syncState->stats) { + messageStats= + &analysisData->stats->messageStats[message->outE->traceNum][message->inE->traceNum]; messageStats->total++; } @@ -985,6 +983,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" @@ -1021,6 +1020,7 @@ static void printAnalysisStatsEval(SyncState* const syncState) } } } +#endif } @@ -1536,7 +1536,10 @@ static glp_prob* lpCreateProblem(GQueue* const lowerHull, GQueue* const // Create the LP problem glp_term_out(GLP_OFF); - glp_add_rows(lp, hullPointNb); + if (hullPointNb > 0) + { + glp_add_rows(lp, hullPointNb); + } glp_add_cols(lp, 2); glp_set_col_name(lp, 1, "a0"); @@ -1724,37 +1727,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= @@ -1794,15 +1796,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 /* @@ -1845,7 +1846,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) {