00001 #ifndef __TERMINATE_H 00002 #define __TERMINATE_H 00003 00004 #include "../structs.h" 00005 00006 #define NOTPARTICIPATING 0 ///< used to TerminationDetection->status 00007 #define PARTICIPATING 1 ///< used to TerminationDetection->status 00008 #define EMPTY 0 ///< used to TerminationDetection->stream 00009 #define FULL 1 ///< used to TerminationDetection->stream 00010 #define NOTTERMINATED 0 ///< used to TerminationDetection->nd->neighborTerm and GlobalTermination->tfid->terminate 00011 #define TERMINATED 1 ///< used to TerminationDetection->nd->neighborTerm and GlobalTermination->tfid->terminate 00012 00013 /**** Filters structs ****/ 00014 00015 typedef struct _NeighborsData_ { 00016 int neighborStreamId; ///< id to address stream. 0 --> numStreams 00017 int neighborTid; ///< neighbor pvm tid 00018 int neighborPortTag; ///< port tag 00019 int neighborTerm; ///< indicates if I have already received a termination mesg of neighbor i 00020 } NeighborData; 00021 00022 typedef struct _TerminationDetection_ { 00023 int localTag; ///< # of termination detection round 00024 int status; ///< indicates if I am participating of a termination detection 00025 int numNeighbors; ///< my number of neighbors 00026 NeighborData *nd; 00027 int numStreams; ///< Number of streams connected to me (input + output) 00028 int *stream; ///< indicates if the stream i is empty 00029 } TerminationDetection; 00030 00031 /*************************/ 00032 00033 /**** Leader structs ****/ 00034 00035 typedef struct _TerminationFilterInstancesData_ { 00036 int filterInstanceTid; ///< filter instance pvm tid 00037 int terminate; ///< indicates if filter instance i terminated 00038 int breakLoop; ///< when leader detect termination, send EOW to filter instances witch breakLoop == 1 00039 int tagBreakLoop; 00040 } TerminationFilterInstancesData; 00041 00042 typedef struct _GlobalTermination_ { 00043 int currentRoundTag; ///< current termination detection round tag 00044 int numFilterInstances; ///< number of filter instances participating of termination detection 00045 TerminationFilterInstancesData *tfid; ///< 0 --> numFilterInstances 00046 } GlobalTermination; 00047 00048 /************************/ 00049 00050 00051 #ifdef TERMINATE_C 00052 TerminationDetection *tdd; ///< Global variable that points to data of termination detection 00053 #else 00054 extern TerminationDetection *tdd; ///< Global variable that points to data of termination detection 00055 #endif 00056 00057 #ifdef TERMINATE_C 00058 GlobalTermination *gt; ///< Global variable that points to data of global termination 00059 #else 00060 extern GlobalTermination *gt; ///< Global variable that points to data of global termination 00061 #endif 00062 00063 /**** Leader functions ****/ 00064 GlobalTermination *initGlobalTermination(Layout *layout, int numFilterInstances); 00065 int verifyGlobalTermination(int filterInstTid, int filterInstTag); 00066 00067 /**** Filter functions ****/ 00068 TerminationDetection *initTerminationDetection(); 00069 int beginTerminationDetection(); 00070 int terminationDetectionRound(int neighborTid, int neighborTag); 00071 int updateTermStreamToEmpty(int neighborTid); 00072 00073 #endif
1.4.6