
00001 // #ifdef filippo 00002 00003 // #include "MsgPacker.h" 00004 00005 // CkpvExtern(int, RecvCombinedShortMsgHdlrIdx); 00006 00007 // MsgPacker::MsgPacker(){ 00008 // nShortMsgs = 0; 00009 // msgList = 0; 00010 // } 00011 00012 // MsgPacker::MsgPacker(CkQ<CharmMessageHolder *> &msgq, int n_msgs){ 00013 00014 // CkAssert(n_msgs < 65536); //16 bit field for num messages 00015 00016 // nShortMsgs = n_msgs; 00017 // msgList = new short_envelope[n_msgs]; 00018 00019 // for(int count = 0; count < n_msgs; count ++){ 00020 // CharmMessageHolder *cmsg = msgq.deq(); 00021 // char *msg = cmsg->getCharmMessage(); 00022 // envelope *env = (envelope *)UsrToEnv(msg); 00023 // CkPackMessage(&env); 00024 00025 // if(count == 0) { 00026 // aid = env->getsetArrayMgr(); 00027 // if(aid.isZero()) 00028 // CkAbort("Array packing set and ArrayID is zero"); 00029 // } 00030 00031 // msgList[count].epIdx = env->getsetArrayEp(); 00032 // msgList[count].size = env->getTotalsize() - sizeof(envelope); 00033 // msgList[count].idx = env->getsetArrayIndex(); 00034 // msgList[count].data = msg; 00035 00036 // CkAssert(msgList[count].size < MAX_MESSAGE_SIZE); 00037 // delete cmsg; 00038 // } 00039 // } 00040 00041 // //Takes a queue of envelopes as char* ptrs and not charm message holders 00042 // //Used by mesh streaming strategy 00043 // MsgPacker::MsgPacker(CkQ<char *> &msgq, int n_msgs){ 00044 00045 // CkAssert(n_msgs < 65536); //16 bit field for num messages 00046 00047 // nShortMsgs = n_msgs; 00048 // msgList = new short_envelope[n_msgs]; 00049 00050 // for(int count = 0; count < n_msgs; count ++){ 00051 // envelope *env = (envelope *)msgq.deq(); 00052 // char *msg = (char *)EnvToUsr(env); 00053 // CkPackMessage(&env); 00054 00055 // if(count == 0) { 00056 // aid = env->getsetArrayMgr(); 00057 // if(aid.isZero()) 00058 // CkAbort("Array packing set and ArrayID is zero"); 00059 // } 00060 00061 // msgList[count].epIdx = env->getsetArrayEp(); 00062 // msgList[count].size = env->getTotalsize() - sizeof(envelope); 00063 // msgList[count].idx = env->getsetArrayIndex(); 00064 // msgList[count].data = msg; 00065 00066 // CkAssert(msgList[count].size < MAX_MESSAGE_SIZE); 00067 // } 00068 // } 00069 00070 // MsgPacker::~MsgPacker(){ 00071 // if(nShortMsgs > 0 && msgList != NULL) { 00072 // for(int count = 0; count < nShortMsgs; count ++) 00073 // CkFreeMsg(msgList[count].data); 00074 00075 // delete [] msgList; 00076 // } 00077 // } 00078 00079 // void MsgPacker::getMessage(CombinedMessage *&cmb_msg, int &total_size){ 00080 // int count; 00081 // PUP_cmiAllocSizer sp; 00082 00083 // CombinedMessage cmb_hdr; 00084 // cmb_hdr.aid = aid; 00085 // cmb_hdr.srcPE = CkMyPe(); 00086 // cmb_hdr.nmsgs = nShortMsgs; 00087 00088 // sp | cmb_hdr; 00089 // for(count = 0; count < nShortMsgs; count ++) 00090 // sp | msgList[count]; 00091 00092 // total_size = sp.size(); 00093 // ComlibPrintf("In MsgPacker with %d bytes and %d messages\n", total_size, 00094 // nShortMsgs); 00095 00096 // cmb_msg = (CombinedMessage *)CmiAlloc(sp.size()); 00097 00098 // PUP_toCmiAllocMem mp(cmb_msg); 00099 // mp | cmb_hdr; 00100 00101 // for(count = 0; count < nShortMsgs; count ++) 00102 // mp | msgList[count]; 00103 00104 // CmiSetHandler(cmb_msg, CkpvAccess(RecvCombinedShortMsgHdlrIdx)); 00105 // } 00106 00107 // #endif
1.5.5