Perform trace factor reduction as a separate step
[lttv.git] / lttv / lttv / sync / data_structures.h
index 1f70ade4877a82ae782bfe4695d16d7375895683..cc422a81261efe105861e68855bd980aca010aa7 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/>.
  */
 
 #ifndef DATA_STRUCTURES_H
@@ -23,8 +22,6 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-#include <ltt/ltt.h>
-
 
 enum Direction
 {
@@ -88,6 +85,8 @@ typedef struct
 typedef struct _Event
 {
        unsigned long traceNum;
+       // wallTime is corrected according to factors in trace struct, cpuTime
+       // is not
        uint64_t cpuTime;
        WallTime wallTime;
 
@@ -100,6 +99,7 @@ typedef struct _Event
                UDPEvent* udpEvent;
        } event;
 
+       void (*copy)(const struct _Event* const event, struct _Event** const newEvent);
        void (*destroy)(struct _Event* const event);
 } Event;
 
@@ -114,20 +114,75 @@ typedef struct _Message
 typedef struct
 {
        Message* message;
+       // Event* acks[]
        GQueue* acks;
 } Exchange;
 
 typedef struct
 {
+       // Event* events[]
        GQueue* events;
 } Broadcast;
 
-// One set of factors for each trace, this is the result of synchronization
+// Stage 4: These structures contain correction factors
+/* Correction factors for each trace, this is the final result of
+ * synchronization */
 typedef struct
 {
        double drift, offset;
 } Factors;
 
+// Correction factors between trace pairs, to be used for reduction
+typedef enum
+{
+       EXACT,
+       /* Used for identity factors (a0= 0, a1= 1) that map a trace to itself. In
+        * this case, min, max and accuracy are NULL.
+        */
+
+       ACCURATE,
+       /* The approximation is the middle of the min and max limits. All fields
+        * are initialized.
+        */
+
+       APPROXIMATE,
+       /* min and max are not available. The approximation is a "best effort".
+        * min and max are NULL.
+        */
+
+       INCOMPLETE,
+       /* min or max is available but not both. approx and accuracy are not
+        * NULL.
+        */
+
+       ABSENT,
+       /* The pair of trace did not have communications in both directions (maybe
+        * even no communication at all). approx and accuracy are NULL.
+        */
+
+       SCREWED,
+       /* The algorithms are screwed. All fields may be NULL.
+        */
+
+       APPROX_NB, // This must be the last member
+} ApproxType;
+
+extern const char* const approxNames[APPROX_NB];
+
+typedef struct
+{
+       Factors* min, * max, * approx;
+       ApproxType type;
+       double accuracy;
+} PairFactors;
+
+typedef struct
+{
+       unsigned int refCount;
+       unsigned int traceNb;
+       PairFactors** pairFactors;
+} AllFactors;
+
 
 // ConnectionKey-related functions
 guint ghfConnectionKeyHash(gconstpointer key);
@@ -149,11 +204,15 @@ void gdnDestroyDatagramKey(gpointer data);
 
 // Event-related functions
 void gdnDestroyEvent(gpointer data);
+void copyEvent(const Event* const event, Event** const newEvent);
+void copyTCPEvent(const Event* const event, Event** const newEvent);
+void copyUDPEvent(const Event* const event, Event** const newEvent);
 void destroyEvent(Event* const event);
 void destroyTCPEvent(Event* const event);
 void destroyUDPEvent(Event* const event);
 void gfDestroyEvent(gpointer data, gpointer user_data);
 double wallTimeSub(const WallTime const* tA, const WallTime const* tB);
+void gfAddEventToArray(gpointer data, gpointer user_data);
 
 // Message-related functions
 void printTCPSegment(const Message* const segment);
@@ -173,4 +232,10 @@ void destroyTCPExchange(Exchange* const exchange);
 void gdnDestroyBroadcast(gpointer data);
 void destroyBroadcast(Broadcast* const broadcast);
 
+// Factor-related functions
+void destroyPairFactors(PairFactors* factorsCHull);
+
+AllFactors* createAllFactors(const unsigned int traceNb);
+void freeAllFactors(AllFactors* const allFactors);
+
 #endif
This page took 0.024385 seconds and 4 git commands to generate.