00001 #include <ck.h>
00002 #include "envelope.h"
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include <string.h>
00006 #include "queueing.h"
00007
00008 #if 0
00009
00010 CqsEnumerateQueue((Queue)CpvAccess(CsdSchedQueue), &schedQueue);
00011 FIFOQueue = CdsFifo_Enumerate((CdsFifo)CpvAccess(CmiLocalQueue));
00012 DQueue = CdsFifo_Enumerate(CpvAccess(debugQueue));
00013 #endif
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 void CkPupMessage(PUP::er &p,void **atMsg,int pack_mode) {
00027 UChar type;
00028 int size,prioBits,envSize,groupDepNum;
00029
00030
00031 int isNull = (*atMsg == NULL);
00032 p(isNull);
00033 if (isNull) { *atMsg = NULL; return; }
00034
00035 envelope *env=UsrToEnv(*atMsg);
00036 unsigned char wasPacked=0;
00037 p.comment("Begin Charm++ Message {");
00038 if (!p.isUnpacking()) {
00039 wasPacked=env->isPacked();
00040 if (0==wasPacked)
00041 CkPackMessage(&env);
00042 type=env->getMsgtype();
00043 size=env->getTotalsize();
00044 prioBits=env->getPriobits();
00045 groupDepNum=env->getGroupDepNum();
00046 envSize=sizeof(envelope);
00047 }
00048 p(type);
00049 p(wasPacked);
00050 p(size);
00051 p(prioBits);
00052 p(groupDepNum);
00053 p(envSize);
00054 int userSize=size-envSize-sizeof(int)*CkPriobitsToInts(prioBits)-groupDepNum*sizeof(CkGroupID);
00055 if (p.isUnpacking())
00056 env=_allocEnv(type,userSize,prioBits,GroupDepNum{groupDepNum});
00057 if (pack_mode == 1) {
00058
00059 p((char *)env,size);
00060 }
00061 else if (pack_mode == 2) {
00062
00063
00064 env->pup(p);
00065 p((char*)env+sizeof(envelope),size-envSize);
00066 }
00067 else
00068 {
00069 p.comment("Message Envelope:");
00070 env->pup(p);
00071 p.comment("Message User Data:");
00072 #if 0
00073 int ep=env->getEpIdx();
00074 if (ep>0 && ep<_numEntries)
00075 _entryTable[ep]->pupFn(p,*atMsg);
00076 else
00077 #endif
00078 ((CkMessage *)*atMsg)->pup(p);
00079 p.comment("} End Charm++ Message");
00080 }
00081 if (0==wasPacked)
00082 CkUnpackMessage(&env);
00083 *atMsg=EnvToUsr(env);
00084 }
00085
00086 void envelope::pup(PUP::er &p) {
00087
00088 int convHeaderSize;
00089 if (!p.isUnpacking()) convHeaderSize = CmiReservedHeaderSize;
00090 p(convHeaderSize);
00091
00092 p((char *)core,convHeaderSize);
00093 p(ref);
00094
00095 p(attribs.msgIdx);
00096 p(attribs.mtype);
00097 int d;
00098 if (!p.isUnpacking()) d = attribs.queueing;
00099
00100 p|d;
00101 if (p.isUnpacking()) attribs.queueing = d;
00102 if (!p.isUnpacking()) d = attribs.isPacked;
00103 p|d;
00104 if (p.isUnpacking()) attribs.isPacked = d;
00105 if (!p.isUnpacking()) d = attribs.isUsed;
00106 p|d;
00107 if (p.isUnpacking()) attribs.isUsed = d;
00108 p(epIdx);
00109 p(pe);
00110 #if CMK_REPLAYSYSTEM || CMK_TRACE_ENABLED
00111 p(event);
00112 #endif
00113 p((char*)getPrioPtr(),getPrioBytes());
00114 p((char*)getGroupDepPtr(),getGroupDepSize());
00115 switch(getMsgtype()) {
00116 case NewChareMsg: case NewVChareMsg:
00117 case ForChareMsg: case ForVidMsg: case FillVidMsg:
00118 p((char *)&(type.chare.ptr),sizeof(void *));
00119 p(type.chare.forAnyPe);
00120 break;
00121 case NodeBocInitMsg: case BocInitMsg: case ForNodeBocMsg: case ForBocMsg:
00122 p|type.group.g;
00123 p|type.group.rednMgr;
00124 p|type.group.epoch;
00125 p|type.group.arrayEp;
00126 break;
00127 case ArrayEltInitMsg: case ForArrayEltMsg:
00128 p|type.array.arr;
00129 p|type.array.id;
00130 p(type.array.hopCount);
00131 p(type.array.ifNotThere);
00132 break;
00133 case RODataMsg:
00134 p(type.roData.count);
00135 break;
00136 case ROMsgMsg:
00137 p(type.roMsg.roIdx);
00138 break;
00139 default:
00140 break;
00141 }
00142 }
00143
00144 void CkMessage::pup(PUP::er &p) {
00145
00146 envelope *env=UsrToEnv((void *)this);
00147 int userSize=env->getTotalsize()-sizeof(envelope)-env->getPrioBytes()-env->getGroupDepSize();
00148 p((char *)this,userSize);
00149 }