コード例 #1
0
ファイル: machine-broadcast.c プロジェクト: luyukunphy/namd
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
}
コード例 #2
0
ファイル: HbmLB.C プロジェクト: gitter-badger/quinoa
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  
}
コード例 #3
0
ファイル: machine-sysvshm.c プロジェクト: brog2610/quinoa
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;
		}
	}
}
コード例 #4
0
ファイル: evq.C プロジェクト: quinoacomputing/quinoa
/// 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
}
コード例 #5
0
ファイル: CrayNid.c プロジェクト: quinoacomputing/quinoa
/** \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);
}
コード例 #6
0
ファイル: machine-sysvshm.c プロジェクト: brog2610/quinoa
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++;
}
コード例 #7
0
ファイル: ProxyPatch.C プロジェクト: sunhwan/NAMD-mini
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");
  }
}
コード例 #8
0
ファイル: machine-pxshm.c プロジェクト: gitter-badger/quinoa
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);
}
コード例 #9
0
ファイル: eqheap.C プロジェクト: davidheryanto/sc14
/** 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);
}
コード例 #10
0
ファイル: ProxyPatch.C プロジェクト: luyukunphy/namd
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");
	}
}
コード例 #11
0
ファイル: machine-sysvshm.c プロジェクト: brog2610/quinoa
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());

};
コード例 #12
0
ファイル: ScriptTcl.C プロジェクト: sunhwan/NAMD-mini
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;
}
コード例 #13
0
ファイル: LBDatabase.C プロジェクト: davidheryanto/sc14
// 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];
  }
}
コード例 #14
0
ファイル: HbmLB.C プロジェクト: gitter-badger/quinoa
// 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
}
コード例 #15
0
ファイル: ComputeMap.C プロジェクト: luyukunphy/namd
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);
}
コード例 #16
0
ファイル: eqheap.C プロジェクト: davidheryanto/sc14
/// Remove heap node matching evID
int HeapNode::remove(eventID evID, POSE_TimeType timestamp)
{
#ifdef EH_SANITIZE
    sanitize();
#endif
  CmiAssert(this != NULL);
  CmiAssert(!(this->e->evID == evID));
  int found = 0; // return status
  HeapNode *tmp;
  if (left) { // search left subheap first
    if (timestamp < left->e->timestamp) found = 0; // subheap elements too high
    else if ((timestamp == left->e->timestamp) && (evID == left->e->evID)) {
      // found element on top
      tmp = left; // save a pointer to it
      if (left->left)
	left = left->left->conjoin(left->right); // remove it from heap
      else left = left->right;
      subheapsize--;
      tmp->left = tmp->right = NULL; // foil recursive destructor
      delete tmp; // delete it
      found = 1;
    }
    else if (timestamp >= left->e->timestamp) { // need to look deeper
      found = left->remove(evID, timestamp);
      if (found) subheapsize--; // must decrement heap size
    }
  }
  if (found) return 1; // found in left subheap; exit with status 1
  else if (right) { // search in right subheap
    if (timestamp < right->e->timestamp) found = 0; //subheap elements too high
    else if ((timestamp == right->e->timestamp) && (evID == right->e->evID)) {
      // found element on top
      tmp = right; // save a pointer to it
      if (right->left)
	right = right->left->conjoin(right->right); // remove it from heap
      else right = right->right;
      subheapsize--;                 
      tmp->left = tmp->right = NULL; // foil recursive destructor
      delete tmp; // delete it
      found = 1; 
    }
    else if (timestamp >= right->e->timestamp) { // need to look deeper
      found = right->remove(evID, timestamp); // set return status
      if (found) subheapsize--; // must decrement heap size
    }
  }
#ifdef EH_SANITIZE
    sanitize();
#endif
  return found; // exit with found status
}
コード例 #17
0
ファイル: BaseLB.C プロジェクト: luyukunphy/namd
// remove the obj-th object from database
void BaseLB::LDStats::removeObject(int obj)
{
  CmiAssert(obj < objData.size());
  LDObjData odata = objData[obj];

  LDObjKey okey;		// build a key
  okey.omID() = odata.omID();
  okey.objID() = odata.objID();

  objData.remove(obj);
  from_proc.remove(obj);
  to_proc.remove(obj);
  n_objs --;
  if (odata.migratable) n_migrateobjs --;

  // search for sender, can be multiple sender
  int removed = 0;
  for (int com=0; com<n_comm; com++) {
    LDCommData &cdata = commData[com-removed];
    if(!cdata.from_proc() && cdata.sender == okey) {
      commData.remove(com-removed);
      removed++;
    }
  }
  n_comm -= removed;
}
コード例 #18
0
ファイル: PmeKSpace.C プロジェクト: wware/namd-povray-cloud
static inline void compute_energy_orthogonal_ckloop(int first, int last, void *result, int paraNum, void *param){
    CmiAssert(first==last);
    void **params = (void **)param;
    PmeKSpace *kspace = (PmeKSpace *)params[0];
    float *q_arr = (float *)params[1];
    double *recips = (double *)params[2];
    double *partialEnergy = (double *)params[3];
    double *partialVirial = (double *)params[4];
    int *unitDist = (int *)params[5];
    
    int i = first;
    int unit = unitDist[0];
    int remains = unitDist[1];
    int k1from, k1to;
    if(i<remains){
        k1from = i*(unit+1);
        k1to = k1from+unit;
    }else{
        k1from = remains*(unit+1)+(i-remains)*unit;
        k1to = k1from+unit-1;
    }
    double *pEnergy = partialEnergy+i;
    double *pVirial = partialVirial+i*6;
    kspace->compute_energy_orthogonal_subset(q_arr, recips, pVirial, pEnergy, k1from, k1to);
}
コード例 #19
0
ファイル: machine.c プロジェクト: davidheryanto/sc14
CmiCommHandle CmiAsyncBroadcastFn(int size, char *msg) {
#if ENSURE_MSG_PAIRORDER
    /* Not sure how to add the msg seq no for async broadcast messages --Chao Mei */
    /* so abort here ! */
    CmiAssert(0);
    return 0;
#else
    int i, rank;
    int mype = CmiMyPe();
#if ENABLE_CONVERSE_QD
    CQdCreate(CpvAccess(cQdState), CmiNumPes()-1);
#endif
    MACHSTATE1(3,"[%d] Sending async broadcast message from {",CmiMyNode());
    CMI_BROADCAST_ROOT(msg) = 0;
    void *handle = malloc(sizeof(int));
    *((int *)handle) = CmiNumPes()-1;

    for (i=mype+1; i<CmiNumPes(); i++) {
        CMI_DEST_RANK(msg) = CmiRankOf(i);
        lapiSendFn(CmiNodeOf(i), size, msg, DeliveredMsg, handle);
    }
    for (i=0; i<mype; i++) {
        CMI_DEST_RANK(msg) = CmiRankOf(i);
        lapiSendFn(CmiNodeOf(i), size, msg, DeliveredMsg, handle);
    }

    MACHSTATE(3,"} Sending async broadcast message end");
    return handle;
#endif
}
コード例 #20
0
ファイル: hello.C プロジェクト: davidheryanto/sc14
  void SayHi(HiMsg *m)
  {
    redNo ++;
    CmiAssert(m->data[0] == 22 && m->data[1] == 28);

    CkGetSectionInfo(sid, m);

    CkMulticastMgr *mg = CProxy_CkMulticastMgr(mCastGrpId).ckLocalBranch();
    int dataSize = (int)(CompleteMsgSize);
    int* data = new int [dataSize];
    int fragSize = dataSize/NumFrags;
    CkAssert (0 != fragSize);
    for (int i=0; i<dataSize; i++) {
      data [i] = thisIndex;
    }
    CkCallback cb(CkIndex_Hello::cb_client(NULL), CkArrayIndex1D(0), thisProxy);
    mg->contribute(dataSize*sizeof(int), data,CkReduction::sum_int, sid, cb, fragSize*sizeof(int));
//    data[0] = thisIndex+2;
//    data[1] = thisIndex+2;
//    mg->contribute(2*sizeof(int), &data,CkReduction::max_int, sid, sizeof(int));
//    data[0] = thisIndex+1;
//    data[1] = thisIndex+1;
//    mg->contribute(2*sizeof(int), &data,CkReduction::product_int, sid, sizeof(int));
    delete m;
    if (1)
      ckMigrate((CkMyPe()+1)%CkNumPes());
  }
コード例 #21
0
ファイル: trace-bluegene.C プロジェクト: luyukunphy/namd
void TraceBluegene::beginExecute(envelope *e)
{
  if (e==NULL || !genTimeLog) return;
  BgTimeLog* log = tTIMELINE[tTIMELINE.length()-1];
  CmiAssert(log!=NULL);
  log->setCharmEP(e->getEpIdx());
}
コード例 #22
0
ファイル: machine-sysvshm.c プロジェクト: brog2610/quinoa
void static inline handoverSysvshmMessage(char *newmsg,int total_size,int rank,int broot){
	CmiAssert(rank == 0);
#if CMK_BROADCAST_SPANNING_TREE
        if (rank == DGRAM_BROADCAST
#if CMK_NODE_QUEUE_AVAILABLE
          || rank == DGRAM_NODEBROADCAST
#endif
         ){
          	SendSpanningChildren(NULL, 0, total_size, newmsg,broot,rank);
					}
#elif CMK_BROADCAST_HYPERCUBE
        if (rank == DGRAM_BROADCAST
#if CMK_NODE_QUEUE_AVAILABLE
          || rank == DGRAM_NODEBROADCAST
#endif
         ){
          		SendHypercube(NULL, 0, total_size, newmsg,broot,rank);
					}
#endif

		switch (rank) {
    	case DGRAM_BROADCAST: {
          CmiPushPE(0, newmsg);
          break;
      }
        default:
				{
					
          CmiPushPE(rank, newmsg);
				}
  	}    /* end of switch */
}
コード例 #23
0
ファイル: machine-sysvshm.c プロジェクト: brog2610/quinoa
void emptyRecvBuf(sharedBufData *recvBuf){
 	int numMessages = recvBuf->header->count;
	int i=0;

	char *ptr=recvBuf->data;

	for(i=0;i<numMessages;i++){
		int size;
		int rank, srcpe, seqno, magic, i;
		unsigned int broot;
		char *msg = ptr;
		char *newMsg;

		DgramHeaderBreak(msg, rank, srcpe, magic, seqno, broot);
		size = CmiMsgHeaderGetLength(msg);
	
		newMsg = (char *)CmiAlloc(size);
		memcpy(newMsg,msg,size);

		handoverSysvshmMessage(newMsg,size,rank,broot);
		
		ptr += size;

		MACHSTATE3(3,"message of size %d recvd ends at ptr-data %d total bytes %d bytes %d",size,ptr-recvBuf->data,recvBuf->header->bytes);
	}
	CmiAssert(ptr - recvBuf->data == recvBuf->header->bytes);
	recvBuf->header->count=0;
	recvBuf->header->bytes=0;
}
コード例 #24
0
ファイル: machine-sysvshm.c プロジェクト: brog2610/quinoa
inline void emptyAllRecvBufs(){
	struct sembuf sb;
	int i;
	int j,ret;
	union semun {
	int val;
	struct semid_ds *buf;
	ushort array[1];
	} arg;
	for(i=0;i<sysvshmContext->nodesize;i++){
		if(i != sysvshmContext->noderank){
			sharedBufData *recvBuf = &(sysvshmContext->recvBufs[i]);
			if(recvBuf->header->count > 0){

#if SYSVSHM_STATS
				sysvshmContext->lockRecvCount++;
#endif

				ACQUIRE(i);
				if(semop(recvBuf->semid, &sb, 1)>=0) {
					MACHSTATE1(3,"emptyRecvBuf to be called for rank %d",i);
					emptyRecvBuf(recvBuf);
					RELEASE(i);
					CmiAssert((semop(recvBuf->semid, &sb, 1))>=0);
				}

			}
		}
	}
};
コード例 #25
0
ファイル: trace-bluegene.C プロジェクト: luyukunphy/namd
void TraceBluegene::addBackwardDep(void *log)
{
  if(!genTimeLog || log==NULL) return;
  BgTimeLog  *parentLogPtr = BgLastLog(tTIMELINEREC);
  CmiAssert(parentLogPtr);
  BgAddBackwardDep(parentLogPtr, (BgTimeLog*)log);
}
コード例 #26
0
ファイル: CentralLB.C プロジェクト: luyukunphy/namd
// called on every processor
void CentralLB::SendStats()
{
#if CMK_LBDB_ON
  CmiAssert(statsMsg != NULL);
  reduction_started = 0;

#if USE_LDB_SPANNING_TREE
  if(CkNumPes()>1024)
  {
    if (CkMyPe() == cur_ld_balancer)
      thisProxy[CkMyPe()].ReceiveStats(statsMsg);
    else
      thisProxy[CkMyPe()].ReceiveStatsViaTree(statsMsg);
  }
  else
#endif
  {
    DEBUGF(("[%d] calling ReceiveStats on step %d \n",CmiMyPe(),step()));
    thisProxy[cur_ld_balancer].ReceiveStats(statsMsg);
  }

  statsMsg = NULL;

#ifdef __BIGSIM__
  BgEndStreaming();
#endif

  {
  // enfore the barrier to wait until centralLB says no
  LDOMHandle h;
  h.id.id.idx = 0;
  theLbdb->getLBDB()->RegisteringObjects(h);
  }
#endif
}
コード例 #27
0
ファイル: CentralLB.C プロジェクト: luyukunphy/namd
void CentralLB::ProcessAtSync()
{
#if CMK_LBDB_ON
  if (reduction_started) return;              // reducton in progress

  CmiAssert(CmiNodeAlive(CkMyPe()));
  if (CkMyPe() == cur_ld_balancer) {
    start_lb_time = CkWallTimer();
  }

#if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
	initMlogLBStep(thisgroup);
#endif

  // build message
  BuildStatsMsg();

#if USE_REDUCTION
    // reduction to get total number of objects and comm
    // so that processor 0 can pre-allocate load balancing database
  int counts[2];
  counts[0] = theLbdb->GetObjDataSz();
  counts[1] = theLbdb->GetCommDataSz();

  CkCallback cb(CkIndex_CentralLB::ReceiveCounts((CkReductionMsg*)NULL), 
                  thisProxy[0]);
  contribute(2*sizeof(int), counts, CkReduction::sum_int, cb);
  reduction_started = 1;
#else
  SendStats();
#endif
#endif
}
コード例 #28
0
ファイル: evq.C プロジェクト: quinoacomputing/quinoa
/// Change currentPtr to point to event e
void eventQueue::SetCurrentPtr(Event *e) { 
  Event *tmp = e;
  // Check possible error conditions
  CmiAssert((e->done == 0) || (e->done == -1)); // e is not done or a sentinel
  CmiAssert(currentPtr->done != 2);
  currentPtr = e; // move currentPtr to e
  if ((currentPtr == backPtr) && (eqh->top)) { // moved currentPtr to backPtr
    // get next event from heap and put it in the queue
    tmp = eqh->GetAndRemoveTopEvent();
    tmp->next = currentPtr;
    tmp->prev = currentPtr->prev;
    currentPtr->prev->next = tmp;
    currentPtr->prev = tmp;
    currentPtr = tmp;
  }
}
コード例 #29
0
ファイル: BGQTorus.C プロジェクト: varunbhatia16/DIC_project
void BGQTorusManager::populateLocalNodes() {
  if(CmiNumPartitions() == 1) return;

  CmiLock(bgq_lock);
  if(bgq_isLocalSet) {
    CmiUnlock(bgq_lock);
    return;
  }

  if(bgq_localNodes == NULL)
    bgq_localNodes = (int *)malloc(CmiNumNodesGlobal()*sizeof(int));

  CmiAssert(bgq_localNodes != NULL);

  for(int i = 0; i < CmiNumNodesGlobal(); i++)
    bgq_localNodes[i] = -1;

  for(int i = 0; i < CmiNumNodes(); i++) {
    int a, b, c, d, e, t;
    int global;

    rankToCoordinates(CmiNodeFirst(i), a, b, c, d, e, t);
    global = CmiNodeOf(coordinatesToRank(a, b, c, d, e, t));

    bgq_localNodes[global] = i;
  }

  bgq_isLocalSet = 1;

  CmiUnlock(bgq_lock);
}
コード例 #30
0
ファイル: init.C プロジェクト: gitter-badger/quinoa
void _CkExit(void) 
{
  CmiAssert(CkMyPe() == 0);
  // Shuts down Converse handlers for the upper layers on this processor
  //
  CkNumberHandler(_charmHandlerIdx,(CmiHandler)_discardHandler);
  CkNumberHandler(_bocHandlerIdx, (CmiHandler)_discardHandler);
  DEBUGF(("[%d] CkExit - _exitStarted:%d %d\n", CkMyPe(), _exitStarted, _exitHandlerIdx));

  if(CkMyPe()==0) {
    if(_exitStarted)
      CsdScheduler(-1);
    envelope *env = _allocEnv(ReqStatMsg);
    env->setSrcPe(CkMyPe());
    CmiSetHandler(env, _exitHandlerIdx);
		/*FAULT_EVAC*/
    CmiSyncBroadcastAllAndFree(env->getTotalsize(), (char *)env);
  } else {
    envelope *env = _allocEnv(ExitMsg);
    env->setSrcPe(CkMyPe());
    CmiSetHandler(env, _exitHandlerIdx);
    CmiSyncSendAndFree(0, env->getTotalsize(), (char *)env);
  }
#if ! CMK_BIGSIM_THREAD
  _TRACE_END_EXECUTE();
  //Wait for stats, which will call ConverseExit when finished:
  CsdScheduler(-1);
#endif
}