Skip to Content.
Sympa Menu

charm - [charm] Packed messages and CkMulticast

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

[charm] Packed messages and CkMulticast


Chronological Thread 
  • From: Pritish Jetley <pjetley2 AT illinois.edu>
  • To: charm AT cs.uiuc.edu
  • Subject: [charm] Packed messages and CkMulticast
  • Date: Wed, 28 Mar 2012 15:07:50 -0500
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/charm>
  • List-id: CHARM parallel programming system <charm.cs.uiuc.edu>

Hi all,

I have a question about using packed messages with CkMulticast. I have a user-defined, packed message type, MapMsg, which has integer members, as well as a pointer to a PUPable class:

struct MapMsg : public CkMcastBaseMsg, public CMessage_MapMsg {
  int x,y;
  MyPupableClass *ptr;

  static void *pack(MapMsg *in);
  static MapMsg *unpack(void *buf);
  void pup(PUP::er &p);
}

When I send out a MapMsg, I would like the PUPable object to which 'ptr' points, to be packed into it. Therefore, I have defined the pack() and unpack() methods for the MapMsg class:

void *MapMsg::pack(MapMsg *inm){
  PUP::sizer psz;
  inm->pup(psz);

  void *buf = (void *)CkAllocBuffer(inm,psz.size());
  PUP::toMem pmem(buf);
  inm->pup(pmem);

  delete inm;
  return buf;
}

MapMsg *MapMsg::unpack(void *inbuf){
  MapMsg *m = (MapMsg *)CkAllocBuffer(inbuf,sizeof(MapMsg));
  m->a = NULL;
  PUP::fromMem pmem(inbuf);
  m->pup(pmem);

  CkFreeMsg(inbuf); 
  return m; 
}

That is, I call pup() on the message to size and pack/unpack its contents. The pup() method for MapMsg is as follows:

  void MapMsg::pup(PUP::er &p){
    CkMcastBaseMsg::pup(p);
    CMessage_MapMsg::pup(p);
    p|x;
    p|y;
    p|ptr;
  }

I defined CkMcastBaseMsg::pup() myself, to pup the values of the CkMulticast cookie, magic number and ep index:

void CkMcastBaseMsg::pup(PUP::er &p){                       
  p|_cookie;                                
  p|magic;                                  
  p|ep;                                     
}   

However, the code segfaults when the message is being sent, which leads me to believe that I'm forgetting to pack something. Can anyone see something that is wrong with the code above?

Thanks,
Pritish

--
Pritish Jetley
Doctoral Candidate, Computer Science
University of Illinois at Urbana-Champaign



Archive powered by MHonArc 2.6.16.

Top of Page