static int gasnetc_init(int *argc, char ***argv) { int retval = GASNET_OK; int networkdepth = 0; const char *pstr = NULL; const char *tmsgstr = NULL; AMLOCK(); if (gasneti_init_done) INITERR(NOT_INIT, "GASNet already initialized"); gasneti_init_done = 1; /* enable early to allow tracing */ /* check system sanity */ gasnetc_check_config(); gasneti_freezeForDebugger(); #if GASNET_DEBUG_VERBOSE /* note - can't call trace macros during gasnet_init because trace system not yet initialized */ fprintf(stderr,"gasnetc_init(): about to spawn...\n"); fflush(stderr); #endif /* choose network depth */ networkdepth = gasnett_getenv_int_withdefault("GASNET_NETWORKDEPTH", GASNETC_DEFAULT_NETWORKDEPTH, 0); if (networkdepth <= 1) networkdepth = GASNETC_DEFAULT_NETWORKDEPTH; AMMPI_VerboseErrors = gasneti_VerboseErrors; AMMPI_SPMDkillmyprocess = gasneti_killmyprocess; #if !defined(GASNETI_DISABLE_MPI_INIT_THREAD) { int res; #if GASNETI_THREADS /* tell MPI to be thread-safe */ res = AMMPI_SPMDSetThreadMode(1, &pstr, argc, argv); #else res = AMMPI_SPMDSetThreadMode(0, &pstr, argc, argv); #endif if (!res) { #if GASNETI_THREADS { static char tmsg[255]; snprintf(tmsg, sizeof(tmsg), "*** WARNING: The pthreaded version of mpi-conduit requires an MPI implementation " "which supports threading mode MPI_THREAD_SERIALIZED, " "but this implementation reports it can only support %s\n", pstr); #if GASNET_DEBUG_VERBOSE /* only show this in verbose mode, because some versions of MPICH (eg Quadrics version) lie and report THREAD_SINGLE, when in actuality MPI_THREAD_SERIALIZED works just fine */ if (!gasneti_getenv_yesno_withdefault("GASNET_QUIET",0)) fprintf(stderr, "%s", tmsg); #else tmsgstr = tmsg; #endif } #else fprintf(stderr,"unknown failure in AMMPI_SPMDSetThreadMode() => %s\n",pstr); #endif } } #endif /* perform job spawn */ retval = AMMPI_SPMDStartup(argc, argv, networkdepth, NULL, &gasnetc_bundle, &gasnetc_endpoint); if (retval != AM_OK) INITERR(RESOURCE, "AMMPI_SPMDStartup() failed"); gasneti_mynode = AMMPI_SPMDMyProc(); gasneti_nodes = AMMPI_SPMDNumProcs(); /* a number of MPI job spawners fail to propagate the environment to all compute nodes */ /* do this before trace_init to make sure it gets right environment */ gasneti_setupGlobalEnvironment(gasneti_nodes, gasneti_mynode, gasnetc_bootstrapExchange, gasnetc_bootstrapBroadcast); /* enable tracing */ gasneti_trace_init(argc, argv); GASNETI_AM_SAFE(AMMPI_SPMDSetExitCallback(gasnetc_traceoutput)); if (pstr) GASNETI_TRACE_PRINTF(C,("AMMPI_SPMDSetThreadMode/MPI_Init_thread()=>%s",pstr)); if (tmsgstr) GASNETI_TRACE_PRINTF(I,("%s",tmsgstr)); #if GASNET_DEBUG_VERBOSE fprintf(stderr,"gasnetc_init(): spawn successful - node %i/%i starting...\n", gasneti_mynode, gasneti_nodes); fflush(stderr); #endif gasneti_nodemapInit(&gasnetc_bootstrapExchange, NULL, 0, 0); #if GASNET_PSHM gasneti_pshm_init(&gasnetc_bootstrapExchange, 0); #endif #if GASNET_SEGMENT_FAST || GASNET_SEGMENT_LARGE { uintptr_t limit; #if HAVE_MMAP limit = gasneti_mmapLimit((uintptr_t)-1, (uint64_t)-1, &gasnetc_bootstrapExchange, &gasnetc_bootstrapBarrier); #else limit = (intptr_t)-1; #endif gasneti_segmentInit(limit, &gasnetc_bootstrapExchange); } #elif GASNET_SEGMENT_EVERYTHING /* segment is everything - nothing to do */ #else #error Bad segment config #endif AMUNLOCK(); gasneti_auxseg_init(); /* adjust max seg values based on auxseg */ gasneti_assert(retval == GASNET_OK); return retval; done: /* error return while locked */ AMUNLOCK(); GASNETI_RETURN(retval); }
void gasnete_coll_bcast_proto_register(void) { DCMF_GlobalBcast_Configuration_t gbcast_conf; DCMF_Broadcast_Configuration_t bcast_conf; DCMF_AsyncBroadcast_Configuration_t a_bcast_conf; GASNETC_DCMF_LOCK(); /* for DCMF_SAFE */ gasnete_use_dcmf_bcast = gasneti_getenv_yesno_withdefault("GASNET_USE_DCMF_BCAST", 1); /* tree broadcast registration */ gasnete_dcmf_bcast_enabled[TREE_BROADCAST] = gasneti_getenv_yesno_withdefault("GASNET_DCMF_TREE_BCAST", 1); if (gasnete_dcmf_bcast_enabled[TREE_BROADCAST]) { gbcast_conf.protocol = DCMF_TREE_GLOBALBCAST_PROTOCOL; DCMF_SAFE(DCMF_GlobalBcast_register(&gasnete_dcmf_globalbcast_proto, &gbcast_conf)); bcast_conf.protocol = DCMF_TREE_BROADCAST_PROTOCOL; DCMF_SAFE(DCMF_Broadcast_register(&gasnete_dcmf_bcast_proto[TREE_BROADCAST], &bcast_conf)); } /* torus broadcast registration */ gasnete_dcmf_bcast_enabled[TORUS_RECTANGLE_BROADCAST] = gasneti_getenv_yesno_withdefault("GASNET_DCMF_TORUS_RECTANGLE_BCAST", 1); if (gasnete_dcmf_bcast_enabled[TORUS_RECTANGLE_BROADCAST]) { bcast_conf.protocol = DCMF_TORUS_RECTANGLE_BROADCAST_PROTOCOL; DCMF_SAFE(DCMF_Broadcast_register(&gasnete_dcmf_bcast_proto[TORUS_RECTANGLE_BROADCAST], &bcast_conf)); } gasnete_dcmf_bcast_enabled[TORUS_BINOMIAL_BROADCAST] = gasneti_getenv_yesno_withdefault("GASNET_DCMF_TORUS_BINOMIAL_BCAST", 1); if (gasnete_dcmf_bcast_enabled[TORUS_BINOMIAL_BROADCAST]) { bcast_conf.protocol = DCMF_TORUS_BINOMIAL_BROADCAST_PROTOCOL; DCMF_SAFE(DCMF_Broadcast_register(&gasnete_dcmf_bcast_proto[TORUS_BINOMIAL_BROADCAST], &bcast_conf)); } /* asynchronous broadcast registration */ gasnete_dcmf_bcast_enabled[TORUS_ASYNCBROADCAST_RECTANGLE] = gasneti_getenv_yesno_withdefault("GASNET_DCMF_TORUS_ASYNCBROADCAST_RECTANGLE_BCAST", 1); if (gasnete_dcmf_bcast_enabled[TORUS_ASYNCBROADCAST_RECTANGLE]) { a_bcast_conf.protocol = DCMF_TORUS_ASYNCBROADCAST_RECTANGLE_PROTOCOL; a_bcast_conf.isBuffered = 1; a_bcast_conf.cb_geometry = gasnete_dcmf_get_geometry; DCMF_SAFE(DCMF_AsyncBroadcast_register(&gasnete_dcmf_bcast_proto[TORUS_ASYNCBROADCAST_RECTANGLE], &a_bcast_conf)); } gasnete_dcmf_bcast_enabled[TORUS_ASYNCBROADCAST_BINOMIAL] = gasneti_getenv_yesno_withdefault("GASNET_DCMF_TORUS_ASYNCBROADCAST_BINOMIAL_BCAST", 1); if (gasnete_dcmf_bcast_enabled[TORUS_ASYNCBROADCAST_BINOMIAL]) { a_bcast_conf.protocol = DCMF_TORUS_ASYNCBROADCAST_BINOMIAL_PROTOCOL; a_bcast_conf.isBuffered = 1; a_bcast_conf.cb_geometry = gasnete_dcmf_get_geometry; DCMF_SAFE(DCMF_AsyncBroadcast_register(&gasnete_dcmf_bcast_proto[TORUS_ASYNCBROADCAST_BINOMIAL], &a_bcast_conf)); } /* number of bcast streams used in the torus rectangle bcast */ gasnete_dcmf_bcast_num_colors = gasneti_getenv_int_withdefault("GASNET_DCMF_BCAST_NUM_COLORS", 1, 0); if (gasnete_dcmf_bcast_num_colors < 1 || gasnete_dcmf_bcast_num_colors > 6) gasnete_dcmf_bcast_num_colors = 1; GASNETC_DCMF_UNLOCK(); }