4 CkpvDeclare(size_t *, _offsets);
7 void *CkAllocSysMsg(const CkEntryOptions *opts)
10 return CkpvAccess(_msgPool)->get();
12 envelope *env = _allocEnv(ForChareMsg, 0, opts->getPriorityBits(), GroupDepNum{(int)opts->getGroupDepNum()});
13 setMemoryTypeMessage(env);
16 env->setIsVarSysMsg(1);
17 // Set the message's queueing type
18 env->setQueueing((unsigned char)opts->getQueueing());
20 // Copy the priority bytes into the env from the opts
21 if (opts->getPriorityPtr() != NULL)
22 CmiMemcpy(env->getPrioPtr(), opts->getPriorityPtr(), env->getPrioBytes());
24 // Copy the group dependence into the env from the opts
25 if(opts->getGroupDepNum() > 0)
26 CmiMemcpy(env->getGroupDepPtr(), opts->getGroupDepPtr(), env->getGroupDepSize());
32 void CkFreeSysMsg(void *m)
34 CkpvAccess(_msgPool)->put(m);
38 void* CkAllocMsg(int msgIdx, int msgBytes, int prioBits, GroupDepNum groupDepNum)
40 envelope* env = _allocEnv(ForChareMsg, msgBytes, prioBits, groupDepNum);
41 setMemoryTypeMessage(env);
43 env->setQueueing(_defaultQueueing);
44 env->setMsgIdx(msgIdx);
50 void* CkAllocBuffer(void *msg, int bufsize)
52 bufsize = CkMsgAlignLength(bufsize);
53 envelope *env = UsrToEnv(msg);
54 envelope *packbuf = _allocEnv(env->getMsgtype(), bufsize,
56 GroupDepNum{(int)env->getGroupDepNum()});
58 int size = packbuf->getTotalsize();
59 CmiMemcpy(packbuf, env, sizeof(envelope));
60 packbuf->setTotalsize(size);
61 packbuf->setPacked(!env->isPacked());
62 CmiMemcpy(packbuf->getPrioPtr(), env->getPrioPtr(), packbuf->getPrioBytes());
64 return EnvToUsr(packbuf);;
68 void CkFreeMsg(void *msg)
71 CmiFree(UsrToEnv(msg));
77 void* CkCopyMsg(void **pMsg)
78 {// cannot simply memcpy, because srcMsg could be varsize msg
80 envelope *env = UsrToEnv(srcMsg);
81 unsigned char msgidx = env->getMsgIdx();
82 if(!env->isPacked() && _msgTable[msgidx]->pack) {
83 srcMsg = _msgTable[msgidx]->pack(srcMsg);
84 UsrToEnv(srcMsg)->setPacked(1);
86 int size = UsrToEnv(srcMsg)->getTotalsize();
87 envelope *newenv = (envelope *) CmiAlloc(size);
88 CmiMemcpy(newenv, UsrToEnv(srcMsg), size);
89 //memcpy(newenv, UsrToEnv(srcMsg), size);
90 if(UsrToEnv(srcMsg)->isPacked() && _msgTable[msgidx]->unpack) {
91 srcMsg = _msgTable[msgidx]->unpack(srcMsg);
92 UsrToEnv(srcMsg)->setPacked(0);
95 if(newenv->isPacked() && _msgTable[msgidx]->unpack) {
96 srcMsg = _msgTable[msgidx]->unpack(EnvToUsr(newenv));
97 UsrToEnv(srcMsg)->setPacked(0);
98 } else srcMsg = EnvToUsr(newenv);
100 setMemoryTypeMessage(newenv);
105 void CkSetQueueing(void *msg, int strategy)
107 UsrToEnv(msg)->setQueueing((unsigned char) strategy);
112 void* CkPriorityPtr(void *msg)
114 #if CMK_ERROR_CHECKING
115 if (UsrToEnv(msg)->getPriobits() == 0) CkAbort("Trying to access priority bits, but none was allocated");
117 return UsrToEnv(msg)->getPrioPtr();
120 CkMarshallMsg *CkAllocateMarshallMsgNoninline(int size,const CkEntryOptions *opts)
122 //Allocate the message
123 CkMarshallMsg *m=new (size,opts->getPriorityBits(),GroupDepNum{(int)opts->getGroupDepNum()}) CkMarshallMsg;
124 //Copy the user's priority data into the message
125 envelope *env=UsrToEnv(m);
126 setMemoryTypeMessage(env);
127 if (opts->getPriorityPtr() != NULL)
128 CmiMemcpy(env->getPrioPtr(),opts->getPriorityPtr(),env->getPrioBytes());
130 // Copy the group dependence into the env from the opts
131 if(opts->getGroupDepNum() > 0)
132 CmiMemcpy(env->getGroupDepPtr(), opts->getGroupDepPtr(), env->getGroupDepSize());
134 //Set the message's queueing type
135 env->setQueueing((unsigned char)opts->getQueueing());