Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ProxyCombinedResultMsg Class Reference

#include <ProxyMgr.h>

List of all members.

Static Public Member Functions

void * pack (ProxyCombinedResultMsg *msg)
ProxyCombinedResultMsgunpack (void *ptr)

Public Attributes

PatchID patch
NodeIDList nodes
ForceList forceList [Results::maxNumForces]


Member Function Documentation

void * ProxyCombinedResultMsg::pack ProxyCombinedResultMsg msg  )  [static]
 

Definition at line 241 of file ProxyMgr.C.

References ALIGN_8, ResizeArray< Elem >::begin(), Force, forceList, j, NodeID, nodes, patch, ResizeArray< Elem >::size(), Vector::x, Vector::y, and Vector::z.

00241                                                               {
00242   int msg_size = 0;
00243   msg_size += sizeof(int) + msg->nodes.size()*sizeof(NodeID);
00244   #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00245   msg_size += sizeof(msg->destPe);
00246   #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
00247   msg_size += sizeof(msg->isFromImmMsgCall);
00248   #endif
00249   #endif  
00250   msg_size += sizeof(msg->patch);
00251   int j;
00252   for ( j = 0; j < Results::maxNumForces; ++j ) {
00253     int array_size = msg->forceList[j].size();
00254     msg_size += sizeof(array_size);
00255     msg_size += array_size * sizeof(char);
00256     msg_size = ALIGN_8 (msg_size);
00257 
00258     Force* f = msg->forceList[j].begin();
00259     int nonzero_count = 0;
00260     for ( int i = 0; i < array_size; ++i ) {
00261       if ( f[i].x != 0. || f[i].y != 0. || f[i].z != 0. ) { ++nonzero_count; }
00262     }
00263     msg_size += nonzero_count * sizeof(Force);
00264   }
00265 
00266   void *msg_buf = CkAllocBuffer(msg,msg_size);
00267   char *msg_cur = (char *)msg_buf;
00268 
00269   int nodeSize = msg->nodes.size();
00270   CmiMemcpy((void*)msg_cur,(void*)(&nodeSize), sizeof(nodeSize));
00271   msg_cur += sizeof(nodeSize);
00272   for (int i=0; i<nodeSize; i++) {
00273     CmiMemcpy((void*)msg_cur,(void*)(&msg->nodes[i]), sizeof(NodeID));
00274     msg_cur += sizeof(NodeID);
00275   }
00276   #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00277   CmiMemcpy((void*)msg_cur,(void*)(&(msg->destPe)),sizeof(msg->destPe));
00278   msg_cur += sizeof(msg->destPe);
00279   #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
00280   CmiMemcpy((void*)msg_cur, (void*)(&(msg->isFromImmMsgCall)), sizeof(msg->isFromImmMsgCall));
00281   msg_cur += sizeof(msg->isFromImmMsgCall);
00282   #endif
00283   #endif
00284   CmiMemcpy((void*)msg_cur,(void*)(&(msg->patch)),sizeof(msg->patch));
00285   msg_cur += sizeof(msg->patch);
00286   for ( j = 0; j < Results::maxNumForces; ++j ) {
00287     int array_size = msg->forceList[j].size();
00288     CmiMemcpy((void*)msg_cur,(void*)(&array_size),sizeof(array_size));
00289     msg_cur += sizeof(array_size);
00290     char *nonzero = msg_cur;
00291     msg_cur += array_size * sizeof(char);
00292     msg_cur = (char *)ALIGN_8 (msg_cur);
00293     Vector *farr = (Vector *) msg_cur; 
00294     Force* f = msg->forceList[j].begin();
00295 
00296     for ( int i = 0; i < array_size; ++i ) {
00297       if ( f[i].x != 0. || f[i].y != 0. || f[i].z != 0. ) {
00298         nonzero[i] = 1;
00299         farr->x  =  f[i].x;
00300         farr->y  =  f[i].y;
00301         farr->z  =  f[i].z;
00302 
00303         farr ++;
00304       } else {
00305         nonzero[i] = 0;
00306       }
00307     }
00308     msg_cur = (char *) farr;
00309   }
00310 
00311   delete msg;
00312   return msg_buf;
00313 }

ProxyCombinedResultMsg * ProxyCombinedResultMsg::unpack void *  ptr  )  [static]
 

Definition at line 315 of file ProxyMgr.C.

References ResizeArray< Elem >::add(), ALIGN_8, ResizeArray< Elem >::begin(), Force, forceList, j, nodes, patch, ResizeArray< Elem >::resize(), Vector::x, Vector::y, and Vector::z.

00315                                                                 {
00316   void *vmsg = CkAllocBuffer(ptr,sizeof(ProxyCombinedResultMsg));
00317   ProxyCombinedResultMsg *msg = new (vmsg) ProxyCombinedResultMsg;
00318   char *msg_cur = (char*)ptr;
00319 
00320   int nodeSize;
00321   CmiMemcpy((void*)(&nodeSize),(void*)msg_cur,sizeof(nodeSize));
00322   msg_cur += sizeof(nodeSize);
00323   for (int i=0; i<nodeSize; i++) {
00324     msg->nodes.add(*(int *)msg_cur);
00325     msg_cur += sizeof(NodeID);
00326   }
00327   #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00328   CmiMemcpy((void*)(&(msg->destPe)),(void*)msg_cur,sizeof(msg->destPe));
00329   msg_cur += sizeof(msg->destPe);
00330   #if CMK_SMP && defined(NAMDSRC_IMMQD_HACK)
00331   CmiMemcpy((void *)(&(msg->isFromImmMsgCall)), (void*)msg_cur, sizeof(msg->isFromImmMsgCall));
00332   msg_cur += sizeof(msg->isFromImmMsgCall);  
00333   #endif
00334   #endif
00335   CmiMemcpy((void*)(&(msg->patch)),(void*)msg_cur,sizeof(msg->patch));
00336   msg_cur += sizeof(msg->patch);
00337   int j;
00338   for ( j = 0; j < Results::maxNumForces; ++j ) {
00339     int array_size;
00340     CmiMemcpy((void*)(&array_size),(void*)msg_cur,sizeof(array_size));
00341     msg_cur += sizeof(array_size);
00342     msg->forceList[j].resize(array_size);
00343     char *nonzero = msg_cur;
00344     msg_cur += array_size * sizeof(char);
00345     msg_cur = (char *)ALIGN_8 (msg_cur);
00346     Vector* farr = (Vector *) msg_cur;
00347     Force* f = msg->forceList[j].begin();
00348 
00349     for ( int i = 0; i < array_size; ++i ) {
00350       if ( nonzero[i] ) {
00351         f[i].x = farr->x;
00352         f[i].y = farr->y;
00353         f[i].z = farr->z;
00354         farr++;
00355       } else {
00356         f[i].x = 0.;  f[i].y = 0.;  f[i].z = 0.;
00357       }
00358     }
00359     msg_cur = (char *) farr;
00360   }
00361 
00362   CkFreeMsg(ptr);
00363   return msg;
00364 }


Member Data Documentation

ForceList ProxyCombinedResultMsg::forceList[Results::maxNumForces]
 

Definition at line 194 of file ProxyMgr.h.

Referenced by ProxyPatch::depositCombinedResultMsg(), pack(), HomePatch::receiveResults(), and unpack().

NodeIDList ProxyCombinedResultMsg::nodes
 

Definition at line 193 of file ProxyMgr.h.

Referenced by ProxyPatch::depositCombinedResultMsg(), pack(), HomePatch::receiveResults(), and unpack().

PatchID ProxyCombinedResultMsg::patch
 

Definition at line 192 of file ProxyMgr.h.

Referenced by pack(), NodeProxyMgr::recvImmediateResults(), ProxyMgr::recvImmediateResults(), ProxyMgr::recvResults(), ProxyMgr::sendResults(), and unpack().


The documentation for this class was generated from the following files:
Generated on Tue Nov 24 04:07:51 2009 for NAMD by  doxygen 1.3.9.1