Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

BigListElement.H

Go to the documentation of this file.
00001 // BigListElement.H
00002 //
00003 // 2/11/98 WAH:  Broke away from Scheduler package; minor patching up.
00004 // 3/23/98 WAH:  Added RemovePredecessor and RemoveSuccessor methods.
00005 // 4/1/98 WAH:   Turned on assignment operator; added resetting of
00006 //               array_size fields in Deallocate methods.
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 /* This defines an element in the 'master list'. */
00018 class BigListElement : public DagNode {
00019 
00020 public:
00021 
00022    int ClusterId;               // Used for cluster scheduling
00023    double Value;                // Used for node-ordering
00024 
00025    vector < SmallListElement > *Predecessors, *Successors;
00026 
00027 private:
00028 
00029    // Holds weight info for objects related to this object in the dag.
00030    // There is a weight for every cluster in the dag. The higher the
00031    // weight, the strong the 'affinity' for this object to that cluster.
00032    int *AncestorClusterInfo;
00033    int a_array_size;
00034 
00035    // Holds info telling if object OR data produced by the object has
00036    // been copied into other clusters in the machine
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    // Constructor, copy constructor, and destructor
00049    BigListElement();
00050    BigListElement( const BigListElement &src );
00051    ~BigListElement();
00052 
00053 #if 1
00054    // Equality operator
00055    BigListElement & operator=(const BigListElement &src );
00056 #endif
00057 
00058    // Equality test operator
00059    int operator==(const BigListElement &src )
00060    {
00061       if ( src.Op->GetOpId() == Op->GetOpId() ) return 1;
00062       else return 0;
00063    }
00064 
00065    // Allocate_AncestorClusterInfo - allocate an array of size n (> 0)
00066    void BigListElement::Allocate_AncestorClusterInfo( int n );
00067 
00068    // DeAllocate_AncestorClusterInfo - deallocate the array
00069    void DeAllocate_AncestorClusterInfo()
00070    {
00071      if ( a_array_size > 0 ) delete [] AncestorClusterInfo;
00072      a_array_size = 0;
00073    }
00074 
00075    // Get_a_array_size: returns the value of a_array_size
00076    int Get_a_array_size()                       { return a_array_size; }
00077 
00078    // GetAncestorClusterEntry - return entry [n] in AncestorClusterInfo
00079    int GetAncestorClusterEntry( int n )
00080    { if ( a_array_size > n ) return AncestorClusterInfo[ n ]; }
00081 
00082    // SetAncestorClusterEntry - entry [n] in AncestorClusterInfo to value
00083    void SetAncestorClusterEntry( int entry, int value )
00084    { if ( a_array_size > entry ) AncestorClusterInfo[ entry ] = value; }
00085 
00086    // InitAncestorClusterInfo - sets all entries to -1
00087    void InitAncestorClusterInfo();
00088 
00089    // Allocate_CopiedResultInfo
00090    void Allocate_CopiedResultInfo( int n );
00091 
00092    // Deallocate_CopiedResultInfo
00093    void Deallocate_CopiedResultInfo()
00094    {
00095      if ( c_array_size > 0 ) delete [] CopiedResultInfo;
00096      c_array_size = 0;
00097    }
00098 
00099    // AddCopiedResultInfo - notates that the *result* of this Op was scheduled
00100    //    to be copied to cluster in cycle
00101    void AddCopiedResultInfo( int cluster, int cycle )
00102    { if ( c_array_size > cluster ) CopiedResultInfo[ cluster ] = cycle; }
00103 
00104    // CheckCopyStatus - checks if this object copies its result data to
00105    //    cluster and if the data is present there by cycle. Returns 1 if
00106    //    yes, 0 otherwise.
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    //HZ: 8/24/00 print to a stream
00118    void PrintElement(ofstream & os1);
00119 
00120    /* Add an Op as a data predecessor with an edge of type Dependency */
00121    int AddPredecessorBeginning( enum edgeTypes Dependency, legoOp *Op,
00122                        BigListElement *Iter );
00123 
00124    /* Add an Op as a data predecessor with an edge of type Dependency */
00125    int AddPredecessor( enum edgeTypes Dependency, legoOp *Op,
00126                        BigListElement *Iter );
00127 
00128    /* Add an Op as a data successor with an edge of type Dependency */
00129    int AddSuccessor( enum edgeTypes Dependency, legoOp *Op,
00130                      BigListElement *Iter );
00131 
00132    /* Remove an Op as a data predecessor with an edge of type Dependency */
00133    int RemovePredecessor( enum edgeTypes Dependency, legoOp *Op,
00134                           BigListElement *Iter );
00135 
00136    /* Remove an Op as a data successor with an edge of type Dependency */
00137    int RemoveSuccessor( enum edgeTypes Dependency, legoOp *Op,
00138                         BigListElement *Iter );
00139 
00140    /* Remove an Op as a data predecessor with an edge of type Dependency */
00141    vector < SmallListElement >::iterator 
00142    RemovePredecessor( enum edgeTypes Dependency, legoOp *Op );
00143 
00144    /* Remove an Op as a data successor with an edge of type Dependency */
00145    vector < SmallListElement >::iterator  
00146    RemoveSuccessor( enum edgeTypes Dependency, legoOp *Op );
00147 
00148    /* Returns size of predecessor list. A size of 0 indicates an entry node
00149       in a region. */
00150    int NumPredecessors()        { return Predecessors->size();  }
00151 
00152    /* Returns size of successor list. A size of 0 indicates an exit  node
00153       in a region. */
00154    int NumSuccessors()          { return Successors->size();    }
00155 
00156 
00157    /* Sort Successor Ops in a variety of ways. */
00158    void     SortSuccessorsByOpId();
00159    void     SortSuccessorsByHeight();
00160    void     SortSuccessorsByDepth();
00161    void     SortSuccessorsByWeight();
00162    void     SortSuccessorsByValue();
00163 
00164    /* Sort Predecessor Ops in a variety of ways. */
00165    void     SortPredecessorsByOpId();
00166    void     SortPredecessorsByHeight();
00167    void     SortPredecessorsByDepth();
00168    void     SortPredecessorsByWeight();
00169    void     SortPredecessorsByValue();
00170 };
00171 
00172 
00173 // DestructBigList:  destructs a list of of BigListElements
00174 void DestructBigList( list < BigListElement > *List );
00175 
00176 // DestructBigVector:  destructs a vector of of BigListElements
00177 void DestructBigVector( vector < BigListElement > *Vector );
00178       
00179 // CopyBigVector: copies data from Src to Target
00180 int CopyBigVector( vector < BigListElement > *Src,
00181                    vector < BigListElement > *Target );
00182 
00183 // FindOpInBigList: find Op w/'OpId' in the vector V, returns the index
00184 //    where Op is located OR -1 if Op isn't found
00185 int FindOpInList( vector < BigListElement > *V, int OpId );
00186 
00187 // FindNode: find Op w/'OpId' in the vector V, returns an iterator to
00188 //    the element. Returns V->end() if OPid isn't found.
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

Generated on Mon Jul 21 20:24:01 2003 for TINKER LEGO DOC by doxygen 1.3.2