Perform factor reduction as a modular step
[lttv.git] / lttv / lttv / sync / event_matching_distributor.c
index 4bb7e68cd50dd9158dadd414b4c4b0cd642795a6..5df7cd4116641f7687d73ddf97da7d326e8007e6 100644 (file)
@@ -1,19 +1,18 @@
 /* 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
@@ -52,7 +51,7 @@ static void destroyMatchingDistributor(SyncState* const syncState);
 
 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 writeMatchingTraceTraceForePlotsDistributor(SyncState* const
        syncState, const unsigned int i, const unsigned int j);
@@ -68,8 +67,6 @@ 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);
@@ -103,7 +100,7 @@ static MatchingModule matchingModuleDistributor = {
 /*
  * Matching module registering function
  */
-static void registerMatchingDistributor()
+void registerMatchingDistributor()
 {
        g_queue_push_tail(&matchingModules, &matchingModuleDistributor);
 }
@@ -147,7 +144,7 @@ static void destroyMatchingDistributor(SyncState* const syncState)
 
        g_queue_foreach(matchingData->distributedModules, &gfDestroyModule, NULL);
 
-       g_queue_clear(matchingData->distributedModules);
+       g_queue_free(matchingData->distributedModules);
        free(syncState->matchingData);
        syncState->matchingData= NULL;
 }
@@ -171,35 +168,21 @@ static void matchEventDistributor(SyncState* const syncState, Event* const event
 
 
 /*
- * 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);
 }
 
 
@@ -409,11 +392,10 @@ void gfMatchEvent(gpointer data, gpointer user_data)
  */
 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);
 }
 
 
This page took 0.024158 seconds and 4 git commands to generate.