void gasnetc_bootstrapBroadcast(void *src, size_t len, void *dest, int rootnode) { int retval; gasneti_assert(gasneti_nodes > 0 && gasneti_mynode < gasneti_nodes); if (gasneti_mynode == rootnode) memcpy(dest, src, len); GASNETI_AM_SAFE_NORETURN(retval,AMMPI_SPMDBroadcast(dest, len, rootnode)); if_pf (retval) gasneti_fatalerror("failure in gasnetc_bootstrapBroadcast()"); }
extern int gasnetc_AMPoll(GASNETI_THREAD_FARG_ALONE) { int retval; GASNETI_CHECKATTACH(); #if GASNET_PSHM gasneti_AMPSHMPoll(0 GASNETI_THREAD_PASS); #endif AMLOCK(); // In single-nbrhd case never need to poll the network for client AMs. // However, we'll still check for control traffic for orderly exit handling. if (gasneti_mysupernode.grp_count > 1) { GASNETI_AM_SAFE_NORETURN(retval,AM_Poll(gasnetc_bundle)); } else { // TODO-EX: a lock-free peek would allow elimination of a lock cycle GASNETI_AM_SAFE_NORETURN(retval,AMUDP_SPMDHandleControlTraffic(NULL)); } AMUNLOCK(); if_pf (retval) GASNETI_RETURN_ERR(RESOURCE); else return GASNET_OK;
extern void gasnetc_trace_finish(void) { /* dump AMUDP statistics */ if (GASNETI_STATS_ENABLED(C) ) { const char *statdump; int isglobal = 0; int retval = 0; amudp_stats_t stats = AMUDP_initial_stats; /* bug 2181 - lock state is unknown, eg we may be in handler context */ AMLOCK_CAUTIOUS(); if (isglobal) { /* TODO: tricky bit - if this exit is collective, we can display more interesting and useful statistics with collective cooperation. But there's no easy way to know for sure whether the exit is collective. */ /* TODO: want a bootstrap barrier here for global stats to ensure network is quiescent, but no way to do this unless we know things are collective */ if (gasnet_mynode() != 0) { GASNETI_AM_SAFE_NORETURN(retval, AMUDP_GetEndpointStatistics(gasnetc_endpoint, &stats)); /* get statistics */ /* TODO: send stats to zero */ } else { amudp_stats_t *remote_stats = NULL; /* TODO: gather stats from all nodes */ GASNETI_AM_SAFE_NORETURN(retval, AMUDP_AggregateStatistics(&stats, remote_stats)); } } else { GASNETI_AM_SAFE_NORETURN(retval, AMUDP_GetEndpointStatistics(gasnetc_endpoint, &stats)); /* get statistics */ } if ((gasnet_mynode() == 0 || !isglobal) && !retval) { GASNETI_STATS_PRINTF(C,("--------------------------------------------------------------------------------")); GASNETI_STATS_PRINTF(C,("AMUDP Statistics:")); if (!isglobal) GASNETI_STATS_PRINTF(C,("*** AMUDP stat dump reflects only local node info, because gasnet_exit is non-collective ***")); statdump = AMUDP_DumpStatistics(NULL, &stats, isglobal); GASNETI_STATS_PRINTF(C,("\n%s",statdump)); /* note, dump has embedded '%' chars */ GASNETI_STATS_PRINTF(C,("--------------------------------------------------------------------------------")); } } }
extern int gasnetc_AMPoll(void) { int retval; GASNETI_CHECKATTACH(); #if GASNET_PSHM gasneti_AMPSHMPoll(0); #endif AMLOCK(); GASNETI_AM_SAFE_NORETURN(retval,AM_Poll(gasnetc_bundle)); AMUNLOCK(); if_pf (retval) GASNETI_RETURN_ERR(RESOURCE); else return GASNET_OK;
/* Misc. Active Message Functions ============================== */ extern int gasnetc_AMGetMsgSource(gasnet_token_t token, gasnet_node_t *srcindex) { int retval; gasnet_node_t sourceid; GASNETI_CHECKATTACH(); GASNETI_CHECK_ERRR((!token),BAD_ARG,"bad token"); GASNETI_CHECK_ERRR((!srcindex),BAD_ARG,"bad src ptr"); #if GASNET_PSHM if (gasneti_AMPSHMGetMsgSource(token, &sourceid) != GASNET_OK) #endif { int tmp; /* AMUDP wants an int, but gasnet_node_t is uint16_t */ GASNETI_AM_SAFE_NORETURN(retval,AMUDP_GetSourceId(token, &tmp)); if_pf (retval) GASNETI_RETURN_ERR(RESOURCE); gasneti_assert(tmp >= 0); sourceid = tmp; } gasneti_assert(sourceid < gasneti_nodes); *srcindex = sourceid; return GASNET_OK; }
void gasnetc_bootstrapExchange(void *src, size_t len, void *dest) { int retval; GASNETI_AM_SAFE_NORETURN(retval,AMUDP_SPMDAllGather(src, dest, len)); if_pf (retval) gasneti_fatalerror("failure in gasnetc_bootstrapExchange()"); }
void gasnetc_bootstrapBarrier(void) { int retval; AM_ASSERT_LOCKED(); /* need this because SPMDBarrier may poll */ GASNETI_AM_SAFE_NORETURN(retval,AMUDP_SPMDBarrier()); if_pf (retval) gasneti_fatalerror("failure in gasnetc_bootstrapBarrier()"); }