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 }
void master_init(int argc, char **argv){ cpuTime_start = CmiCpuTimer(); wallTime_start = CmiWallTimer(); if ( CmiMyPe() ) { all_init(argc, argv); CsdScheduler(-1); ConverseExit(); // should never return } all_init(argc, argv); // Create branch-office chares BOCgroup group; group.workDistrib = CProxy_WorkDistrib::ckNew(); group.proxyMgr = CProxy_ProxyMgr::ckNew(); group.patchMgr = CProxy_PatchMgr::ckNew(); group.computeMgr = CProxy_ComputeMgr::ckNew(); group.reductionMgr = CProxy_ReductionMgr::ckNew(); // group.computePmeMgr set in constructor during startup group.nodePmeMgr = CProxy_NodePmeMgr::ckNew(); #ifdef OPENATOM_VERSION group.computeMoaMgr = CProxy_ComputeMoaMgr::ckNew(); #endif // OPENATOM_VERSION group.computeExtMgr = CProxy_ComputeExtMgr::ckNew(); group.computeGBISserMgr = CProxy_ComputeGBISserMgr::ckNew(); group.computeMsmSerialMgr = CProxy_ComputeMsmSerialMgr::ckNew(); #ifdef CHARM_HAS_MSA group.computeMsmMsaMgr = CProxy_ComputeMsmMsaMgr::ckNew(); #endif group.computeMsmMgr = CProxy_ComputeMsmMgr::ckNew(); // Charm CkMulticast library module group.multicastMgr = CProxy_CkMulticastMgr::ckNew(); #ifdef MEM_OPT_VERSION group.ioMgr=CProxy_ParallelIOMgr::ckNew(); #endif group.sync = CProxy_Sync::ckNew(); #ifdef USE_NODEPATCHMGR group.nodeProxyMgr = CProxy_NodeProxyMgr::ckNew(); #endif #if USE_CKLOOP group.ckLoop = CkLoop_Init(); #endif CkChareID collectionMaster = CProxy_CollectionMaster::ckNew(0); SlaveInitMsg *initmsg7 = new SlaveInitMsg; initmsg7->master = collectionMaster; group.collectionMgr = CProxy_CollectionMgr::ckNew(initmsg7); group.broadcastMgr = CProxy_BroadcastMgr::ckNew(); group.ldbCoordinator = CProxy_LdbCoordinator::ckNew(); GroupInitMsg *msg = new GroupInitMsg; msg->group = group; CProxy_Node::ckNew(msg); }
/* * allows the system to use processor 0 as a worker. */ void CmsAwaitResponses(void) { CsdScheduler(-1); /* * be a worker for a while, and also process * responses */ /* * when back from the sceduler, return. Because all response have been * recvd */ }
void CkExit(void) { /*FAULT_EVAC*/ DEBUGF(("[%d] CkExit called \n",CkMyPe())); // always send to PE 0 envelope *env = _allocEnv(StartExitMsg); 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: if(!CharmLibInterOperate) CsdScheduler(-1); #endif }
static void *call_startfn(void *vindex) { size_t index = (size_t)vindex; #if CMK_HAS_TLS_VARIABLES && !CMK_NOT_USE_TLS_THREAD if (index<_Cmi_mynodesize) CmiStateInit(index+Cmi_nodestart, index, &Cmi_mystate); else CmiStateInit(_Cmi_mynode+CmiNumPes(),_Cmi_mynodesize,&Cmi_mystate); Cmi_state_vector[index] = &Cmi_mystate; #else CmiState state = Cmi_state_vector + index; pthread_setspecific(Cmi_state_key, state); #endif ConverseRunPE(0); if(CharmLibInterOperate) { while(1) { if(!_cleanUp) { StartInteropScheduler(); CmiNodeAllBarrier(); } else { if (CmiMyRank() == CmiMyNodeSize()) { while (1) { CommunicationServerThread(5); } } else { CsdScheduler(-1); } break; } } } #if 0 if (index<_Cmi_mynodesize) ConverseRunPE(0); /*Regular worker thread*/ else { /*Communication thread*/ CommunicationServerInit(); if (Cmi_charmrun_fd!=-1) while (1) CommunicationServer(5,COM_SERVER_FROM_SMP); } #endif return 0; }
// called on slave procs void slave_init(int argc, char **argv) { #if CMK_SMP //the original main thread could now be a comm thread //and a slave thread could now be the main thread, //so we have to do the master initialization here if(CmiMyRank()==0){ master_init(argc, argv); if(CmiMyPe()==0) after_backend_init(argc, argv); return; } #endif all_init(argc, argv); if (CkMyRank() < CkMyNodeSize()) // skip the communication thread CsdScheduler(-1); }
void CmsInit(CmsWorkerFn f, int maxResponses) { char *argv[1]; int argc = 0; argv[0] = 0; ConverseInit(argc, argv, (CmiStartFn) initForCms, 1, 1); cms_registerHandlers(f); CpvAccess(tableSize) = maxResponses; if (CmiMyPe() == 0) { /* * I am the manager */ CpvAccess(responses) = (ResponseRecord *) CmiAlloc(maxResponses * sizeof(ResponseRecord)); CpvAccess(counter) = 0; } else { /* * I am a worker */ CsdScheduler(-1); ConverseExit(); } }
// start scheduler void BackEnd::suspend(void) { CsdScheduler(-1); }
void StartCharmScheduler() { CsdScheduler(-1); }
void CharmLibExit() { if(CkMyPe() == 0) { CkExit(); } CsdScheduler(-1); }
void CmsProcessResponses(CmsConsumerFn f) { CpvAccess(consumerFunction) = f; CsdScheduler(-1); }