Ejemplo n.º 1
0
void CkQuadView::pup(PUP::er &p) {
	CkView::pup(p);
	p.comment("Texture corners");
	p|nCorners;
	for (int i=0;i<nCorners;i++) {
		p|corners[i];
		p|texCoord[i];
	}
	
// Pup the image:
	x_tex.pup(p);

#ifdef CMK_LIVEVIZ3D_CLIENT
	if (p.isUnpacking()) { /* immediately upload image to OpenGL */
		CkAllocImage *img=x_tex.getImage();
		oglTextureFormat_t fmt=oglImageFormat(*img);
		c_tex=new oglLilTex(img->getData(),x_tex.gl_w,x_tex.gl_h,
			fmt.format,fmt.type);
		stats::get()->add(x_tex.w*x_tex.h,op_upload_pixels);
		stats::get()->add(x_tex.gl_w*x_tex.gl_h,op_uploadpad_pixels);
		/// Scale texture coordinates from the partial image to OpenGL fractions:
		double tx=x_tex.w/(double)x_tex.gl_w;
		double ty=x_tex.h/(double)x_tex.gl_h;
		for (int i=0;i<nCorners;i++) 
			texCoord[i]=c_tex->texCoord(
				CkVector3d(tx*texCoord[i].x,ty*texCoord[i].y,texCoord[i].z)
			);
		
		//Now that we've copied the view into GL, 
		// flush the old in-memory copy:
		delete img;
	}
#endif

}
Ejemplo n.º 2
0
void operator| (PUP::er& p, Vec& v) {
  PetscInt sz;
  if (!p.isUnpacking()) {
    VecGetSize(v, &sz);
  }
  p | sz;
  if(p.isUnpacking()) {    
	  VecCreateSeq(PETSC_COMM_WORLD, sz,  &v);
	  VecSetFromOptions(v);
	  VecGetSize(v, &sz);

	  for (int i = 0; i < sz; i++) {
		  PetscScalar d;
		  p | d;
		  VecSetValue(v, i, d, INSERT_VALUES);
	  }
	  VecAssemblyBegin(v);
	  VecAssemblyEnd(v);
  }
  else {
	  for (int i = 0; i < sz; i++) {
		  PetscScalar d;
		  VecGetValues(v, 1, &i, &d);
		  p | d;
	  }
  }
}
Ejemplo n.º 3
0
/// PUP routine
void GVT::pup(PUP::er &p) {
  p|estGVT; p|inactive; p|inactiveTime; p|nextLBstart;
  p|lastEarliest; p|lastSends; p|lastRecvs; p|reportsExpected;
  p|optGVT; p|conGVT; p|done; p|startOffset;
  p|gvtIterationCount;

  if (p.isUnpacking()) {
#ifndef CMK_OPTIMIZE
    localStats = (localStat *)CkLocalBranch(theLocalStats);
#endif
  }

  int nullFlag;
  if (SRs == NULL) {
    nullFlag = 1;
  } else {
    nullFlag = 0;
  }
  p|nullFlag;
  if (p.isUnpacking()) {
    if (nullFlag) {
      SRs = NULL;
    } else {
      SRs = new SRentry();
      SRs->pup(p);
    }
  } else {
    if (!nullFlag) {
      SRs->pup(p);
    }
  }
}
Ejemplo n.º 4
0
// handle main chare
void CkPupMainChareData(PUP::er &p, CkArgMsg *args)
{
	int nMains=_mainTable.size();
	DEBCHK("[%d] CkPupMainChareData %s: nMains = %d\n", CkMyPe(),p.typeString(),nMains);
	for(int i=0;i<nMains;i++){  /* Create all mainchares */
		ChareInfo *entry = _chareTable[_mainTable[i]->chareIdx];
		int entryMigCtor = entry->getMigCtor();
		if(entryMigCtor!=-1) {
			Chare* obj;
			if (p.isUnpacking()) {
				int size = entry->size;
				DEBCHK("MainChare PUP'ed: name = %s, idx = %d, size = %d\n", entry->name, i, size);
				obj = (Chare*)malloc(size);
				_MEMCHECK(obj);
				_mainTable[i]->setObj(obj);
				//void *m = CkAllocSysMsg();
				_entryTable[entryMigCtor]->call(args, obj);
			}
			else 
			 	obj = (Chare *)_mainTable[i]->getObj();
			obj->pup(p);
		}
	}
	// to update mainchare proxy
	// only readonly variables of Chare Proxy is taken care of here;
	// in general, if chare proxy is contained in some data structure
	// for example CkCallback, it is user's responsibility to
	// update them after restarting
	if (p.isUnpacking() && CkMyPe()==0)
		bdcastRO();
}
Ejemplo n.º 5
0
  void pupSingleMessage(PUP::er &p, int curObj, void *msg) {
    beginItem(p,curObj);
    int isCharm=0;
    const char *type="Converse";
    p.comment("name");
    char name[128];
    if (msg == (void*)-1) {
      type="Sentinel";
      p((char*)type, strlen(type));
      return;
    }
#if ! CMK_BIGSIM_CHARM
    if (CmiGetHandler(msg)==_charmHandlerIdx) {isCharm=1; type="Local Charm";}
    if (CmiGetXHandler(msg)==_charmHandlerIdx) {isCharm=1; type="Network Charm";}
#else
    isCharm=1; type="BG";
#endif
    if (curObj < 0) type="Conditional";
    sprintf(name,"%s %d: %s (%d)","Message",curObj,type,CmiGetHandler(msg));
    p(name, strlen(name));

    if (isCharm)
    { /* charm message */
      p.comment("charmMsg");
      p.synchronize(PUP::sync_begin_object);
      envelope *env=(envelope *)msg;
      CkUnpackMessage(&env);
      //messages[curObj]=env;
      CpdPupMessage(p, EnvToUsr(env));
      //CkPupMessage(p, &messages[curObj], 0);
      p.synchronize(PUP::sync_end_object);
    }
  }
Ejemplo n.º 6
0
// handle GroupTable and data
void CkPupGroupData(PUP::er &p, CmiBool create)
{
	int numGroups, i;

	if (!p.isUnpacking()) {
	  numGroups = CkpvAccess(_groupIDTable)->size();
	}
	p|numGroups;
	if (p.isUnpacking()) {
	  if(CkMyPe()==0)  
            CkpvAccess(_numGroups) = numGroups+1; 
          else 
	    CkpvAccess(_numGroups) = 1;
	}
	DEBCHK("[%d] CkPupGroupData %s: numGroups = %d\n", CkMyPe(),p.typeString(),numGroups);

	GroupInfo *tmpInfo = new GroupInfo [numGroups];
	if (!p.isUnpacking()) {
	  for(i=0;i<numGroups;i++) {
		tmpInfo[i].gID = (*CkpvAccess(_groupIDTable))[i];
		TableEntry ent = CkpvAccess(_groupTable)->find(tmpInfo[i].gID);
		tmpInfo[i].MigCtor = _chareTable[ent.getcIdx()]->migCtor;
		tmpInfo[i].DefCtor = _chareTable[ent.getcIdx()]->defCtor;
		strncpy(tmpInfo[i].name,_chareTable[ent.getcIdx()]->name,255);
		//CkPrintf("[%d] CkPupGroupData: %s group %s \n", CkMyPe(), p.typeString(), tmpInfo[i].name);

		if(tmpInfo[i].MigCtor==-1) {
			char buf[512];
			sprintf(buf,"Group %s needs a migration constructor and PUP'er routine for restart.\n", tmpInfo[i].name);
			CkAbort(buf);
		}
	  }
  	}
	for (i=0; i<numGroups; i++) p|tmpInfo[i];

	for(i=0;i<numGroups;i++) 
	{
	  CkGroupID gID = tmpInfo[i].gID;
	  if (p.isUnpacking()) {
	    //CkpvAccess(_groupIDTable)->push_back(gID);
	    int eIdx = tmpInfo[i].MigCtor;
	    // error checking
	    if (eIdx == -1) {
	      CkPrintf("[%d] ERROR> Group %s's migration constructor is not defined!\n", CkMyPe(), tmpInfo[i].name); CkAbort("Abort");
	    }
	    void *m = CkAllocSysMsg();
	    envelope* env = UsrToEnv((CkMessage *)m);
		if(create)
		    CkCreateLocalGroup(gID, eIdx, env);
	  }   // end of unPacking
	  IrrGroup *gobj = CkpvAccess(_groupTable)->find(gID).getObj();
	  // if using migration constructor, you'd better have a pup
	  	if(!create)
			gobj->mlogData->teamRecoveryFlag = 1;
          gobj->pup(p);
         // CkPrintf("Group PUP'ed: gid = %d, name = %s\n",gobj->ckGetGroupID().idx, tmpInfo[i].name);
	}
	delete [] tmpInfo;
}
Ejemplo n.º 7
0
	void pup(PUP::er &p) {
		p|len1;
		if (p.isUnpacking()) arr1=new int[len1];
		PUParray(p,arr1,len1);
		p|len2;
		if (p.isUnpacking()) arr2=new int[len2];
		PUParray(p,arr2,len2);
		p|subclass;
	}
Ejemplo n.º 8
0
void CkPupROData(PUP::er &p)
{
	int _numReadonlies;
	if (!p.isUnpacking()) _numReadonlies=_readonlyTable.size();
        p|_numReadonlies;
	if (p.isUnpacking()) {
	  if (_numReadonlies != _readonlyTable.size())
	    CkAbort("You cannot add readonlies and restore from checkpoint...");
	}
	for(int i=0;i<_numReadonlies;i++) _readonlyTable[i]->pupData(p);
}
Ejemplo n.º 9
0
 virtual void pup(PUP::er &p, CpdListItemsRequest &req) {
   for (int i=0; i<_debugData.length(); ++i) {
     beginItem(p, i);
     void *obj = _debugData[i].obj;
     p.comment("obj");
     pup_pointer(&p, &obj);
     void *msg = _debugData[i].msg;
     p.comment("msg");
     pup_pointer(&p, &msg);
   }
 }
Ejemplo n.º 10
0
void CkMarshalledCLBStatsMessage::pup(PUP::er &p)
{
  int count = msgs.size();
  p|count;
  for (int i=0; i<count; i++) {
    CLBStatsMsg *msg;
    if (p.isUnpacking()) msg = new CLBStatsMsg;
    else { 
      msg = msgs[i]; CmiAssert(msg!=NULL);
    }
    msg->pup(p);
    if (p.isUnpacking()) add(msg);
  }
}
Ejemplo n.º 11
0
// handle NodeGroupTable and data
void CkPupNodeGroupData(PUP::er &p, CmiBool create)
{
	int numNodeGroups, i;
	if (!p.isUnpacking()) {
	  numNodeGroups = CksvAccess(_nodeGroupIDTable).size();
	}
	p|numNodeGroups;
	if (p.isUnpacking()) {
	  if(CkMyPe()==0){ CksvAccess(_numNodeGroups) = numNodeGroups+1; }
	  else { CksvAccess(_numNodeGroups) = 1; }
	}
	if(CkMyPe() == 3)
	CkPrintf("[%d] CkPupNodeGroupData %s: numNodeGroups = %d\n",CkMyPe(),p.typeString(),numNodeGroups);

	GroupInfo *tmpInfo = new GroupInfo [numNodeGroups];
	if (!p.isUnpacking()) {
	  for(i=0;i<numNodeGroups;i++) {
		tmpInfo[i].gID = CksvAccess(_nodeGroupIDTable)[i];
		TableEntry ent2 = CksvAccess(_nodeGroupTable)->find(tmpInfo[i].gID);
		tmpInfo[i].MigCtor = _chareTable[ent2.getcIdx()]->migCtor;
		if(tmpInfo[i].MigCtor==-1) {
			char buf[512];
			sprintf(buf,"NodeGroup %s either need a migration constructor and\n\
				     declared as [migratable] in .ci to be able to checkpoint.",\
				     _chareTable[ent2.getcIdx()]->name);
			CkAbort(buf);
		}
	  }
	}
	for (i=0; i<numNodeGroups; i++) p|tmpInfo[i];
	for (i=0;i<numNodeGroups;i++) {
		CkGroupID gID = tmpInfo[i].gID;
		if (p.isUnpacking()) {
			//CksvAccess(_nodeGroupIDTable).push_back(gID);
			int eIdx = tmpInfo[i].MigCtor;
			void *m = CkAllocSysMsg();
			envelope* env = UsrToEnv((CkMessage *)m);
			if(create){
				CkCreateLocalNodeGroup(gID, eIdx, env);
			}
		}
		TableEntry ent2 = CksvAccess(_nodeGroupTable)->find(gID);
		IrrGroup *obj = ent2.getObj();
		obj->pup(p);
		if(CkMyPe() == 3) CkPrintf("Nodegroup PUP'ed: gid = %d, name = %s\n",
			obj->ckGetGroupID().idx,
			_chareTable[ent2.getcIdx()]->name);
	}
	delete [] tmpInfo;
}
Ejemplo n.º 12
0
 virtual void pup(PUP::er &p, CpdListItemsRequest &req) {
   envelope *env = (envelope*)(((unsigned int)req.lo) + (((unsigned long)req.hi)<<32)+sizeof(CmiChunkHeader));
   beginItem(p, 0);
   const char *type="Converse";
   p.comment("name");
   char name[128];
   if (CmiGetHandler(env)==_charmHandlerIdx) {type="Local Charm";}
   if (CmiGetXHandler(env)==_charmHandlerIdx) {type="Network Charm";}
   sprintf(name,"%s 0: %s (%d)","Message",type,CmiGetHandler(env));
   p(name, strlen(name));
   p.comment("charmMsg");
   p.synchronize(PUP::sync_begin_object);
   CpdPupMessage(p, EnvToUsr(env));
   p.synchronize(PUP::sync_end_object);
 }
Ejemplo n.º 13
0
void BinaryTreeNode::pup(PUP::er &p, int depth) {
  //CkPrintf("Pupper of BinaryTreeNode(%d) called for %s (%d)\n",depth,p.isPacking()?"Packing":p.isUnpacking()?"Unpacking":"Sizing",p.isSizing()?((PUP::sizer*)&p)->size():((PUP::mem*)&p)->size());
  GenericTreeNode::pup(p);
  int isNull;
  for (int i=0; i<2; ++i) {
    isNull = (children[i]==NULL || depth==0) ? 0 : 1;
    p | isNull;
    CkAssert(isNull==0 || isNull==1);
    if (isNull != 0 && depth != 0) {
      if (p.isUnpacking()) children[i] = new BinaryTreeNode();
      children[i]->pup(p, depth-1);
      if (p.isUnpacking()) children[i]->parent = this;
    }
  }
};
Ejemplo n.º 14
0
 /// Pack-Unpack method.
 /// We pack/unpack the handle to the collide manager group.
 /// When unpacking, we register this element with the local branch
 /// of the collide manager group on the new PE.
 void pup(PUP::er &p)
 {
   ArrayElement1D::pup(p);
   p|collide;
   if (p.isUnpacking())
     CollideRegister(collide, thisIndex);
 }
Ejemplo n.º 15
0
/** Recursively packs/sizes entire subheap; DOES NOT UNPACK HEAP!!! */
void HeapNode::pup(PUP::er &p)
{
  CmiAssert(this != NULL);
  CmiAssert(!p.isUnpacking());
  e->pup(p);
  if (left) left->pup(p);
  if (right) right->pup(p);
}
Ejemplo n.º 16
0
void asf::parameter_float_image::pup(PUP::er &p) {
	parameter_pixel_image::pup(p);
	// Allocate pixel data (if needed)
	if (p.isUnpacking()) data_alloc(src_alloc,0,bands(),bands()*pixel().size_x());
	// Pup all pixel data (FIXME: speed up contiguous case?)
	ASF_FOR_PIXELS(x,y,pixels()) 
		p(&at(x,y,0),bands());
}
Ejemplo n.º 17
0
void NetFEM_update::pup(PUP::er &p) {
	int version=2; p(version);
	if (version>=2) p(source);
	p(timestep);
	p(dim);
	
	if (nodes==NULL) {
		if (!p.isUnpacking()) CmiAbort("You forgot to call NetFEM_Nodes!");
		else nodes=new NetFEM_nodes;
	}
	nodes->pup(p);
		
	p(nElems);
	for (int i=0;i<nElems;i++) {
		if (p.isUnpacking()) elems[i]=new NetFEM_elems;
		elems[i]->pup(p);
	}
}
Ejemplo n.º 18
0
/// PUP routine
void PVT::pup(PUP::er &p) {
  p|optPVT; p|conPVT; p|estGVT; p|repPVT;
  p|simdone; p|iterMin; p|waitForFirst;
  p|reportTo; p|reportsExpected; p|reportReduceTo; p|reportEnd;
  p|gvtTurn; p|specEventCount; p|eventCount;
  p|startPhaseActive; p|parStartTime; p|parCheckpointInProgress;
  p|parLastCheckpointGVT; p|parLastCheckpointTime;
  p|parLBInProgress; p|parLastLBGVT;
  p|optGVT; p|conGVT; p|rdone;

  if (p.isUnpacking()) {
    parStartTime = parLastCheckpointTime;
#ifndef CMK_OPTIMIZE
    localStats = (localStat *)CkLocalBranch(theLocalStats);
#endif
#ifdef MEM_TEMPORAL
    localTimePool = (TimePool *)CkLocalBranch(TempMemID);
#endif
    SendsAndRecvs = new SRtable();
  }

  SendsAndRecvs->pup(p);

  int nullFlag;
  if (SRs == NULL) {
    nullFlag = 1;
  } else {
    nullFlag = 0;
  }
  p|nullFlag;
  if (p.isUnpacking()) {
    if (nullFlag) {
      SRs = NULL;
    } else {
      SRs = new SRentry();
      SRs->pup(p);
    }
  } else {
    if (!nullFlag) {
      SRs->pup(p);
    }
  }
}
Ejemplo n.º 19
0
void LBDatabase::pup(PUP::er& p)
{ 
	IrrGroup::pup(p); 
	// the memory should be already allocated
	int np;
	if (!p.isUnpacking()) np = CkNumPes();
	p|np;
	CmiAssert(avail_vector);
	// in case number of processors changes
	if (p.isUnpacking() && np > CkNumPes()) {
		CmiLock(avail_vector_lock);
		delete [] avail_vector;
		avail_vector = new char[np];
		for (int i=0; i<np; i++) avail_vector[i] = 1;
		CmiUnlock(avail_vector_lock);
	}
	p(avail_vector, np);
	p|mystep;
	if(p.isUnpacking()) nloadbalancers = 0;
}
Ejemplo n.º 20
0
// handle chare array elements for this processor
void CkPupArrayElementsData(PUP::er &p, int notifyListeners)
{
 	int i;
	// safe in both packing/unpakcing at this stage
        int numGroups = CkpvAccess(_groupIDTable)->size();

	// number of array elements on this processor
	int numElements;
	if (!p.isUnpacking()) {
	  ElementCounter  counter;
	  CKLOCMGR_LOOP(mgr->iterate(counter););
Ejemplo n.º 21
0
void CentralLB::pup(PUP::er &p) { 
  BaseLB::pup(p); 
  if (p.isUnpacking())  {
    initLB(CkLBOptions(seqno)); 
  }
  p|reduction_started;
  int has_statsMsg=0;
  if (p.isPacking()) has_statsMsg = (statsMsg!=NULL);
  p|has_statsMsg;
  if (has_statsMsg) {
    if (p.isUnpacking())
      statsMsg = new CLBStatsMsg;
    statsMsg->pup(p);
  }
#if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
  p | lbDecisionCount;
  p | resumeCount;
#endif
	
}
Ejemplo n.º 22
0
void PipeBroadcastStrategy::pup(PUP::er &p){
  ComlibPrintf("[%d] PipeBroadcastStrategy::pup %s\n",CkMyPe(), (p.isPacking()==0)?(p.isUnpacking()?"UnPacking":"sizer"):("Packing"));
  PipeBroadcastConverse::pup(p);
  CharmStrategy::pup(p);

  /*
  if (p.isUnpacking()) {
    converseStrategy = new PipeBroadcastConverse(0,0,this);
  }
  p | *converseStrategy;

  if (p.isUnpacking()) {
    //propagateHandle = CmiRegisterHandler((CmiHandler)propagate_handler);

    ComlibPrintf("[%d] registered handler single to %d\n",CmiMyPe(),CsvAccess(pipeBcastPropagateHandle));
    messageBuf = new CkQ<CharmMessageHolder *>;
    converseStrategy->setHigherLevel(this);
  }
  */
}
Ejemplo n.º 23
0
void CkArrayReductionMgr::pup(PUP::er &p){
	NodeGroup::pup(p);
	p(redNo);p(count);
	p|my_msgs;
	p|my_futureMsgs;
	p|attachedGroup;
	if(p.isUnpacking()) {
	  size = CkMyNodeSize();
	  lockCount = CmiCreateLock();
	}
}
Ejemplo n.º 24
0
//! Pack/Unpack selected RNGs. This Pack/Unpack method (re-)creates the full RNG
//! stack since it needs to (re-)bind function pointers on different processing
//! elements. Therefore we circumvent Charm's usual pack/unpack for this type,
//! and thus sizing does not make sense: sizing is a no-op. We could initialize
//! the stack in RNGTestDriver's constructor and let this function re-create the
//! stack only when unpacking, but that leads to repeating the same code twice:
//! once in RNGTestDriver's constructor, once here. Another option is to use
//! this pack/unpack routine to both initially create (when packing) and to
//! re-create (when unpacking) the stack, which eliminates the need for
//! pre-creating the object in RNGTestDriver's constructor and therefore
//! eliminates the repeated code. This explains the guard for sizing: the code
//! below is called for packing only (in serial) and packing and unpacking (in
//! parallel).
inline
void operator|( PUP::er& p, std::map< tk::ctr::RawRNGType, tk::RNG >& rng ) {
  if (!p.isSizing()) {
    tk::RNGStack stack(
      #ifdef HAS_MKL
      g_inputdeck.get< tag::param, tag::rngmkl >(),
      #endif
      g_inputdeck.get< tag::param, tag::rngsse >() );
    rng = stack.selected( g_inputdeck.get< tag::selected, tag::rng >() );
  }
}
Ejemplo n.º 25
0
  void pup (PUP::er & p)
  {
    CBase_Minor::pup (p);
//        p|messages_due;
    p | iterations;
    p | useLB;
    if (p.isUnpacking ())
      arr = new float[1000];
    for (int i = 0; i < 1000; i++)
      p | arr[i];
/* There may be some more variables used in doWork */
  }
Ejemplo n.º 26
0
// Note that this is supposed to be used for migration.
// We should not hava a remote methos which has to pack the win data --- Inefficient
void
win_obj::pup(PUP::er &p) {
#if 0
    p|winSize;
    p|disp_unit;
    p|comm;
    p|initflag;

    int len = 0;
    if(winName) len = strlen(winName)+1;
    p|len;
    if(p.isUnpacking()) winName = new char[len+1];
    p(winName, len);

    int size = 0;
    if(baseAddr) size = winSize;
    p|size;
    if(p.isUnpacking()) baseAddr = new char[size+1];
    p(baseAddr, size);
#endif
}
Ejemplo n.º 27
0
void BaseLB::LDStats::pup(PUP::er &p)
{
  int i;
  p(count);
  p(n_objs);
  p(n_migrateobjs);
  p(n_comm);
  if (p.isUnpacking()) {
    // user can specify simulated processors other than the real # of procs.
    int maxpe = nprocs() > LBSimulation::simProcs ? nprocs() : LBSimulation::simProcs;
    procs = new ProcStats[maxpe];
    objData.resize(n_objs);
    commData.resize(n_comm);
    from_proc.resize(n_objs);
    to_proc.resize(n_objs);
    objHash = NULL;
  }
  // ignore the background load when unpacking if the user change the # of procs
  // otherwise load everything
  if (p.isUnpacking() && LBSimulation::procsChanged) {
    ProcStats dummy;
    for (i=0; i<nprocs(); i++) p|dummy;
  }
  else
    for (i=0; i<nprocs(); i++) p|procs[i];
  for (i=0; i<n_objs; i++) p|objData[i]; 
  for (i=0; i<n_objs; i++) p|from_proc[i]; 
  for (i=0; i<n_objs; i++) p|to_proc[i]; 
  // reset to_proc when unpacking
  if (p.isUnpacking())
    for (i=0; i<n_objs; i++) to_proc[i] = from_proc[i];
  for (i=0; i<n_comm; i++) p|commData[i];
  if (p.isUnpacking())
    count = LBSimulation::simProcs;
  if (p.isUnpacking()) {
    objHash = NULL;
    if (_lb_args.lbversion() <= 1) 
      for (i=0; i<nprocs(); i++) procs[i].pe = i;
  }
}
Ejemplo n.º 28
0
// handle plain non-migratable chare
void CkPupChareData(PUP::er &p)
{
  int i, n;
  if (!p.isUnpacking()) n = CkpvAccess(chare_objs).size();
  p|n;
  for (i=0; i<n; i++) {
        int chare_type;
	if (!p.isUnpacking()) {
		chare_type = CkpvAccess(chare_types)[i];
	}
	p | chare_type;
	if (p.isUnpacking()) {
		int migCtor = _chareTable[chare_type]->migCtor;
		if(migCtor==-1) {
			char buf[512];
			sprintf(buf,"Chare %s needs a migration constructor and PUP'er routine for restart.\n", _chareTable[chare_type]->name);
			CkAbort(buf);
		}
	        void *m = CkAllocSysMsg();
	        envelope* env = UsrToEnv((CkMessage *)m);
		CkCreateLocalChare(migCtor, env);
		CkFreeSysMsg(m);
	}
	Chare *obj = (Chare*)CkpvAccess(chare_objs)[i];
	obj->pup(p);
  }

  if (!p.isUnpacking()) n = CkpvAccess(vidblocks).size();
  p|n;
  for (i=0; i<n; i++) {
	VidBlock *v;
	if (p.isUnpacking()) {
		v = new VidBlock();
		CkpvAccess(vidblocks).push_back(v);
	}
	else
		v = CkpvAccess(vidblocks)[i];
	v->pup(p);
  }
}
Ejemplo n.º 29
0
  virtual void pup(PUP::er &p, CpdListItemsRequest &req) {
    int length;
    void ** messages;
    int curObj=0;
    void *msg;

    length = CdsFifo_Length((CdsFifo)(CpvAccess(conditionalQueue)));
    messages = CdsFifo_Enumerate(CpvAccess(conditionalQueue));
    for (curObj=-length; curObj<0; curObj++) {
      void *msg = messages[length+curObj];
      pupSingleMessage(p, curObj-1, msg);
    }
    delete[] messages;
    
    curObj = 0;
    length = CdsFifo_Length((CdsFifo)(CkpvAccess(debugQueue)));
    messages = CdsFifo_Enumerate(CkpvAccess(debugQueue));
    
    if (CkpvAccess(lastBreakPointMsg) != NULL) {
      beginItem(p, -1);
      envelope *env=(envelope *)UsrToEnv(CkpvAccess(lastBreakPointMsg));
      p.comment("name");
      char *type=(char*)"Breakpoint";
      p(type,strlen(type));
      p.comment("charmMsg");
      p.synchronize(PUP::sync_begin_object);
      CkUnpackMessage(&env);
      CpdPupMessage(p, EnvToUsr(env));
      p.synchronize(PUP::sync_end_object);
    }

    for(curObj=req.lo; curObj<req.hi; curObj++)
      if ((curObj>=0) && (curObj<length))
      {
        void *msg=messages[curObj]; /* converse message */
        pupSingleMessage(p, curObj, msg);
      }
    delete[] messages;

  }
Ejemplo n.º 30
0
/// Pack/unpack/sizing operator
void sim::pup(PUP::er &p) {
  // pup simple types
  p(active); p(myPVTidx); p(myLBidx); p(sync); p(DOs); p(UNDOs);
  // pup event queue
  if (p.isUnpacking()) {
    eq = new eventQueue();
  }
  eq->pup(p);
  // pup cancellations
  cancels.pup(p);
  if (p.isUnpacking()) { // reactivate migrated object
#if !CMK_TRACE_DISABLED
    localStats = (localStat *)CkLocalBranch(theLocalStats);
#endif
#ifndef SEQUENTIAL_POSE
    localPVT = (PVT *)CkLocalBranch(ThePVT);
    myPVTidx = localPVT->objRegister(thisIndex, localPVT->getGVT(), sync, this);
    if(pose_config.lb_on){
      localLBG = TheLBG.ckLocalBranch();
      myLBidx = localLBG->objRegister(thisIndex, sync, this);
    }
#endif
    active = 0;
  }
  PUParray(p, basicStats, 2);
  // pup checkpoint info for sequential mode using sim 0 only
#ifdef SEQUENTIAL_POSE
  if (thisIndex == 0) {
    p|seqCheckpointInProgress;
    p|seqLastCheckpointGVT;
    p|seqLastCheckpointTime;
    p|seqStartTime;
    p|POSE_Skipped_Events;
    p|poseIndexOfStopEvent;
    if (p.isUnpacking()) {
      seqStartTime = seqLastCheckpointTime;
    }
  }
#endif
}