/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
+ * Copyright (C) 2009, 2010 Benjamin Poirier <benjamin.poirier@polymtl.ca>
*
- * 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 <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
static void matchEventDistributor(SyncState* const syncState, Event* const
event);
-static GArray* finalizeMatchingDistributor(SyncState* const syncState);
+static AllFactors* finalizeMatchingDistributor(SyncState* const syncState);
static void printMatchingStatsDistributor(SyncState* const syncState);
-static void writeMatchingGraphsPlotsDistributor(SyncState* const syncState,
- const unsigned int i, const unsigned int j);
-static void writeMatchingGraphsOptionsDistributor(SyncState* const syncState,
- const unsigned int i, const unsigned int j);
+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 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);
// Functions specific to this module
-static void registerMatchingDistributor() __attribute__((constructor (101)));
-
void gfInitModule(gpointer data, gpointer user_data);
void gfDestroyModule(gpointer data, gpointer user_data);
void gfMatchEvent(gpointer data, gpointer user_data);
.matchEvent= &matchEventDistributor,
.finalizeMatching= &finalizeMatchingDistributor,
.printMatchingStats= &printMatchingStatsDistributor,
- .writeMatchingGraphsPlots= &writeMatchingGraphsPlotsDistributor,
- .writeMatchingGraphsOptions= &writeMatchingGraphsOptionsDistributor,
+ .graphFunctions= {
+ .writeTraceTraceForePlots=
+ &writeMatchingTraceTraceForePlotsDistributor,
+ .writeTraceTraceBackPlots=
+ &writeMatchingTraceTraceBackPlotsDistributor,
+ .writeTraceTraceOptions= &writeMatchingTraceTraceOptionsDistributor,
+ .writeTraceTimeForePlots= &writeMatchingTraceTimeForePlotsDistributor,
+ .writeTraceTimeBackPlots= &writeMatchingTraceTimeBackPlotsDistributor,
+ .writeTraceTimeOptions= &writeMatchingTraceTimeOptionsDistributor,
+ },
};
/*
* Matching module registering function
*/
-static void registerMatchingDistributor()
+void registerMatchingDistributor()
{
g_queue_push_tail(&matchingModules, &matchingModuleDistributor);
}
g_queue_foreach(matchingData->distributedModules, &gfDestroyModule, NULL);
- g_queue_clear(matchingData->distributedModules);
+ g_queue_free(matchingData->distributedModules);
free(syncState->matchingData);
syncState->matchingData= NULL;
}
/*
- * Call the distributed finalization functions and return identity factors
+ * Call the distributed finalization functions and return absent factors
*
* Args:
* syncState container for synchronization data.
*
* Returns:
- * Factors[traceNb] identity factors for each trace
+ * AllFactors* synchronization factors for each trace pair
*/
-static GArray* finalizeMatchingDistributor(SyncState* const syncState)
+static AllFactors* finalizeMatchingDistributor(SyncState* const syncState)
{
- GArray* factors;
- unsigned int i;
MatchingDataDistributor* matchingData= syncState->matchingData;
g_queue_foreach(matchingData->distributedModules, &gfFinalize, NULL);
- factors= g_array_sized_new(FALSE, FALSE, sizeof(Factors),
- syncState->traceNb);
- g_array_set_size(factors, syncState->traceNb);
- for (i= 0; i < syncState->traceNb; i++)
- {
- Factors* e;
-
- e= &g_array_index(factors, Factors, i);
- e->drift= 1.;
- e->offset= 0.;
- }
-
- return factors;
+ return createAllFactors(syncState->traceNb);
}
* i: first trace number
* j: second trace number, garanteed to be larger than i
*/
-static void writeMatchingGraphsPlotsDistributor(SyncState* const syncState,
+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.writeTraceTimeForePlots), 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 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.writeTraceTimeBackPlots), i, j});
+}
+
+
+/*
+ * Call the distributed graph options 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 writeMatchingTraceTraceOptionsDistributor(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,
- writeMatchingGraphsPlots), i, j});
+ graphFunctions.writeTraceTraceOptions), i, j});
}
* i: first trace number
* j: second trace number, garanteed to be larger than i
*/
-static void writeMatchingGraphsOptionsDistributor(SyncState* const syncState,
+static void writeMatchingTraceTimeOptionsDistributor(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,
- writeMatchingGraphsOptions), i, j});
+ graphFunctions.writeTraceTimeOptions), i, j});
}
*/
void gfFinalize(gpointer data, gpointer user_data)
{
- GArray* factors;
SyncState* parallelSS= data;
- factors= parallelSS->matchingModule->finalizeMatching(parallelSS);
- g_array_free(factors, TRUE);
+ freeAllFactors(parallelSS->matchingModule->finalizeMatching(parallelSS),
+ parallelSS->traceNb);
}
{
SyncState* parallelSS= data;
struct GraphAggregate* aggregate= user_data;
- void (*graphFunction)(struct _SyncState*, const unsigned int, const
- unsigned int)= (void*) data + (size_t) aggregate->offset;
+ typedef void (*GraphFunction)(struct _SyncState*, const unsigned int,
+ const unsigned int);
+ GraphFunction graphFunction= *(GraphFunction*)((void*)
+ parallelSS->matchingModule + (size_t) aggregate->offset);
if (graphFunction != NULL)
{