00001 #ifndef _CKOBJID_H_ 00002 #define _CKOBJID_H_ 00003 00004 union _ObjectID { 00005 struct { 00006 CkChareID id; 00007 } chare; 00008 struct { 00009 CkGroupID id; 00010 int onPE; 00011 } group; //also used for NodeGroups 00012 struct s_array{ 00013 CkGroupID id; //array id 00014 CkArrayIndexBase idx; //index 00015 } array; 00016 }; 00017 00018 extern int totalCompares; 00019 00020 class CkObjID { 00021 public: 00022 ChareType type; 00023 _ObjectID data; 00024 CkObjID(){ 00025 type = TypeInvalid; 00026 }; 00027 00028 inline operator CkHashCode()const{ 00029 CkHashCode ret=circleShift(type,25); 00030 switch(type){ 00031 case TypeInvalid: 00032 break; 00033 case TypeChare: 00034 case TypeMainChare: 00035 ret += circleShift(data.chare.id.onPE,5); 00036 ret += circleShift((CmiInt8)data.chare.id.objPtr,3); 00037 break; 00038 case TypeGroup: 00039 case TypeNodeGroup: 00040 ret += circleShift(data.group.onPE,4); 00041 ret += circleShift(data.group.id.idx,6); 00042 break; 00043 case TypeArray: 00044 CkHashCode temp = data.array.idx.asChild().hash(); 00045 //ret = circleShift(ret,13); 00046 //ret += circleShift(temp,11); 00047 ret += temp; 00048 break; 00049 } 00050 return ret; 00051 } 00052 00053 inline bool operator == (const CkObjID &t) const{ 00054 00055 if(type != t.type){ 00056 return false; 00057 } 00058 switch (type){ 00059 case TypeInvalid: 00060 break; 00061 case TypeMainChare: 00062 case TypeChare: 00063 if((data.chare.id.onPE == t.data.chare.id.onPE) && (data.chare.id.objPtr == t.data.chare.id.objPtr)){ 00064 return true; 00065 }else{ 00066 return false; 00067 } 00068 //break; unreachable 00069 case TypeGroup: 00070 case TypeNodeGroup: 00071 if((data.group.onPE == t.data.group.onPE) && (data.group.id == t.data.group.id)){ 00072 return true; 00073 }else{ 00074 return false; 00075 } 00076 //break; unreachable 00077 case TypeArray: 00078 bool val; 00079 if(data.array.id == t.data.array.id && data.array.idx.asChild().compare(t.data.array.idx.asChild())){ 00080 val = true; 00081 }else{ 00082 val = false; 00083 } 00084 return val; 00085 // break; unreachable 00086 } 00087 return false; 00088 } 00089 00090 void* getObject(); 00091 00092 int guessPE(); 00093 00094 char *toString(char *buf) const; 00095 00096 inline void updatePosition(int PE); 00097 }; 00098 00099 PUPbytes(CkObjID) 00100 00101 typedef unsigned int MCount; //Message Count 00102 00103 #endif