当前位置: 首页>>代码示例>>C++>>正文


C++ CmiAssert函数代码示例

本文整理汇总了C++中CmiAssert函数的典型用法代码示例。如果您正苦于以下问题:C++ CmiAssert函数的具体用法?C++ CmiAssert怎么用?C++ CmiAssert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CmiAssert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SendSpanningChildren

static void SendSpanningChildren(int size, char *msg, int rankToAssign, int startNode) {
#if CMK_BROADCAST_SPANNING_TREE
    int i, oldRank;
    char *newmsg;

    oldRank = CMI_DEST_RANK(msg);
    /* doing this is to avoid the multiple assignment in the following for loop */
    CMI_DEST_RANK(msg) = rankToAssign;
    /* first send msgs to other nodes */
    CmiAssert(startNode >=0 &&  startNode<CmiNumNodes());
    for (i=1; i<=BROADCAST_SPANNING_FACTOR; i++) {
        int nd = CmiMyNode()-startNode;
        if (nd<0) nd+=CmiNumNodes();
        nd = BROADCAST_SPANNING_FACTOR*nd + i;
        if (nd > CmiNumNodes() - 1) break;
        nd += startNode;
        nd = nd%CmiNumNodes();
        CmiAssert(nd>=0 && nd!=CmiMyNode());
#if CMK_BROADCAST_USE_CMIREFERENCE
        CmiReference(msg);
        CmiSendNetworkFunc(CmiNodeFirst(nd), size, msg, BCAST_SYNC);
#else
        newmsg = CopyMsg(msg, size);
        CmiSendNetworkFunc(CmiNodeFirst(nd), size, newmsg, BCAST_SYNC);
#endif
    }
    CMI_DEST_RANK(msg) = oldRank;
#endif
}
开发者ID:luyukunphy,项目名称:namd,代码行数:29,代码来源:machine-broadcast.c

示例2: FindNeighbors

void HbmLB::ReceiveStats(double t, int frompe, int fromlevel)
{
#if CMK_LBDB_ON
  FindNeighbors();

  int atlevel = fromlevel + 1;
  CmiAssert(tree->isroot(CkMyPe(), atlevel));

  DEBUGF(("[%d] ReceiveStats from PE %d from level: %d\n", CkMyPe(), frompe, fromlevel));
  int neighborIdx = NeighborIndex(frompe, atlevel);
  CmiAssert(neighborIdx==0 || neighborIdx==1);
  LevelData *lData = levelData[atlevel];
  lData->statsList[neighborIdx] = t;

  int &stats_msg_count = levelData[atlevel]->stats_msg_count;
  stats_msg_count ++;

  DEBUGF(("[%d] ReceiveStats at level: %d %d/%d\n", CkMyPe(), atlevel, stats_msg_count, levelData[atlevel]->nChildren));
  if (stats_msg_count == levelData[atlevel]->nChildren)  
  {
    stats_msg_count = 0;
    int parent = levelData[atlevel]->parent;

    // load balancing
    thisProxy[CkMyPe()].Loadbalancing(atlevel);
  }

#endif  
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:29,代码来源:HbmLB.C

示例3: setupSharedBuffers

void setupSharedBuffers(){
	int i=0;

        CmiAssert((sysvshmContext->recvbufnames=(int *)malloc(sizeof(int)*(sysvshmContext->nodesize)))!=NULL);
        CmiAssert((sysvshmContext->sendbufnames=(int *)malloc(sizeof(int)*(sysvshmContext->nodesize)))!=NULL);
	CmiAssert((sysvshmContext->semarray= (ushort *)malloc(sizeof(int)*(sysvshmContext->nodesize)))!=NULL);

		
	for(i=0;i<sysvshmContext->nodesize;i++){
		sysvshmContext->semarray[i]=1;
		if(i != sysvshmContext->noderank){
			sysvshmContext->sendbufnames[i]=SHMSNDNAME(i);
			sysvshmContext->recvbufnames[i]=SHMRCVNAME(i);
		}
	}
	
	createShmObjectsAndSems(&(sysvshmContext->recvBufs),sysvshmContext->recvbufnames,0);
	createShmObjectsAndSems(&(sysvshmContext->sendBufs),sysvshmContext->sendbufnames,1);

	for(i=0;i<sysvshmContext->nodesize;i++){
		if(i != sysvshmContext->noderank){
			CmiAssert(sysvshmContext->sendBufs[i].header->count == 0);
			sysvshmContext->sendBufs[i].header->count = 0;
			sysvshmContext->sendBufs[i].header->bytes = 0;
		}
	}
}
开发者ID:brog2610,项目名称:quinoa,代码行数:27,代码来源:machine-sysvshm.c

示例4: sanitize

/// Delete event and reconnect surrounding events in queue
void eventQueue::DeleteEvent(Event *ev) 
{
#ifdef EQ_SANITIZE
  sanitize();
#endif
  Event *tmp;
  CmiAssert(ev != currentPtr);
  CmiAssert(ev->spawnedList == NULL);
  CmiAssert(ev != frontPtr);
  CmiAssert(ev != backPtr);
  // if ev is earliest straggler, see if there is another
  if (RBevent == ev) {
    RBevent = NULL;
    tmp = ev->next;
    while ((tmp != currentPtr) && (tmp != backPtr) && (tmp->done == 1))
      tmp = tmp->next;
    if ((tmp != currentPtr) && (tmp != backPtr) && (tmp->done == 0))
      RBevent = tmp;
  }
  // connect surrounding events
  ev->prev->next = ev->next;
  ev->next->prev = ev->prev;
  POSE_TimeType ts = ev->timestamp;
  if (!ev->done) eventCount--;
  else mem_usage--;
  delete ev; // then delete the event
  if (ts == largest) FindLargest();
#ifdef EQ_SANITIZE
  sanitize();
#endif
}
开发者ID:quinoacomputing,项目名称:quinoa,代码行数:32,代码来源:evq.C

示例5: pidtonid

/** \function pidtonid
 *  finds nids for pids 1 to CmiNumPes and stores them in an array
 *  correspondingly also creates an array for nids to pids
 */
void pidtonid(int numpes) {
  CmiLock(cray_lock);
  if (pid2nid != NULL) {
      CmiUnlock(cray_lock);
      return;          /* did once already */
  }

  getDimension(&maxNID,&maxX,&maxY,&maxZ);
  int numCores = CmiNumCores();
  
  pid2nid = (int *)malloc(sizeof(int) * numpes);

#if XT4_TOPOLOGY || XT5_TOPOLOGY || XE6_TOPOLOGY
  int i, nid, ret;
  CmiAssert(rca_coords == NULL);
  rca_coords = (rca_mesh_coord_t *)malloc(sizeof(rca_mesh_coord_t)*(maxNID+1));
  for (i=0; i<maxNID; i++) {
    rca_coords[i].mesh_x = rca_coords[i].mesh_y = rca_coords[i].mesh_z = -1;
  }
  for (i=0; i<numpes; i++) {
    PMI_Get_nid(CmiGetNodeGlobal(CmiNodeOf(i),CmiMyPartition()), &nid);
    pid2nid[i] = nid;
    CmiAssert(nid < maxNID);
    ret = rca_get_meshcoord(nid, &rca_coords[nid]);
    CmiAssert(ret != -1);
  }
#endif
  CmiUnlock(cray_lock);
}
开发者ID:quinoacomputing,项目名称:quinoa,代码行数:33,代码来源:CrayNid.c

示例6: pushSendQ

void pushSendQ(SysvshmSendQ *q,OutgoingMsg msg){
	if(q->numEntries == q->size){
		/* need to resize */
		OutgoingMsg *oldData = q->data;
		int newSize = q->size<<1;
		q->data = (OutgoingMsg *)malloc(sizeof(OutgoingMsg)*newSize);
		/* copy head to the beginning of the new array */
		
		CmiAssert(q->begin == q->end);

		CmiAssert(q->begin < q->size);
		memcpy(&(q->data[0]),&(oldData[q->begin]),sizeof(OutgoingMsg)*(q->size - q->begin));

		if(q->end != 0){
			memcpy(&(q->data[(q->size - q->begin)]),&(oldData[0]),sizeof(OutgoingMsg)*(q->end));
		}
		free(oldData);
		q->begin = 0;
		q->end = q->size;
		q->size = newSize;
	}
	q->data[q->end] = msg;
	(q->end)++;
	if(q->end >= q->size){
		q->end -= q->size;
	}
	q->numEntries++;
}
开发者ID:brog2610,项目名称:quinoa,代码行数:28,代码来源:machine-sysvshm.c

示例7: sendResults

void ProxyPatch::boxClosed(int box) {
 
  if (box == 1) { // force Box
    // Note: delay the deletion of proxyDataMsg (of the 
    // current step) until the next step. This is done 
    // for the sake of atom migration (ProxyDataMsg) 
    // as the ProxyPatch has to  unregister the atoms 
    // of the previous step in the AtomMap data structure 
    // also denotes end of gbis phase 3
    sendResults();
  } else if ( box == 5) {//end phase 1
  } else if ( box == 8) {//end phase 2
  } else if (box == 9) {
    //nothing
  } else if (box == 10) {
    // LCPO do nothing
  }


  if ( ! --boxesOpen ) {
    DebugM(2,patchID << ": " << "Checking message buffer.\n");    
    
    if(proxyMsgBufferStatus == PROXYALLMSGBUFFERED) {
          CmiAssert(curProxyMsg != NULL);
          DebugM(3,"Patch " << patchID << " processing buffered proxy ALL data.\n");
          receiveAll(curProxyMsg);          
    }else if(proxyMsgBufferStatus == PROXYDATAMSGBUFFERED) {
          CmiAssert(curProxyMsg != NULL);
          DebugM(3,"Patch " << patchID << " processing buffered proxy data.\n");
          receiveData(curProxyMsg);
    }
  } else {
       DebugM(3,"ProxyPatch " << patchID << ": " << boxesOpen << " boxes left to close.\n");
  }
}
开发者ID:sunhwan,项目名称:NAMD-mini,代码行数:35,代码来源:ProxyPatch.C

示例8: createShmObject

void createShmObject(char *name,int size,char **pPtr){
	int fd=-1;
	int flags;	// opening flags for shared object
	int open_repeat_count = 0;

	flags= O_RDWR | O_CREAT; // open file in read-write mode and create it if its not there
	
	while(fd<0 && open_repeat_count < 100){
	  open_repeat_count++;
	  fd = shm_open(name,flags, S_IRUSR | S_IWUSR); // create the shared object with permissions for only the user to read and write
	  
	  if(fd < 0 && open_repeat_count > 10){
	    fprintf(stderr,"Error(attempt=%d) from shm_open %s while opening %s \n",open_repeat_count, strerror(errno),name);
	    fflush(stderr);
	  }
	}

	CmiAssert(fd >= 0);

	ftruncate(fd,size); //set the size of the shared memory object

	*pPtr = mmap(NULL,size,PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 
	CmiAssert(*pPtr != NULL);

	close(fd);
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:26,代码来源:machine-pxshm.c

示例9: CmiAssert

/** 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);
}
开发者ID:davidheryanto,项目名称:sc14,代码行数:9,代码来源:eqheap.C

示例10: sendResults

void ProxyPatch::boxClosed(int box) {
	ProxyGBISP1ResultMsg *msg1;
	ProxyGBISP2ResultMsg *msg2;

	if (box == 1) { // force Box
		// Note: delay the deletion of proxyDataMsg (of the
		// current step) until the next step. This is done
		// for the sake of atom migration (ProxyDataMsg)
		// as the ProxyPatch has to  unregister the atoms
		// of the previous step in the AtomMap data structure
		// also denotes end of gbis phase 3
		sendResults();
	} else if (box == 5) {    //end phase 1
		//this msg should only have nonzero atoms if flags.doNonbonded
		int msgAtoms = (flags.doNonbonded) ? numAtoms : 0;
		msg1 = new (msgAtoms, PRIORITY_SIZE) ProxyGBISP1ResultMsg;
		for (int i = 0; i < msgAtoms; i++) {
			msg1->psiSum[i] = psiSum[i];
		}
		msg1->patch = patchID;
		msg1->psiSumLen = msgAtoms;
		msg1->origPe = CkMyPe();
		SET_PRIORITY(msg1, flags.sequence, GB1_PROXY_RESULTS_PRIORITY + PATCH_PRIORITY(patchID));
		ProxyMgr::Object()->sendResult(msg1);
	} else if (box == 8) {    //end phase 2
		//this msg should only have nonzero atoms if flags.doFullElectrostatics
		int msgAtoms = (flags.doFullElectrostatics) ? numAtoms : 0;
		msg2 = new (msgAtoms, PRIORITY_SIZE) ProxyGBISP2ResultMsg;
		for (int i = 0; i < msgAtoms; i++) {
			msg2->dEdaSum[i] = dEdaSum[i];
		}
		msg2->patch = patchID;
		msg2->dEdaSumLen = msgAtoms;
		msg2->origPe = CkMyPe();
		SET_PRIORITY(msg2, flags.sequence, GB2_PROXY_RESULTS_PRIORITY + PATCH_PRIORITY(patchID));
		ProxyMgr::Object()->sendResult(msg2);
	} else if (box == 9) {
		//nothing
	} else if (box == 10) {
		// LCPO do nothing
	}

	if (!--boxesOpen) {
		DebugM(2, patchID << ": " << "Checking message buffer.\n");

		if (proxyMsgBufferStatus == PROXYALLMSGBUFFERED) {
			CmiAssert(curProxyMsg != NULL);
			DebugM(3, "Patch " << patchID << " processing buffered proxy ALL data.\n");
			receiveAll(curProxyMsg);
		} else if (proxyMsgBufferStatus == PROXYDATAMSGBUFFERED) {
			CmiAssert(curProxyMsg != NULL);
			DebugM(3, "Patch " << patchID << " processing buffered proxy data.\n");
			receiveData(curProxyMsg);
		}
	} else {
		DebugM(3, "ProxyPatch " << patchID << ": " << boxesOpen << " boxes left to close.\n");
	}
}
开发者ID:luyukunphy,项目名称:namd,代码行数:58,代码来源:ProxyPatch.C

示例11: CmiSendMessageSysvshm

void CmiSendMessageSysvshm(OutgoingMsg ogm,OtherNode node,int rank,unsigned int broot){
	struct sembuf sb;
	
#if SYSVSHM_STATS
	double _startSendTime = CmiWallTimer();
#endif

	
	int dstRank = SysvshmRank(ogm->dst);
	MEMDEBUG(CmiMemoryCheck());
  
	DgramHeaderMake(ogm->data,rank,ogm->src,Cmi_charmrun_pid,1, broot);
	
  
	MACHSTATE4(3,"Send Msg Sysvshm ogm %p size %d dst %d dstRank %d",ogm,ogm->size,ogm->dst,dstRank);

	CmiAssert(dstRank >=0 && dstRank != sysvshmContext->noderank);
	
	sharedBufData *dstBuf = &(sysvshmContext->sendBufs[dstRank]);

	ACQUIRENW(sysvshmContext->noderank);
	if(semop(dstBuf->semid, &sb, 1)<0) {
		/**failed to get the lock 
		insert into q and retain the message*/

		pushSendQ(sysvshmContext->sendQs[dstRank],ogm);
		ogm->refcount++;
		MEMDEBUG(CmiMemoryCheck());
		return;
	}else{
		/***
		 * We got the lock for this buffer
		 * first write all the messages in the sendQ and then write this guy
		 * */
		 if(sysvshmContext->sendQs[dstRank]->numEntries == 0){
				/* send message user event */
				int ret = sendMessage(ogm,dstBuf,sysvshmContext->sendQs[dstRank]);
				MACHSTATE(3,"Sysvshm Send succeeded immediately");
		 }else{
				ogm->refcount+=2;/*this message should not get deleted when the queue is flushed*/
			 	pushSendQ(sysvshmContext->sendQs[dstRank],ogm);
				MACHSTATE3(3,"Sysvshm ogm %p pushed to sendQ length %d refcount %d",ogm,sysvshmContext->sendQs[dstRank]->numEntries,ogm->refcount);
				int sent = flushSendQ(dstRank);
				ogm->refcount--; /*if it has been sent, can be deleted by caller, if not will be deleted when queue is flushed*/
				MACHSTATE1(3,"Sysvshm flushSendQ sent %d messages",sent);
		 }
		 /* unlock the recvbuffer*/
		RELEASE(sysvshmContext->noderank);
		CmiAssert(semop(dstBuf->semid, &sb, 1)>=0);
	}
#if SYSVSHM_STATS
		sysvshmContext->sendCount ++;
		sysvshmContext->sendTime += (CmiWallTimer()-_startSendTime);
#endif
	MEMDEBUG(CmiMemoryCheck());

};
开发者ID:brog2610,项目名称:quinoa,代码行数:57,代码来源:machine-sysvshm.c

示例12: Tcl_SetResult

int ScriptTcl::Tcl_replicaAtomSendrecv(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) {
  ScriptTcl *script = (ScriptTcl *)clientData;
  script->initcheck();
  if ( ! Node::Object()->simParameters->replicaUniformPatchGrids ) {
    Tcl_SetResult(interp,"replicaUniformPatchGrids is required for atom exchange",TCL_VOLATILE);
    return TCL_ERROR;
  }
  if ( argc < 2 || argc > 3 ) {
    Tcl_SetResult(interp,"bad arg count; args: dest ?source?",TCL_VOLATILE);
    return TCL_ERROR;
  }
  int dest = -1;
  if ( sscanf(argv[1], "%d", &dest) != 1 ) {
    Tcl_SetResult(interp,"bad dest; args: dest ?source?",TCL_VOLATILE);
    return TCL_ERROR;
  }
  int source = -1;
  if ( argc == 3 ) {
    if ( sscanf(argv[2], "%d", &source) != 1 ) {
      Tcl_SetResult(interp,"bad source; args: dest ?source?",TCL_VOLATILE);
      return TCL_ERROR;
    }
  }

#if CMK_HAS_PARTITION
  if (dest != CmiMyPartition()) {
    DataMessage *recvMsg = NULL;
    replica_sendRecv((char*)&(script->state->lattice), sizeof(Lattice), dest, CkMyPe(), &recvMsg, source, CkMyPe());
    CmiAssert(recvMsg != NULL);
    memcpy(&(script->state->lattice), recvMsg->data, recvMsg->size);
    CmiFree(recvMsg);
  }
#endif

  char str[40];
  sprintf(str, "%d", dest);
  script->setParameter("scriptArg1", str);
  sprintf(str, "%d", source);
  script->setParameter("scriptArg2", str);

  CkpvAccess(_qd)->create(2 * PatchMap::Object()->numPatches());

  script->runController(SCRIPT_ATOMSENDRECV);

#if CMK_HAS_PARTITION
  if (dest != CmiMyPartition()) {
    DataMessage *recvMsg = NULL;
    ControllerState *cstate = script->state->controller;
    replica_sendRecv((char*)cstate, sizeof(ControllerState), dest, CkMyPe(), &recvMsg, source, CkMyPe());
    CmiAssert(recvMsg != NULL);
    memcpy(cstate, recvMsg->data, recvMsg->size);
    CmiFree(recvMsg);
  }
#endif

  return TCL_OK;
}
开发者ID:sunhwan,项目名称:NAMD-mini,代码行数:57,代码来源:ScriptTcl.C

示例13: CmiAssert

// return the seq-th load balancer string name of
// it can be specified in either compile time or runtime
// runtime has higher priority
const char *LBDatabase::loadbalancer(int seq) {
  if (lbRegistry.runtime_lbs.length()) {
    CmiAssert(seq < lbRegistry.runtime_lbs.length());
    return lbRegistry.runtime_lbs[seq];
  }
  else {
    CmiAssert(seq < lbRegistry.compile_lbs.length());
    return lbRegistry.compile_lbs[seq];
  }
}
开发者ID:davidheryanto,项目名称:sc14,代码行数:13,代码来源:LBDatabase.C

示例14: DEBUGF

// migration done at current lbLevel
void HbmLB::MigrationDone(int balancing)
{
#if CMK_LBDB_ON
  int i, j;
  LevelData *lData = levelData[0];

  DEBUGF(("[%d] HbmLB::MigrationDone lbLevel:%d numLevels:%d!\n", CkMyPe(), lbLevel, tree->numLevels()));

  CmiAssert(newObjs.size() == lData->migrates_expected);

#if 0
  if (lbLevel == tree->numLevels()-1) {
    theLbdb->incStep();
    // reset 
    lData->clear();
  }
  else {
    lData->migrates_expected = -1;
    lData->migrates_completed = 0;
    lData->obj_completed = 0;
  }
#else
  lData->migrates_expected = -1;
  lData->migrates_completed = 0;
  lData->obj_completed = 0;
#endif

  CkVec<LDObjData> &oData = myStats.objData;

  // update
  int count=0;
  for (i=0; i<oData.size(); i++)
    if (oData[i].handle.handle == -100) count++;
  CmiAssert(count == newObjs.size());

  for (i=0; i<oData.size(); i++) {
    if (oData[i].handle.handle == -100) {
      LDObjHandle &handle = oData[i].handle;
      for (j=0; j<newObjs.size(); j++) {
        if (handle.omID() == newObjs[j].omID() && 
                  handle.objID() == newObjs[j].objID()) {
          handle = newObjs[j];
          break;
        }
      }
      CmiAssert(j<newObjs.size());
    }
  }
  newObjs.free();

  thisProxy[lData->parent].NotifyObjectMigrationDone(0, lbLevel);
#endif
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:54,代码来源:HbmLB.C

示例15: fopen

void ComputeMap::loadComputeMap(const char *fname)
{
  FILE *fp = fopen(fname, "r");
  CmiAssert(fp != NULL);
  int n;
  fscanf(fp, "%d\n", &n);
  CmiAssert(n == nComputes);
  for(int i=0; i < nComputes; i++)
  {
    fscanf(fp, "%d\n", &computeData[i].node);
  }
  fclose(fp);
}
开发者ID:luyukunphy,项目名称:namd,代码行数:13,代码来源:ComputeMap.C


注:本文中的CmiAssert函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。