00001
00010 #ifndef COMLIB_SECTION_INFO
00011 #define COMLIB_SECTION_INFO
00012
00013
00014
00015
00016
00020 class ComlibSectionHashKey{
00021 public:
00022 int srcPe;
00023 int id;
00024 ComlibSectionHashKey(int _pe, int _id):srcPe(_pe), id(_id){};
00025
00026
00027
00028 CkHashCode hash(void) const;
00029 static CkHashCode staticHash(const void *a,size_t);
00030 int compare(const ComlibSectionHashKey &ind) const;
00031 static int staticCompare(const void *a,const void *b,size_t);
00032 };
00033
00034
00035 inline CkHashCode ComlibSectionHashKey::hash(void) const
00036 {
00037 register int _id = id;
00038 register int _pe = srcPe;
00039
00040 register CkHashCode ret = (_id << 16) + _pe;
00041 return ret;
00042 }
00043
00044 inline int ComlibSectionHashKey::compare(const ComlibSectionHashKey &k2) const
00045 {
00046 if(id == k2.id && srcPe == k2.srcPe)
00047 return 1;
00048
00049 return 0;
00050 }
00051
00053 inline int intCompare(const void *a, const void *b){
00054 int a1 = *(int *) a;
00055 int b1 = *(int *) b;
00056
00057 if(a1 < b1)
00058 return -1;
00059
00060 if(a1 == b1)
00061 return 0;
00062
00063 if(a1 > b1)
00064 return 1;
00065
00066 return 0;
00067 }
00068
00069
00070 inline int ComlibSectionHashKey::staticCompare(const void *k1, const void *k2,
00071 size_t ){
00072 return ((const ComlibSectionHashKey *)k1)->
00073 compare(*(const ComlibSectionHashKey *)k2);
00074 }
00075
00076 inline CkHashCode ComlibSectionHashKey::staticHash(const void *v,size_t){
00077 return ((const ComlibSectionHashKey *)v)->hash();
00078 }
00079
00080
00081
00082
00085 class ComlibSectionHashObject {
00086 public:
00087
00088 CkVec<CkArrayIndex> indices;
00089
00090
00091 int npes;
00092 int *pelist;
00093
00094 void *msg;
00095
00096
00097 int isOld;
00098
00099 ComlibSectionHashObject(): indices(0), isOld(0) {
00100 npes = 0;
00101 pelist = NULL;
00102 msg = NULL;
00103 }
00104
00105 ~ComlibSectionHashObject() {
00106 delete [] pelist;
00107
00108 }
00109 };
00110
00111
00120 class ComlibSectionInfo {
00121
00125 int MaxSectionID;
00126
00127 public:
00128
00129 ComlibSectionInfo() {
00130 MaxSectionID = 1;
00131 }
00132
00134 inline void initSectionID(CkSectionID *sid) {
00135 if (MaxSectionID > 65000) {
00136 CkAbort("Too many sections allocated, wrapping of ints should be done!\n");
00137 }
00138 ComlibPrintf("[%d] ComlibSectionInfo::initSectionID: creating section number %d for proc %d\n",
00139 CkMyPe(), MaxSectionID, sid->_cookie.get_pe());
00140 sid->_cookie.info.sInfo.cInfo.id = MaxSectionID ++;
00141 sid->_cookie.get_pe() = CkMyPe();
00142 }
00143
00144 void processOldSectionMessage(CharmMessageHolder *cmsg);
00145
00152 CkMcastBaseMsg *getNewDeliveryErrorMsg(CkMcastBaseMsg *base);
00153
00161 ComlibMulticastMsg *getNewMulticastMessage(CharmMessageHolder *cmsg, int needSort, int instanceID);
00162
00172 void unpack(envelope *cb_env, int &nLocalElems, CkArrayIndex *&destIndices,
00173 envelope *&env);
00174
00175 void localMulticast(envelope *env);
00176
00190 void getPeCount(int nindices, CkArrayIndex *idxlist, const CkArrayID &destArrayID,
00191 int &npes, int &nidx,
00192 ComlibMulticastIndexCount *&counts, int *&belongs);
00193
00194 void getPeList(envelope *cb_env, int npes, int *&pelist);
00195
00206 void getRemotePelist(int nindices, CkArrayIndex *idxlist, CkArrayID &destArrayID,
00207 int &npes, int *&pelist);
00208
00211 void getPeList(int nindices, CkArrayIndex *idxlist, CkArrayID &destArrayID,
00212 int &npes, int *&pelist);
00213
00214 void getLocalIndices(int nindices, CkArrayIndex *idxlist, CkArrayID &destArrayID,
00215 CkVec<CkArrayIndex> &idx_vec);
00216
00217 void getNodeLocalIndices(int nindices, CkArrayIndex *idxlist, CkArrayID &destArrayID,
00218 CkVec<CkArrayIndex> &idx_vec);
00219
00220 void pup(PUP::er &p) {
00221 p | MaxSectionID;
00222 }
00223 };
00224
00225 #endif