/* called on PE 0 */ static void cpuAffinityHandler(void *m) { static int count = 0; static int nodecount = 0; hostnameMsg *rec; hostnameMsg *msg = (hostnameMsg *)m; hostnameMsg *tmpm; int tag, tag1, pe, myrank; int npes = CmiNumPes(); /* for debug char str[128]; skt_print_ip(str, msg->ip); printf("hostname: %d %s\n", msg->pe, str); */ CmiAssert(CmiMyPe()==0 && rankmsg != NULL); tag = *(int*)&msg->ip; pe = msg->pe; if ((rec = (hostnameMsg *)CmmProbe(hostTable, 1, &tag, &tag1)) != NULL) { CmiFree(msg); } else { rec = msg; rec->seq = nodecount; nodecount++; /* a new node record */ CmmPut(hostTable, 1, &tag, msg); } myrank = rec->rank%rec->ncores; while (in_exclude(myrank)) { /* skip excluded core */ myrank = (myrank+1)%rec->ncores; rec->rank ++; } rankmsg->ranks[pe] = myrank; /* core rank */ rankmsg->nodes[pe] = rec->seq; /* on which node */ rec->rank ++; count ++; if (count == CmiNumPes()) { /* CmiPrintf("Cpuaffinity> %d unique compute nodes detected! \n", CmmEntries(hostTable)); */ tag = CmmWildCard; while (tmpm = CmmGet(hostTable, 1, &tag, &tag1)) CmiFree(tmpm); CmmFree(hostTable); #if 1 /* bubble sort ranks on each node according to the PE number */ { int i,j; for (i=0; i<npes-1; i++) for(j=i+1; j<npes; j++) { if (rankmsg->nodes[i] == rankmsg->nodes[j] && rankmsg->ranks[i] > rankmsg->ranks[j]) { int tmp = rankmsg->ranks[i]; rankmsg->ranks[i] = rankmsg->ranks[j]; rankmsg->ranks[j] = tmp; } } } #endif CmiSyncBroadcastAllAndFree(sizeof(rankMsg)+CmiNumPes()*sizeof(int)*2, (void *)rankmsg); } }
static void CsmHandler(void *msg) { if ( CmiMyRank() ) NAMD_bug("Communicate CsmHandler on non-rank-zero pe"); // get start of user message int *m = (int *) ((char *)msg+CmiMsgHeaderSizeBytes); // sending node & tag act as tags CmmPut(CkpvAccess(CsmMessages), 2, m, msg); }
void MBlockChunk::recv(MBlockDataMsg *dm) { if(dm->seqnum == update.wait_seqnum) { DBG( "recv: handling ("<<dm->seqnum<<")" ) update_field(dm); // update the appropriate field value if(update.nRecd==nRecvPatches) { update.wait_seqnum = -1; //This update is complete thread->resume(); } } else if (dm->seqnum>seqnum) { DBG( "recv: stashing early ("<<dm->seqnum<<")" ) CmmPut(messages, 1, &(dm->seqnum), dm); } else CkAbort("MBLOCK MBlockChunk received message from the past!\n"); }