Skip to Content.
Sympa Menu

charm - [charm] PUP framework related....

charm AT lists.cs.illinois.edu

Subject: Charm++ parallel programming system

List archive

[charm] PUP framework related....


Chronological Thread 
  • From: Yogesh Sonawane <sonawane.yogesh19 AT gmail.com>
  • To: charm AT cs.uiuc.edu
  • Subject: [charm] PUP framework related....
  • Date: Mon, 2 Apr 2012 15:30:32 +0530
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/charm>
  • List-id: CHARM parallel programming system <charm.cs.uiuc.edu>

Hello,

following examples are from the CHARM++ manual.
http://charm.cs.illinois.edu/manuals/html/charm++/3_18.html (Section: 3.18.3 Dynamic allocation).

   The issue is, I could understand the code and what it does But i am not getting the exact difference between
"Allocation outside the PUP" and "Allocation during the PUP".
and also in which  condition the right one should be used?

Please, will some one explain this?

Thank you,
Yogesh. 

**************************************************************************************************************************************************
/* 2. Allocation outside pup

The next simplest case is when we contain a class that is always allocated during our constructor,
and deallocated during our destructor. Then no allocation is needed within the pup routine.   */

class keepsHeapFoo : public mySuperclass {
private:
    foo *f;             /*Heap-allocated foo object*/
public:
    keepsHeapFoo(void) {
      f=new foo;
    }
   
    void pup(PUP::er &p) {
      mySuperclass::pup(p);
      p|*f;             // pup f's fields (calls f->pup(p))
    }
   
    ~keepsHeapFoo() {delete f;}
};

/*3 Allocation during pup

If we need values obtained during the pup routine before we can allocate the class,
we must allocate the class inside the pup routine. Be sure to protect the allocation with ``if (p.isUnpacking())''. */

class keepsOneFoo : public mySuperclass {
private:
    foo *f;             /*Heap-allocated foo object*/
public:
    keepsOneFoo(...) {f=new foo(...);}
    keepsOneFoo() {f=NULL;} /* pup constructor */
   
    void pup(PUP::er &p) {
      mySuperclass::pup(p);
      ...
      if (p.isUnpacking()) /* must allocate foo now */
         f=new foo(...);
      p|*f;                //pup f's fields
    }
    ~keepsOne

**********************************************************************************************************************************************


  • [charm] PUP framework related...., Yogesh Sonawane, 04/02/2012

Archive powered by MHonArc 2.6.16.

Top of Page