X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttv%2Flttv%2Fsync%2Fevent_matching_tcp.c;h=90d6c43cb3c6901bdaf9e69a1c9434496393e0a3;hb=eb8e0e6fa27e4cfe25138d8275ee6f686ee2b32d;hp=25e39858fb8b36c76c19c11bcd0efe5d64a5ba09;hpb=10341d26543c63ff318a4cf5cb163bccdc58b19d;p=lttv.git diff --git a/lttv/lttv/sync/event_matching_tcp.c b/lttv/lttv/sync/event_matching_tcp.c index 25e39858..90d6c43c 100644 --- a/lttv/lttv/sync/event_matching_tcp.c +++ b/lttv/lttv/sync/event_matching_tcp.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 . */ #ifdef HAVE_CONFIG_H @@ -21,36 +20,28 @@ #endif #include +#include #include #include #include #include "event_analysis.h" -#include "sync_chain_lttv.h" +#include "sync_chain.h" #include "event_matching_tcp.h" -#ifndef g_info -#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) -#endif - - // Functions common to all matching modules static void initMatchingTCP(SyncState* const syncState); static void destroyMatchingTCP(SyncState* const syncState); static void matchEventTCP(SyncState* const syncState, Event* const event); -static GArray* finalizeMatchingTCP(SyncState* const syncState); +static AllFactors* finalizeMatchingTCP(SyncState* const syncState); static void printMatchingStatsTCP(SyncState* const syncState); -static void writeMatchingGraphsPlotsTCP(FILE* stream, SyncState* const - syncState, const unsigned int i, const unsigned int j); -static void writeMatchingGraphsOptionsTCP(FILE* stream, SyncState* const - syncState, const unsigned int i, const unsigned int j); +static void writeMatchingGraphsPlotsTCPMessages(SyncState* const syncState, + const unsigned int i, const unsigned int j); // Functions specific to this module -static void registerMatchingTCP() __attribute__((constructor (101))); - static void matchEvents(SyncState* const syncState, Event* const event, GHashTable* const unMatchedList, GHashTable* const unMatchedOppositeList, const size_t fieldOffset, const size_t @@ -69,20 +60,23 @@ static void writeMessagePoint(FILE* stream, const Message* const message); static MatchingModule matchingModuleTCP = { .name= "TCP", + .canMatch[TCP]= true, + .canMatch[UDP]= false, .initMatching= &initMatchingTCP, .destroyMatching= &destroyMatchingTCP, .matchEvent= &matchEventTCP, .finalizeMatching= &finalizeMatchingTCP, .printMatchingStats= &printMatchingStatsTCP, - .writeMatchingGraphsPlots= &writeMatchingGraphsPlotsTCP, - .writeMatchingGraphsOptions= &writeMatchingGraphsOptionsTCP, + .graphFunctions= { + .writeTraceTraceForePlots= &writeMatchingGraphsPlotsTCPMessages, + } }; /* * Matching module registering function */ -static void registerMatchingTCP() +void registerMatchingTCP() { g_queue_push_tail(&matchingModules, &matchingModuleTCP); } @@ -137,7 +131,7 @@ static void initMatchingTCP(SyncState* const syncState) matchingData->stats= NULL; } - if (syncState->graphs) + if (syncState->graphsStream) { openGraphDataFiles(syncState); } @@ -217,7 +211,7 @@ static void partialDestroyMatchingTCP(SyncState* const syncState) g_hash_table_destroy(matchingData->unMatchedOutE); g_hash_table_destroy(matchingData->unAcked); - if (syncState->graphs && matchingData->messagePoints) + if (syncState->graphsStream && matchingData->messagePoints) { closeGraphDataFiles(syncState); } @@ -231,12 +225,13 @@ static void partialDestroyMatchingTCP(SyncState* const syncState) * Args: * syncState container for synchronization data. * event new event to match - * eventType type of event to match */ static void matchEventTCP(SyncState* const syncState, Event* const event) { MatchingDataTCP* matchingData; + g_assert(event->type == TCP); + matchingData= (MatchingDataTCP*) syncState->matchingData; if (event->event.tcpEvent->direction == IN) @@ -255,15 +250,15 @@ static void matchEventTCP(SyncState* const syncState, Event* const event) /* - * Call the partial matching destroyer and Obtain the factors from downstream + * Call the partial matching destroyer and obtain the factors from downstream * * Args: * syncState container for synchronization data. * * Returns: - * Factors[traceNb] synchronization factors for each trace + * AllFactors* synchronization factors for each trace pair */ -static GArray* finalizeMatchingTCP(SyncState* const syncState) +static AllFactors* finalizeMatchingTCP(SyncState* const syncState) { partialDestroyMatchingTCP(syncState); @@ -272,8 +267,8 @@ static GArray* finalizeMatchingTCP(SyncState* const syncState) /* - * Print statistics related to matching and downstream modules. Must be - * called after finalizeMatching. + * Print statistics related to matching. Must be called after + * finalizeMatching. * * Args: * syncState container for synchronization data. @@ -315,11 +310,6 @@ static void printMatchingStatsTCP(SyncState* const syncState) printf("\ttotal synchronization exchanges: %u\n", matchingData->stats->totExchangeSync); } - - if (syncState->analysisModule->printAnalysisStats != NULL) - { - syncState->analysisModule->printAnalysisStats(syncState); - } } @@ -376,7 +366,7 @@ static void matchEvents(SyncState* const syncState, Event* const event, return; } - if (syncState->graphs) + if (syncState->graphsStream) { writeMessagePoint(matchingData->messagePoints[packet->inE->traceNum][packet->outE->traceNum], packet); @@ -594,7 +584,7 @@ static void openGraphDataFiles(SyncState* const syncState) matchingData= (MatchingDataTCP*) syncState->matchingData; - cwd= changeToGraphDir(syncState->graphs); + cwd= changeToGraphsDir(syncState->graphsDir); matchingData->messagePoints= malloc(syncState->traceNb * sizeof(FILE**)); for (i= 0; i < syncState->traceNb; i++) @@ -634,26 +624,26 @@ static void openGraphDataFiles(SyncState* const syncState) * * Args: * stream: FILE*, file pointer where to write the point - * message: message for which to write the point + * message: message for which to write the point */ static void writeMessagePoint(FILE* stream, const Message* const message) { - LttCycleCount x, y; + uint64_t x, y; if (message->inE->traceNum < message->outE->traceNum) { // CA is inE->traceNum - x= message->inE->time; - y= message->outE->time; + x= message->inE->cpuTime; + y= message->outE->cpuTime; } else { // CA is outE->traceNum - x= message->outE->time; - y= message->inE->time; + x= message->outE->cpuTime; + y= message->inE->cpuTime; } - fprintf(stream, "%20llu %20llu\n", x, y); + fprintf(stream, "%20" PRIu64 " %20" PRIu64 "\n", x, y); } @@ -699,50 +689,21 @@ static void closeGraphDataFiles(SyncState* const syncState) /* - * Write the matching-specific graph lines in the gnuplot script. Call the - * downstream module's graph function. + * Write the matching-specific graph lines in the gnuplot script. * * Args: - * stream: stream where to write the data * syncState: container for synchronization data * i: first trace number * j: second trace number, garanteed to be larger than i */ -static void writeMatchingGraphsPlotsTCP(FILE* stream, SyncState* const - syncState, const unsigned int i, const unsigned int j) +static void writeMatchingGraphsPlotsTCPMessages(SyncState* const syncState, + const unsigned int i, const unsigned int j) { - fprintf(stream, + fprintf(syncState->graphsStream, "\t\"matching_tcp-%1$03d_to_%2$03d.data\" " "title \"Sent messages\" with points linetype 4 " "linecolor rgb \"#98fc66\" pointtype 9 pointsize 2, \\\n" "\t\"matching_tcp-%2$03d_to_%1$03d.data\" " "title \"Received messages\" with points linetype 4 " "linecolor rgb \"#6699cc\" pointtype 11 pointsize 2, \\\n", i, j); - - if (syncState->analysisModule->writeAnalysisGraphsPlots != NULL) - { - syncState->analysisModule->writeAnalysisGraphsPlots(stream, syncState, - i, j); - } -} - - -/* - * Write the matching-specific options in the gnuplot script (none). Call the - * downstream module's options function. - * - * Args: - * stream: stream where to write the data - * syncState: container for synchronization data - * i: first trace number - * j: second trace number, garanteed to be larger than i - */ -static void writeMatchingGraphsOptionsTCP(FILE* stream, SyncState* const - syncState, const unsigned int i, const unsigned int j) -{ - if (syncState->analysisModule->writeAnalysisGraphsOptions != NULL) - { - syncState->analysisModule->writeAnalysisGraphsOptions(stream, - syncState, i, j); - } }