00001 #ifndef _MULTICAST
00002 #define _MULTICAST
00003
00004 #include "pup.h"
00005 class mCastEntry;
00006
00007 class multicastSetupMsg;
00008 class multicastGrpMsg;
00009 class cookieMsg;
00010 class CkMcastBaseMsg;
00011 class reductionInfo;
00012
00013 typedef mCastEntry * mCastEntryPtr;
00014 PUPbytes(mCastEntryPtr)
00015
00016 #define MAXMCASTCHILDREN 2
00017
00018 #include "CkMulticast.decl.h"
00019
00020 typedef void (*redClientFn)(CkSectionInfo sid, void *param,int dataSize,void *data);
00021
00023 extern void CkGetSectionInfo(CkSectionInfo &id, void *msg);
00024
00025 class CProxySection_ArrayElement;
00026
00032 class CkMulticastMgr: public CkDelegateMgr
00033 {
00034 private:
00035 int dfactor;
00036 unsigned int split_size;
00037 unsigned int split_threshold;
00038
00039 public:
00040
00041 CkMulticastMgr(CkMigrateMessage *m) {}
00042 CkMulticastMgr(int _dfactor = 2, unsigned int _split_size = 8192, unsigned int _split_threshold = 8192):
00043 dfactor(_dfactor),
00044 split_size(_split_size),
00045 split_threshold(_split_threshold) {}
00046 bool useDefCtor(void){ return true; }
00047 void pup(PUP::er &p){
00048 CkDelegateMgr::pup(p);
00049 p|dfactor;
00050 p|split_size;
00051 p|split_threshold;
00052 }
00053
00054
00056 void setSection(CkSectionInfo &id, CkArrayID aid, CkArrayIndex *, int n);
00058 void setSection(CkSectionInfo &id, CkArrayID aid, CkArrayIndex *, int n, int factor);
00060 void setSection(CkSectionInfo &id);
00062 void setSection(CProxySection_ArrayElement &proxy);
00064 void setup(multicastSetupMsg *);
00066 void recvCookie(CkSectionInfo sid, CkSectionInfo child);
00068 void childrenReady(mCastEntry *entry);
00069
00071 void teardown(CkSectionInfo s);
00073 void retire(CkSectionInfo s, CkSectionInfo root);
00075 void freeup(CkSectionInfo s);
00076
00078 void retrieveCookie(CkSectionInfo s, CkSectionInfo srcInfo);
00080 void recvCookieInfo(CkSectionInfo s, int red);
00081
00083 void recvMsg(multicastGrpMsg *m);
00085 void sendToLocal(multicastGrpMsg *m);
00087 void recvPacket(CkSectionInfo &&_cookie, int offset, int n, char *data, int seqno, int count, int totalsize, bool fromBuffer);
00088
00090 void recvRedMsg(CkReductionMsg *msg);
00092 void updateRedNo(mCastEntryPtr, int red);
00094 void setReductionClient(CProxySection_ArrayElement &, redClientFn fn,void *param=NULL);
00096 void setReductionClient(CProxySection_ArrayBase &, CkCallback *cb);
00098 void contribute(CkSectionInfo &sid, int userData=-1, int fragSize=-1);
00099 void contribute(CkSectionInfo &sid, const CkCallback& cb, int userData=-1, int fragSize=-1);
00100 void contribute(int dataSize,void *data,CkReduction::reducerType type, CkSectionInfo &sid, int userData=-1, int fragSize=-1);
00101 template <typename T>
00102 void contribute(std::vector<T> &data, CkReduction::reducerType type, CkSectionInfo &sid, int userData=-1, int fragSize=-1)
00103 { contribute(sizeof(T)*data.size(), data.data(), type, sid, userData, fragSize); }
00105 void contribute(int dataSize,void *data,CkReduction::reducerType type, CkSectionInfo &sid, const CkCallback &cb,
00106 int userData=-1, int fragSize=-1);
00107 template <typename T>
00108 void contribute(std::vector<T> &data, CkReduction::reducerType type, CkSectionInfo &sid, const CkCallback &cb,
00109 int userData=-1, int fragSize=-1)
00110 { contribute(sizeof(T)*data.size(), data.data(), type, sid, cb, userData, fragSize); }
00112
00113
00115 void resetSection(CProxySection_ArrayBase &proxy);
00117 virtual void initDelegateMgr(CProxy *proxy, int opts=0);
00119 void ArraySectionSend(CkDelegateData *pd,int ep,void *m, int nsid, CkSectionID *s, int opts);
00121 void SimpleSend(int ep,void *m, CkArrayID a, CkSectionID &sid, int opts);
00123 void rebuild(CkSectionInfo &);
00124
00125
00126 void setReductionClient(CProxySection_Group &proxy, CkCallback *cb);
00128 void GroupSectionSend(CkDelegateData *pd,int ep,void *m,int nsid,CkSectionID *s);
00129
00130 private:
00132 void prepareCookie(mCastEntry *entry, CkSectionID &sid, const CkArrayIndex *al, int count, CkArrayID aid);
00134 void initCookie(CkSectionInfo sid);
00136 void sendToSection(CkDelegateData *pd,int ep,void *m, CkSectionID *sid, int opts);
00138 void resetCookie(CkSectionInfo sid);
00140 void releaseBufferedReduceMsgs(mCastEntryPtr entry);
00142 void releaseFutureReduceMsgs(mCastEntryPtr entry);
00144 inline CkReductionMsg *buildContributeMsg(int dataSize,void *data,CkReduction::reducerType type, CkSectionInfo &id, CkCallback &cb, int userFlag=-1);
00146 void reduceFragment (int index, CkSectionInfo& id, mCastEntry* entry, reductionInfo& redInfo, int currentTreeUp);
00148 CkReductionMsg* combineFrags (CkSectionInfo& id, mCastEntry* entry, reductionInfo& redInfo);
00149
00150
00152 void initGrpDelegateMgr(CProxySection_Group *proxy, int opts);
00154 void prepareGrpCookie(mCastEntry *entry, CkSectionID &sid, const int *pelist, int count, CkGroupID gid);
00156 void initGrpCookie(CkSectionInfo sid);
00157 };
00158
00159 #endif