00001
00015 #ifndef _CKMULTICAST_H
00016 #define _CKMULTICAST_H
00017
00018 #define MulticastMsg 1
00019 #define COMLIB_MULTICAST_MESSAGE 2
00020
00021
00022 #define COMLIB_MULTICAST_OLD_SECTION 1
00023 #define COMLIB_MULTICAST_NEW_SECTION 2
00024 #define COMLIB_MULTICAST_SECTION_ERROR 3
00025
00028 typedef struct _CkSectionInfoStruct {
00030 CkGroupID aid;
00031
00032 int pe;
00034 union section_type {
00035
00036 struct sec_mcast {
00038 int redNo;
00039
00040 void *val;
00041 }
00042 sCookie;
00043
00044
00045 struct commlibInfo{
00046
00047 short instId;
00048
00049
00050
00051
00052
00053
00054 short status;
00055
00056 int id;
00057 }
00058 cInfo;
00059 } sInfo;
00060
00061 char type;
00062 } CkSectionInfoStruct;
00063
00064 class CkSectionInfo {
00065 public:
00066 CkSectionInfoStruct info;
00067
00068 CkSectionInfo() {
00069 info.type = 0; info.pe = -1;
00070 info.sInfo.sCookie.val=NULL; info.sInfo.sCookie.redNo=0;
00071 info.sInfo.cInfo.instId = 0;
00072 info.sInfo.cInfo.status = 0;
00073 info.sInfo.cInfo.id = 0;
00074 }
00075
00076 CkSectionInfo(CkSectionInfoStruct i): info(i) {}
00077
00078 CkSectionInfo(int t) {
00079 info.type = t; info.pe = -1;
00080 switch (info.type) {
00081 case MulticastMsg:
00082 info.sInfo.sCookie.val=NULL;
00083 info.sInfo.sCookie.redNo=0;
00084 break;
00085 case COMLIB_MULTICAST_MESSAGE:
00086 info.sInfo.cInfo.instId=0;
00087 info.sInfo.cInfo.status=0;
00088 info.sInfo.cInfo.id=0;
00089 break;
00090 default:
00091 CmiAssert(0);
00092 }
00093 }
00094
00095 CkSectionInfo(CkArrayID _aid, void *p = NULL) {
00096 info.type = MulticastMsg;
00097 info.pe = CkMyPe();
00098 info.aid = _aid;
00099 info.sInfo.sCookie.val=p;
00100 info.sInfo.sCookie.redNo=0;
00101 }
00102
00103 CkSectionInfo(int e, void *p, int r, CkArrayID _aid) {
00104 info.type = MulticastMsg;
00105 info.pe = e;
00106 info.aid = _aid;
00107 info.sInfo.sCookie.val=p;
00108 info.sInfo.sCookie.redNo=r;
00109 }
00110
00111 inline char &get_type() { return info.type; }
00112 inline int &get_pe() { return info.pe; }
00113 inline int &get_redNo() { CmiAssert(info.type==MulticastMsg); return info.sInfo.sCookie.redNo; }
00114 inline void* &get_val() { CmiAssert(info.type==MulticastMsg); return info.sInfo.sCookie.val; }
00115 inline CkGroupID &get_aid() { return info.aid; }
00116 inline CkGroupID get_aid() const { return info.aid; }
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 };
00137
00138 PUPbytes(CkSectionInfo)
00139 PUPmarshall(CkSectionInfo)
00140
00141
00142
00143 class CkArrayIndex1D;
00144 class CkArrayIndex2D;
00145 class CkArrayIndex3D;
00146 class CkArrayIndex4D;
00147 class CkArrayIndex5D;
00148 class CkArrayIndex6D;
00149
00150 #define _SECTION_MAGIC 88
00151
00153 class CkMcastBaseMsg {
00154 public:
00155
00156 CkSectionInfo _cookie;
00157
00158 char magic;
00159 unsigned short ep;
00160
00161 CkMcastBaseMsg(): magic(_SECTION_MAGIC) {}
00162 static inline int checkMagic(CkMcastBaseMsg *m) { return m->magic == _SECTION_MAGIC; }
00163 inline int &gpe(void) { return _cookie.get_pe(); }
00164 inline int &redno(void) { return _cookie.get_redNo(); }
00165 inline void *&cookie(void) { return _cookie.get_val(); }
00166 };
00167
00168
00169
00170 #define CKSECTIONID_CONSTRUCTOR(index) \
00171 CkSectionID(const CkArrayID &aid, const CkArrayIndex##index *elems, const int nElems);
00172
00177 class CkSectionID {
00178 public:
00180 CkSectionInfo _cookie;
00182 CkArrayIndex *_elems;
00184 int _nElems;
00193 int *pelist;
00195 int npes;
00196
00197 CkSectionID(): _elems(NULL), _nElems(0), pelist(0), npes(0) {}
00198 CkSectionID(const CkSectionID &sid);
00199 CkSectionID(CkSectionInfo &c, CkArrayIndex *e, int n, int *_pelist, int _npes): _cookie(c), _elems(e), _nElems(n), pelist(_pelist), npes(_npes) {}
00200 CkSectionID(const CkGroupID &gid, const int *_pelist, const int _npes);
00201 CKSECTIONID_CONSTRUCTOR(1D)
00202 CKSECTIONID_CONSTRUCTOR(2D)
00203 CKSECTIONID_CONSTRUCTOR(3D)
00204 CKSECTIONID_CONSTRUCTOR(4D)
00205 CKSECTIONID_CONSTRUCTOR(5D)
00206 CKSECTIONID_CONSTRUCTOR(6D)
00207 CKSECTIONID_CONSTRUCTOR(Max)
00208
00209 inline int getSectionID(){ return _cookie.info.sInfo.cInfo.id; }
00210 void operator=(const CkSectionID &);
00211 ~CkSectionID() {
00212 if (_elems != NULL) delete [] _elems;
00213 if (pelist != NULL) delete [] pelist;
00214 }
00215 void pup(PUP::er &p);
00216 };
00217 PUPmarshall(CkSectionID)
00218
00219 #endif
00220