本文整理汇总了C++中CmiMyPe函数的典型用法代码示例。如果您正苦于以下问题:C++ CmiMyPe函数的具体用法?C++ CmiMyPe怎么用?C++ CmiMyPe使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CmiMyPe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_thread_affinity
int print_thread_affinity() {
unsigned long mask;
size_t len = sizeof(mask);
#if CMK_HAS_PTHREAD_SETAFFINITY
int j;
cpu_set_t cpuset;
pthread_t thread;
char str[256], pe[16];
thread = pthread_self();
if (errno = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset)) {
perror("pthread_getaffinity");
return -1;
}
sprintf(str, "[%d] %s affinity is: ", CmiMyPe(), CmiMyPe()>=CmiNumPes()?"communication pthread":"pthread");
for (j = 0; j < CPU_SETSIZE; j++)
if (CPU_ISSET(j, &cpuset)) {
sprintf(pe, " %d ", j);
strcat(str, pe);
}
CmiPrintf("%s\n", str);
#endif
return 0;
}
示例2: req_fw_handler
extern "C" void req_fw_handler(char *msg)
{
int offset = CmiReservedHeaderSize + sizeof(CcsImplHeader);
CcsImplHeader *hdr = (CcsImplHeader *)(msg+CmiReservedHeaderSize);
int destPE = (int)ChMessageInt(hdr->pe);
if (CmiMyPe() == 0 && destPE == -1) {
/* Broadcast message to all other processors */
int len=CmiReservedHeaderSize+sizeof(CcsImplHeader)+ChMessageInt(hdr->len);
CmiSyncBroadcast(len, msg);
}
else if (destPE < -1) {
/* Multicast the message to your children */
int len=CmiReservedHeaderSize+sizeof(CcsImplHeader)+ChMessageInt(hdr->len)-destPE*sizeof(ChMessageInt_t);
int index, child, i;
int *pes = (int*)(msg+CmiReservedHeaderSize+sizeof(CcsImplHeader));
ChMessageInt_t *pes_nbo = (ChMessageInt_t *)pes;
offset -= destPE * sizeof(ChMessageInt_t);
if (ChMessageInt(pes_nbo[0]) == CmiMyPe()) {
for (index=0; index<-destPE; ++index) pes[index] = ChMessageInt(pes_nbo[index]);
}
for (index=0; index<-destPE; ++index) {
if (pes[index] == CmiMyPe()) break;
}
child = (index << 2) + 1;
for (i=0; i<4; ++i) {
if (child+i < -destPE) {
CmiSyncSend(pes[child+i], len, msg);
}
}
}
CcsHandleRequest(hdr, msg+offset);
CmiFree(msg);
}
示例3: CpdDebugCallAllocationTree
static void CpdDebugCallAllocationTree(char *msg)
{
int numNodes;
int forPE;
void *tree;
if (CpdDebugGetAllocationTree == NULL) {
CmiPrintf("Error> Invoked CpdDebugCalloAllocationTree but no function initialized.\nDid you forget to link in memory charmdebug?\n");
CcsSendReply(0, NULL);
return;
}
sscanf(msg+CmiMsgHeaderSizeBytes, "%d", &forPE);
if (CmiMyPe() == forPE) CpvAccess(allocationTreeDelayedReply) = CcsDelayReply();
if (forPE == -1 && CmiMyPe()==0) {
CpvAccess(allocationTreeDelayedReply) = CcsDelayReply();
CmiSetXHandler(msg, CpvAccess(CpdDebugCallAllocationTree_Index));
CmiSetHandler(msg, _debugHandlerIdx);
CmiSyncBroadcast(CmiMsgHeaderSizeBytes+strlen(msg+CmiMsgHeaderSizeBytes)+1, msg);
}
tree = CpdDebugGetAllocationTree(&numNodes);
if (forPE == CmiMyPe()) CpdDebugReturnAllocationTree(tree);
else if (forPE == -1) CmiReduceStruct(tree, CpdDebug_pupAllocationPoint, CpdDebug_MergeAllocationTree,
CpdDebugReturnAllocationTree, CpdDebug_deleteAllocationPoint);
else CmiAbort("Received allocationTree request for another PE!");
CmiFree(msg);
}
示例4: DEBUGF
// open file, if phase is -1, don't add the phase string
FILE* CountLogPool::openFile(int phase) {
// technically, the sprintf into pestr & phasestr are unnecessary,
// can just make a limit and check for that
DEBUGF(("%d CountLogPool::openFile(%d)\n", CmiMyPe(), phase));
const static int strSize = 10;
char pestr[strSize+1];
char phasestr[strSize+1];
snprintf(pestr, strSize, "%d", CmiMyPe());
pestr[strSize] = '\0';
int len = strlen(CpvAccess(_logName)) + strlen("phase.count.") + 2*strSize + 1;
char* fname = new char[len+1]; _MEMCHECK(fname);
if (phase >= 0) {
snprintf(phasestr, strSize, "%d", phase);
phasestr[strSize] = '\0';
sprintf(fname, "%s.phase%s.%s.count", CpvAccess(_logName), phasestr, pestr);
}
else { sprintf(fname, "%s.%s.count", CpvAccess(_logName), pestr); }
FILE* fp = NULL;
DEBUGF(("%d/%d DEBUG: TRACE: %s:%d\n", CmiMyPe(), CmiNumPes(), fname, errno));
do {
fp = fopen(fname, "w+");
} while (!fp && errno == EINTR);
delete[] fname;
if(!fp) {
CmiAbort("Cannot open Summary Trace File for writing...\n");
}
return fp;
}
示例5: CmiNotifyStillIdle
static void CmiNotifyStillIdle(CmiIdleState *s)
{
#if CMK_SHARED_VARS_UNAVAILABLE
/*No comm. thread-- listen on sockets for incoming messages*/
MACHSTATE(1,"idle commserver {")
CommunicationServer(Cmi_idlepoll?0:10, COMM_SERVER_FROM_SMP);
MACHSTATE(1,"} idle commserver")
#else
#if CMK_SHARED_VARS_POSIX_THREADS_SMP
if(_Cmi_sleepOnIdle ){
#endif
int nSpins=20; /*Number of times to spin before sleeping*/
s->nIdles++;
if (s->nIdles>nSpins) { /*Start giving some time back to the OS*/
s->sleepMs+=2;
if (s->sleepMs>10) s->sleepMs=10;
}
/*Comm. thread will listen on sockets-- just sleep*/
if (s->sleepMs>0) {
MACHSTATE1(3,"idle lock(%d) {",CmiMyPe())
CmiIdleLock_sleep(&s->cs->idle,s->sleepMs);
CsdResetPeriodic(); /* check ccd callbacks when I am awakened */
MACHSTATE1(3,"} idle lock(%d)",CmiMyPe())
}
#if CMK_SHARED_VARS_POSIX_THREADS_SMP
}
示例6: setupMessage
static void setupMessage(Message *msg)
{
Message *mm;
int i, size;
int nextSize = msg->idx;
size = sizeof(Message)+sizes[nextSize].size;
buffer_msgs = (char*)malloc((sizes[nextSize].numiter) * sizeof(Message*));
for(i=0; i<sizes[nextSize].numiter; i++)
{
mm = (Message*)CmiAlloc(size);
mm->srcpe = CmiMyPe();
CmiSetHandler(mm, pva(iterHandler));
//mm->idx = pva(nextSize);
//*((Message**)buffer_msgs+i*sizeof(char*)) = mm;
((Message**)buffer_msgs)[i] = mm;
}
mm = (Message *) CmiAlloc(size);
mm->srcpe = CmiMyPe();
mm->idx = nextSize;
CmiSetHandler(mm, pva(startHandler));
//fillMessage(mm);
//CmiAssert(msg->srcpe == 0);
CmiSyncSendAndFree(msg->srcpe, size, mm);
CmiFree(msg);
}
示例7: startMessage
static void startMessage(Message *msg)
{
#if 0
EmptyMsg m;
CmiFree(msg);
CmiSetHandler(&m, pva(iterHandler));
//fillMessage(mm);
pva(starttime) = CmiWallTimer();
CmiSyncSend(CmiMyPe(), sizeof(EmptyMsg), &m);
#else
Message *mm;
int size;
size = sizeof(Message)+sizes[pva(nextSize)].size;
mm = (Message *) CmiAlloc(size);
mm->srcpe = CmiMyPe();
mm->idx = pva(nextSize);
CmiSetHandler(mm, pva(iterHandler));
//fillMessage(mm);
pva(starttime) = CmiWallTimer();
CmiSyncSendAndFree(mm->srcpe, size, mm);
CmiFree(msg);
#endif
}
示例8: startNextSize
static void startNextSize(EmptyMsg *msg)
{
EmptyMsg m;
Message *mm;
int i;
//CmiAssert(CmiMyPe()==0);
pva(nextSize)++;
if(pva(nextSize) == pva(numSizes)) {
pva(nextSize) = -1;
CmiSetHandler(&m, pva(nbrHandler));
CmiSyncSend(CmiMyPe(), sizeof(EmptyMsg), &m);
} else {
int size = sizeof(Message)+sizes[pva(nextSize)].size;
buffer_msgs = (char*)malloc((sizes[pva(nextSize)].numiter) * sizeof(Message*));
for(i=0; i<sizes[pva(nextSize)].numiter; i++)
{
mm = CmiAlloc(size);
mm->srcpe = CmiMyPe();
mm->idx = pva(nextSize);
CmiSetHandler(mm, pva(bounceHandler));
//*((Message**)(buffer_msgs+i*sizeof(char*))) = mm;
((Message**)buffer_msgs)[i] = mm;
}
mm = (Message *) CmiAlloc(size);
mm->srcpe = CmiMyPe();
mm->idx = pva(nextSize);
CmiSetHandler(mm, pva(setupHandler));
//fillMessage(mm);
CmiSyncSendAndFree(pva(nextNbr), size, mm);
}
CmiFree(msg);
}
示例9: startNextNbr
static void startNextNbr(EmptyMsg *msg)
{
EmptyMsg m;
TimeMessage *tm;
int i, size;
//CmiAssert(CmiMyPe()==0);
CmiFree(msg);
pva(nextNbr)++;
if(pva(nextNbr) == CmiMyNode()) {
CmiSetHandler(&m, pva(nbrHandler));
CmiSyncSend(CmiMyPe(), sizeof(EmptyMsg), &m);
return;
}
if(pva(nextNbr) == CmiNumNodes()) {
pva(nextNbr) = -1;
CmiSetHandler(&m, pva(nodeHandler));
CmiSyncSend(CmiMyPe(), sizeof(EmptyMsg), &m);
size = sizeof(TimeMessage)+pva(numSizes)*CmiNumNodes()*sizeof(double);
tm = (TimeMessage *) CmiAlloc(size);
for(i=0;i<CmiNumNodes();i++)
memcpy(tm->data+i*pva(numSizes),pva(times)[i],
sizeof(double)*pva(numSizes));
tm->srcNode = CmiMyNode();
CmiSetHandler(tm, pva(timeHandler));
CmiSyncSendAndFree(0, size, tm);
} else {
CmiSetHandler(&m, pva(sizeHandler));
CmiSyncSend(CmiMyPe(), sizeof(EmptyMsg), &m);
}
}
示例10: stats_
// constructor
StatTable::StatTable():
stats_(NULL), numStats_(0)
{
DEBUGF(("%d/%d DEBUG: StatTable::StatTable %08x size %d\n",
CmiMyPe(), CmiNumPes(), this));
DEBUGF(("%d/%d registering reductionID\n", CmiMyPe(), CmiNumPes()));
CpvAccess(_reductionID) = CmiRegisterHandler((CmiHandler)StatTableReduction);
}
示例11: fibobj_calc
CpmInvokable fibobj_calc(int n, int ppe, fibobj_chare ppos)
{
if (n<2) Cpm_fibobj_result(CpmSend(ppe), n, ppos);
else {
fibobj_chare c = (fibobj_chare)malloc(sizeof(struct fibobj_chare));
c->ppe = ppe, c->ppos = ppos; c->count=c->total=0;
Cpm_fibobj_calc(CpmLDB(), n-1, CmiMyPe(), c);
Cpm_fibobj_calc(CpmLDB(), n-2, CmiMyPe(), c);
}
}
示例12: mymain
CmiStartFn mymain(int argc, char** argv)
{
if(CmiMyRank() == CmiMyNodeSize()) return 0;
CpvInitialize(int,msgSize);
CpvInitialize(int,cycleNum);
CpvInitialize(int,sizeNum);
CpvAccess(sizeNum) = 1;
CpvAccess(msgSize)= CmiMsgHeaderSizeBytes + 8;
CpvInitialize(int,exitHandler);
CpvAccess(exitHandler) = CmiRegisterHandler((CmiHandler) exitHandlerFunc);
CpvInitialize(int,node0Handler);
CpvAccess(node0Handler) = CmiRegisterHandler((CmiHandler) node0HandlerFunc);
CpvInitialize(int,node1Handler);
CpvAccess(node1Handler) = CmiRegisterHandler((CmiHandler) node1HandlerFunc);
CpvInitialize(int,ackHandler);
CpvAccess(ackHandler) = CmiRegisterHandler((CmiHandler) ackHandlerFunc);
CpvInitialize(double,startTime);
CpvInitialize(double,endTime);
CpvInitialize(double, IdleStartTime);
CpvInitialize(double, IdleTime);
CpvInitialize(int,ackCount);
CpvAccess(ackCount) = 0;
CpvInitialize(int,twoway);
CpvAccess(twoway) = 0;
CcdCallOnConditionKeep(CcdPROCESSOR_BEGIN_IDLE, ApplIdleStart, NULL);
CcdCallOnConditionKeep(CcdPROCESSOR_END_IDLE, ApplIdleEnd, NULL);
if(argc > 1)
CpvAccess(twoway) = atoi(argv[1]);
if(CmiMyPe() == 0) {
if(!CpvAccess(twoway))
CmiPrintf("Starting Pingpong with oneway traffic \n");
else
CmiPrintf("Starting Pingpong with twoway traffic\n");
}
if ((CmiMyPe() < CmiNumPes()/2) || CpvAccess(twoway))
startPingpong();
return 0;
}
示例13: strlen
//! add the argument parameters to the linked list of args choices
void TraceCounter::registerArg(CounterArg* arg)
{
if (firstArg_ == NULL) {
firstArg_ = lastArg_ = arg;
argStrSize_ = strlen(arg->arg);
}
else {
// check to see if any redundancy
CounterArg* check = firstArg_;
while (check != NULL) {
if (strcmp(check->arg, arg->arg)==0 || check->code == arg->code) {
if (CmiMyPe()==0) {
CmiPrintf("Two args with same name %s or code %d\n",
arg->arg, arg->code);
}
CmiAbort("TraceCounter::registerArg()\n");
}
check = check->next;
}
lastArg_->next = arg;
lastArg_ = arg;
int len = strlen(arg->arg);
if (len > argStrSize_) { argStrSize_ = len; }
}
}
示例14: CmiSyncBroadcastFn1
/* Functions regarding broadcat op that sends to every one else except me */
void CmiSyncBroadcastFn1(int size, char *msg) {
int i, mype;
CQdCreate(CpvAccess(cQdState), CmiNumPes()-1);
/*record the rank to avoid re-sending the msg in spanning tree or hypercube*/
CMI_DEST_RANK(msg) = CmiMyRank();
#if CMK_BROADCAST_SPANNING_TREE
CMI_SET_BROADCAST_ROOT(msg, CmiMyNode()+1);
SendSpanningChildrenProc(size, msg);
#elif CMK_BROADCAST_HYPERCUBE
CMI_SET_BROADCAST_ROOT(msg, CmiMyNode()+1);
SendHyperCubeProc(size, msg);
#else
mype = CmiMyPe();
#if CMK_SMP
/* In SMP, this function may be called from comm thread with a larger pe */
if(mype >= _Cmi_numpes){
for(i=0; i<_Cmi_numpes; i++)
CmiSyncSendFn(i, size, msg);
return;
}
#endif
for ( i=mype+1; i<_Cmi_numpes; i++ )
CmiSyncSendFn(i, size, msg) ;
for ( i=0; i<mype; i++ )
CmiSyncSendFn(i, size, msg) ;
#endif
/*CmiPrintf("In SyncBroadcast broadcast\n");*/
}
示例15: CmiAssert
// 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
}