00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _BIG_LIST_ELEMENT_H_
00009 #define _BIG_LIST_ELEMENT_H_
00010
00011 #include <stl.h>
00012 #include <iostream.h>
00013 #include "legoOp.H"
00014 #include "DagNode.H"
00015 #include "SmallListElement.H"
00016
00017
00018 class BigListElement : public DagNode {
00019
00020 public:
00021
00022 int ClusterId;
00023 double Value;
00024
00025 vector < SmallListElement > *Predecessors, *Successors;
00026
00027 private:
00028
00029
00030
00031
00032 int *AncestorClusterInfo;
00033 int a_array_size;
00034
00035
00036
00037 int *CopiedResultInfo;
00038 int c_array_size;
00039
00040
00041 void BubbleSort( vector < SmallListElement > *,
00042 int (*Compare)( SmallListElement, SmallListElement ) );
00043 void SortList( vector < SmallListElement > *,
00044 int (*Compare)( SmallListElement, SmallListElement ) );
00045
00046 public:
00047
00048
00049 BigListElement();
00050 BigListElement( const BigListElement &src );
00051 ~BigListElement();
00052
00053 #if 1
00054
00055 BigListElement & operator=(const BigListElement &src );
00056 #endif
00057
00058
00059 int operator==(const BigListElement &src )
00060 {
00061 if ( src.Op->GetOpId() == Op->GetOpId() ) return 1;
00062 else return 0;
00063 }
00064
00065
00066 void BigListElement::Allocate_AncestorClusterInfo( int n );
00067
00068
00069 void DeAllocate_AncestorClusterInfo()
00070 {
00071 if ( a_array_size > 0 ) delete [] AncestorClusterInfo;
00072 a_array_size = 0;
00073 }
00074
00075
00076 int Get_a_array_size() { return a_array_size; }
00077
00078
00079 int GetAncestorClusterEntry( int n )
00080 { if ( a_array_size > n ) return AncestorClusterInfo[ n ]; }
00081
00082
00083 void SetAncestorClusterEntry( int entry, int value )
00084 { if ( a_array_size > entry ) AncestorClusterInfo[ entry ] = value; }
00085
00086
00087 void InitAncestorClusterInfo();
00088
00089
00090 void Allocate_CopiedResultInfo( int n );
00091
00092
00093 void Deallocate_CopiedResultInfo()
00094 {
00095 if ( c_array_size > 0 ) delete [] CopiedResultInfo;
00096 c_array_size = 0;
00097 }
00098
00099
00100
00101 void AddCopiedResultInfo( int cluster, int cycle )
00102 { if ( c_array_size > cluster ) CopiedResultInfo[ cluster ] = cycle; }
00103
00104
00105
00106
00107 int CheckCopyStatus( int cluster, int cycle )
00108 {
00109 if ( c_array_size > 0 && CopiedResultInfo[ cluster ] != 0
00110 && CopiedResultInfo[ cluster ] <= cycle )
00111 return 1;
00112 else return 0;
00113 }
00114
00115 void PrintElement();
00116
00117
00118 void PrintElement(ofstream & os1);
00119
00120
00121 int AddPredecessorBeginning( enum edgeTypes Dependency, legoOp *Op,
00122 BigListElement *Iter );
00123
00124
00125 int AddPredecessor( enum edgeTypes Dependency, legoOp *Op,
00126 BigListElement *Iter );
00127
00128
00129 int AddSuccessor( enum edgeTypes Dependency, legoOp *Op,
00130 BigListElement *Iter );
00131
00132
00133 int RemovePredecessor( enum edgeTypes Dependency, legoOp *Op,
00134 BigListElement *Iter );
00135
00136
00137 int RemoveSuccessor( enum edgeTypes Dependency, legoOp *Op,
00138 BigListElement *Iter );
00139
00140
00141 vector < SmallListElement >::iterator
00142 RemovePredecessor( enum edgeTypes Dependency, legoOp *Op );
00143
00144
00145 vector < SmallListElement >::iterator
00146 RemoveSuccessor( enum edgeTypes Dependency, legoOp *Op );
00147
00148
00149
00150 int NumPredecessors() { return Predecessors->size(); }
00151
00152
00153
00154 int NumSuccessors() { return Successors->size(); }
00155
00156
00157
00158 void SortSuccessorsByOpId();
00159 void SortSuccessorsByHeight();
00160 void SortSuccessorsByDepth();
00161 void SortSuccessorsByWeight();
00162 void SortSuccessorsByValue();
00163
00164
00165 void SortPredecessorsByOpId();
00166 void SortPredecessorsByHeight();
00167 void SortPredecessorsByDepth();
00168 void SortPredecessorsByWeight();
00169 void SortPredecessorsByValue();
00170 };
00171
00172
00173
00174 void DestructBigList( list < BigListElement > *List );
00175
00176
00177 void DestructBigVector( vector < BigListElement > *Vector );
00178
00179
00180 int CopyBigVector( vector < BigListElement > *Src,
00181 vector < BigListElement > *Target );
00182
00183
00184
00185 int FindOpInList( vector < BigListElement > *V, int OpId );
00186
00187
00188
00189 vector < BigListElement >::iterator
00190 FindNode( int OpId, vector < BigListElement > *V );
00191
00192 #if 0
00193 #if defined (_STL_LIST_USED_)
00194 typedef list <BigListElement> MainList;
00195 #else if defined (_STL_VECTOR_USED_)
00196 typedef vector <BigListElement> MainList;
00197 #endif
00198 #endif
00199
00200 typedef vector <BigListElement> VectorList;
00201 typedef list <BigListElement> ListList;
00202
00203 #if defined (_STL_LIST_USED_)
00204 typedef ListList MainList;
00205 #else if defined (_STL_VECTOR_USED_)
00206 typedef VectorList MainList;
00207 #endif
00208
00209 #endif