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 230 of file ProxyMgr.C.

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

00230                                                               {
00231   int msg_size = 0;
00232   msg_size += sizeof(int) + msg->nodes.size()*sizeof(NodeID);
00233   #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00234   msg_size += sizeof(msg->destPe);
00235   #endif  
00236   msg_size += sizeof(msg->patch);
00237   int j;
00238   for ( j = 0; j < Results::maxNumForces; ++j ) {
00239     int array_size = msg->forceList[j].size();
00240     msg_size += sizeof(array_size);
00241     msg_size += array_size * sizeof(char);
00242     msg_size = ALIGN_8 (msg_size);
00243 
00244     Force* f = msg->forceList[j].begin();
00245     int nonzero_count = 0;
00246     for ( int i = 0; i < array_size; ++i ) {
00247       if ( f[i].x != 0. || f[i].y != 0. || f[i].z != 0. ) { ++nonzero_count; }
00248     }
00249     msg_size += nonzero_count * sizeof(Force);
00250   }
00251 
00252   void *msg_buf = CkAllocBuffer(msg,msg_size);
00253   char *msg_cur = (char *)msg_buf;
00254 
00255   int nodeSize = msg->nodes.size();
00256   CmiMemcpy((void*)msg_cur,(void*)(&nodeSize), sizeof(nodeSize));
00257   msg_cur += sizeof(nodeSize);
00258   for (int i=0; i<nodeSize; i++) {
00259     CmiMemcpy((void*)msg_cur,(void*)(&msg->nodes[i]), sizeof(NodeID));
00260     msg_cur += sizeof(NodeID);
00261   }
00262   #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00263   CmiMemcpy((void*)msg_cur,(void*)(&(msg->destPe)),sizeof(msg->destPe));
00264   msg_cur += sizeof(msg->destPe);
00265   #endif
00266   CmiMemcpy((void*)msg_cur,(void*)(&(msg->patch)),sizeof(msg->patch));
00267   msg_cur += sizeof(msg->patch);
00268   for ( j = 0; j < Results::maxNumForces; ++j ) {
00269     int array_size = msg->forceList[j].size();
00270     CmiMemcpy((void*)msg_cur,(void*)(&array_size),sizeof(array_size));
00271     msg_cur += sizeof(array_size);
00272     char *nonzero = msg_cur;
00273     msg_cur += array_size * sizeof(char);
00274     msg_cur = (char *)ALIGN_8 (msg_cur);
00275     Vector *farr = (Vector *) msg_cur; 
00276     Force* f = msg->forceList[j].begin();
00277 
00278     for ( int i = 0; i < array_size; ++i ) {
00279       if ( f[i].x != 0. || f[i].y != 0. || f[i].z != 0. ) {
00280         nonzero[i] = 1;
00281         farr->x  =  f[i].x;
00282         farr->y  =  f[i].y;
00283         farr->z  =  f[i].z;
00284 
00285         farr ++;
00286       } else {
00287         nonzero[i] = 0;
00288       }
00289     }
00290     msg_cur = (char *) farr;
00291   }
00292 
00293   delete msg;
00294   return msg_buf;
00295 }

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

Definition at line 297 of file ProxyMgr.C.

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

00297                                                                 {
00298   void *vmsg = CkAllocBuffer(ptr,sizeof(ProxyCombinedResultMsg));
00299   ProxyCombinedResultMsg *msg = new (vmsg) ProxyCombinedResultMsg;
00300   char *msg_cur = (char*)ptr;
00301 
00302   int nodeSize;
00303   CmiMemcpy((void*)(&nodeSize),(void*)msg_cur,sizeof(nodeSize));
00304   msg_cur += sizeof(nodeSize);
00305   for (int i=0; i<nodeSize; i++) {
00306     msg->nodes.add(*(int *)msg_cur);
00307     msg_cur += sizeof(NodeID);
00308   }
00309   #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
00310   CmiMemcpy((void*)(&(msg->destPe)),(void*)msg_cur,sizeof(msg->destPe));
00311   msg_cur += sizeof(msg->destPe);
00312   #endif
00313   CmiMemcpy((void*)(&(msg->patch)),(void*)msg_cur,sizeof(msg->patch));
00314   msg_cur += sizeof(msg->patch);
00315   int j;
00316   for ( j = 0; j < Results::maxNumForces; ++j ) {
00317     int array_size;
00318     CmiMemcpy((void*)(&array_size),(void*)msg_cur,sizeof(array_size));
00319     msg_cur += sizeof(array_size);
00320     msg->forceList[j].resize(array_size);
00321     char *nonzero = msg_cur;
00322     msg_cur += array_size * sizeof(char);
00323     msg_cur = (char *)ALIGN_8 (msg_cur);
00324     Vector* farr = (Vector *) msg_cur;
00325     Force* f = msg->forceList[j].begin();
00326 
00327     for ( int i = 0; i < array_size; ++i ) {
00328       if ( nonzero[i] ) {
00329         f[i].x = farr->x;
00330         f[i].y = farr->y;
00331         f[i].z = farr->z;
00332         farr++;
00333       } else {
00334         f[i].x = 0.;  f[i].y = 0.;  f[i].z = 0.;
00335       }
00336     }
00337     msg_cur = (char *) farr;
00338   }
00339 
00340   CkFreeMsg(ptr);
00341   return msg;
00342 }


Member Data Documentation

ForceList ProxyCombinedResultMsg::forceList[Results::maxNumForces]
 

Definition at line 160 of file ProxyMgr.h.

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

NodeIDList ProxyCombinedResultMsg::nodes
 

Definition at line 159 of file ProxyMgr.h.

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

PatchID ProxyCombinedResultMsg::patch
 

Definition at line 158 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 Fri Sep 5 04:07:19 2008 for NAMD by  doxygen 1.3.9.1