void smp_coll_barrier_cond_var(smp_coll_t handle, int flags){ static gasneti_mutex_t barrier_mutex = GASNETT_MUTEX_INITIALIZER; static volatile int phase = 0; static volatile unsigned int barrier_count = 0; static sem_t sem[2]; gasneti_mutex_lock(&barrier_mutex); { int myphase = phase; static volatile int firsttime = 1; if (firsttime) { gasneti_assert_zeroret(sem_init(&sem[0], 0, 0)); gasneti_assert_zeroret(sem_init(&sem[1], 0, 0)); firsttime = 0; } barrier_count++; if (barrier_count < handle->THREADS) { gasneti_mutex_unlock(&barrier_mutex); gasneti_assert_zeroret(sem_wait(&sem[myphase])); } else { int i; barrier_count = 0; phase = !phase; gasneti_mutex_unlock(&barrier_mutex); for (i=0; i < (handle->THREADS-1); i++) { gasneti_assert_zeroret(sem_post(&sem[myphase])); } } } }
gex_Rank_t gasnetc_msgsource(gex_Token_t token) { #if GASNET_PSHM gasneti_assert(! gasnetc_token_in_nbrhd(token)); #endif gasneti_assert(token); int tmp; /* AMUDP wants an int, but gex_Rank_t is uint32_t */ gasneti_assert_zeroret(AMUDP_GetSourceId(token, &tmp)); gasneti_assert(tmp >= 0); gex_Rank_t sourceid = tmp; gasneti_assert(sourceid < gasneti_nodes); return sourceid; }