static void CmiDestroyLocks() { CmiDestroyLock(comm_mutex); CmiDestroyLock(CmiMemLock_lock); CmiMemLock_lock = 0; pthread_mutex_destroy(&barrier_mutex); #ifdef CMK_NO_ASM_AVAILABLE pthread_mutex_destroy(cmiMemoryLock); #endif }
CkArrayReductionMgr::~CkArrayReductionMgr() { CmiDestroyLock(lockCount); }
static void CmiStartThreads(char **argv) { pthread_t pid; size_t i; int ok, tocreate; pthread_attr_t attr; MACHSTATE(4,"CmiStartThreads") CmiMemLock_lock=CmiCreateLock(); comm_mutex=CmiCreateLock(); _smp_mutex = CmiCreateLock(); #if defined(CMK_NO_ASM_AVAILABLE) && CMK_PCQUEUE_LOCK cmiMemoryLock = CmiCreateLock(); if (CmiMyNode()==0) printf("Charm++ warning> fences and atomic operations not available in native assembly\n"); #endif #if ! (CMK_HAS_TLS_VARIABLES && !CMK_NOT_USE_TLS_THREAD) pthread_key_create(&Cmi_state_key, 0); Cmi_state_vector = (CmiState)calloc(_Cmi_mynodesize+1, sizeof(struct CmiStateStruct)); for (i=0; i<_Cmi_mynodesize; i++) CmiStateInit(i+Cmi_nodestart, i, CmiGetStateN(i)); /*Create a fake state structure for the comm. thread*/ /* CmiStateInit(-1,_Cmi_mynodesize,CmiGetStateN(_Cmi_mynodesize)); */ CmiStateInit(_Cmi_mynode+CmiNumPes(),_Cmi_mynodesize,CmiGetStateN(_Cmi_mynodesize)); #else /* for main thread */ Cmi_state_vector = (CmiState *)calloc(_Cmi_mynodesize+1, sizeof(CmiState)); #if CMK_CONVERSE_MPI /* main thread is communication thread */ CmiStateInit(_Cmi_mynode+CmiNumPes(), _Cmi_mynodesize, &Cmi_mystate); Cmi_state_vector[_Cmi_mynodesize] = &Cmi_mystate; #else /* main thread is of rank 0 */ CmiStateInit(Cmi_nodestart, 0, &Cmi_mystate); Cmi_state_vector[0] = &Cmi_mystate; #endif #endif #if CMK_MULTICORE || CMK_SMP_NO_COMMTHD if (!Cmi_commthread) tocreate = _Cmi_mynodesize-1; else #endif tocreate = _Cmi_mynodesize; #if CMK_CONVERSE_MPI for (i=0; i<=tocreate-1; i++) { /* skip comm thread */ #else for (i=1; i<=tocreate; i++) { /* skip rank 0 main thread */ #endif pthread_attr_init(&attr); pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); ok = pthread_create(&pid, &attr, call_startfn, (void *)i); if (ok<0) PerrorExit("pthread_create"); pthread_attr_destroy(&attr); } #if ! (CMK_HAS_TLS_VARIABLES && !CMK_NOT_USE_TLS_THREAD) #if CMK_CONVERSE_MPI pthread_setspecific(Cmi_state_key, Cmi_state_vector+_Cmi_mynodesize); #else pthread_setspecific(Cmi_state_key, Cmi_state_vector); #endif #endif MACHSTATE(4,"CmiStartThreads done") } static void CmiDestoryLocks() { CmiDestroyLock(comm_mutex); CmiDestroyLock(CmiMemLock_lock); CmiMemLock_lock = 0; pthread_mutex_destroy(&barrier_mutex); #ifdef CMK_NO_ASM_AVAILABLE pthread_mutex_destroy(cmiMemoryLock); #endif }