ompi_mpi_init.c
来自「MPI stands for the Message Passing Inter」· C语言 代码 · 共 762 行 · 第 1/2 页
C
762 行
if (OMPI_SUCCESS != (ret = mca_pml_base_modex_init())) { error = "mca_pml_base_modex_init() failed"; goto error; } /* Select which MPI components to use */ if (OMPI_SUCCESS != (ret = mca_mpool_base_init(OMPI_ENABLE_PROGRESS_THREADS, OMPI_ENABLE_MPI_THREADS))) { error = "mca_mpool_base_init() failed"; goto error; } if (OMPI_SUCCESS != (ret = mca_pml_base_select(OMPI_ENABLE_PROGRESS_THREADS, OMPI_ENABLE_MPI_THREADS))) { error = "mca_pml_base_select() failed"; goto error; } if (OMPI_SUCCESS != (ret = mca_coll_base_find_available(OMPI_ENABLE_PROGRESS_THREADS, OMPI_ENABLE_MPI_THREADS))) { error = "mca_coll_base_find_available() failed"; goto error; } if (OMPI_SUCCESS != (ret = ompi_osc_base_find_available(OMPI_ENABLE_PROGRESS_THREADS, OMPI_ENABLE_MPI_THREADS))) { error = "ompi_osc_base_find_available() failed"; goto error; } /* io and topo components are not selected here -- see comment above about the io and topo frameworks being loaded lazily */ /* Initialize each MPI handle subsystem */ /* initialize requests */ if (OMPI_SUCCESS != (ret = ompi_request_init())) { error = "ompi_request_init() failed"; goto error; } /* initialize info */ if (OMPI_SUCCESS != (ret = ompi_info_init())) { error = "ompi_info_init() failed"; goto error; } /* initialize error handlers */ if (OMPI_SUCCESS != (ret = ompi_errhandler_init())) { error = "ompi_errhandler_init() failed"; goto error; } /* initialize error codes */ if (OMPI_SUCCESS != (ret = ompi_mpi_errcode_init())) { error = "ompi_mpi_errcode_init() failed"; goto error; } /* initialize internal error codes */ if (OMPI_SUCCESS != (ret = ompi_errcode_intern_init())) { error = "ompi_errcode_intern_init() failed"; goto error; } /* initialize groups */ if (OMPI_SUCCESS != (ret = ompi_group_init())) { error = "ompi_group_init() failed"; goto error; } /* initialize communicators */ if (OMPI_SUCCESS != (ret = ompi_comm_init())) { error = "ompi_comm_init() failed"; goto error; } /* initialize file handles */ if (OMPI_SUCCESS != (ret = ompi_file_init())) { error = "ompi_file_init() failed"; goto error; } /* initialize windows */ if (OMPI_SUCCESS != (ret = ompi_win_init())) { error = "ompi_win_init() failed"; goto error; } /* initialize attribute meta-data structure for comm/win/dtype */ if (OMPI_SUCCESS != (ret = ompi_attr_init())) { error = "ompi_attr_init() failed"; goto error; } /* do module exchange */ if (OMPI_SUCCESS != (ret = mca_pml_base_modex_exchange())) { error = "mca_pml_base_modex_exchange() failed"; goto error; } /* Let system know we are at STG1 Barrier */ if (ORTE_SUCCESS != (ret = orte_smr.set_proc_state(orte_process_info.my_name, ORTE_PROC_STATE_AT_STG1, 0))) { ORTE_ERROR_LOG(ret); error = "set process state failed"; goto error; } /* check for timing request - get stop time and report elapsed time if so */ if (timing) { if (0 != gettimeofday(&ompistop, NULL)) { opal_output(0, "ompi_mpi_init: could not obtain stop time"); } else { opal_output(0, "ompi_mpi_init: time from start to exec_compound_cmd %ld usec", (long int)((ompistop.tv_sec - ompistart.tv_sec)*1000000 + (ompistop.tv_usec - ompistart.tv_usec))); if (0 != gettimeofday(&ompistart, NULL)) { opal_output(0, "ompi_mpi_init: could not obtain new start time"); ompistart.tv_sec = ompistop.tv_sec; ompistart.tv_usec = ompistop.tv_usec; } } } /* if the compound command is operative, execute it */ if (compound_cmd) { if (OMPI_SUCCESS != (ret = orte_gpr.exec_compound_cmd())) { ORTE_ERROR_LOG(ret); error = "ompi_rte_init: orte_gpr.exec_compound_cmd failed"; goto error; } } /* check for timing request - get stop time and report elapsed time if so */ if (timing) { if (0 != gettimeofday(&ompistop, NULL)) { opal_output(0, "ompi_mpi_init: could not obtain stop time after compound_cmd"); } else { opal_output(0, "ompi_mpi_init: time to execute compound command %ld usec", (long int)((ompistop.tv_sec - ompistart.tv_sec)*1000000 + (ompistop.tv_usec - ompistart.tv_usec))); } gettimeofday(&ompistart, NULL); } /* FIRST BARRIER - WAIT FOR MSG FROM RMGR_PROC_STAGE_GATE_MGR TO ARRIVE */ if (ORTE_SUCCESS != (ret = orte_rml.xcast(ORTE_PROC_MY_NAME->jobid, true, NULL, orte_gpr.deliver_notify_msg))) { ORTE_ERROR_LOG(ret); error = "ompi_mpi_init: failed to see all procs register\n"; goto error; } /* check for timing request - get start time */ if (timing) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init[%ld]: time to execute xcast %ld usec", (long)ORTE_PROC_MY_NAME->vpid, (long int)((ompistop.tv_sec - ompistart.tv_sec)*1000000 + (ompistop.tv_usec - ompistart.tv_usec))); gettimeofday(&stg2start, NULL); } /* start PTL's */ ret = MCA_PML_CALL(enable(true)); if( OMPI_SUCCESS != ret ) { error = "PML control failed"; goto error; } /* add all ompi_proc_t's to PML */ if (NULL == (procs = ompi_proc_world(&nprocs))) { error = "ompi_proc_world() failed"; goto error; } ret = MCA_PML_CALL(add_procs(procs, nprocs)); free(procs); if( OMPI_SUCCESS != ret ) { error = "PML add procs failed"; goto error; } MCA_PML_CALL(add_comm(&ompi_mpi_comm_world)); MCA_PML_CALL(add_comm(&ompi_mpi_comm_self)); /* Figure out the final MPI thread levels. If we were not compiled for support for MPI threads, then don't allow MPI_THREAD_MULTIPLE. */ ompi_mpi_thread_requested = requested; if (OMPI_HAVE_THREAD_SUPPORT == 0) { ompi_mpi_thread_provided = *provided = MPI_THREAD_SINGLE; ompi_mpi_main_thread = NULL; } else if (OMPI_ENABLE_MPI_THREADS == 1) { ompi_mpi_thread_provided = *provided = requested; ompi_mpi_main_thread = opal_thread_get_self(); } else { if (MPI_THREAD_MULTIPLE == requested) { ompi_mpi_thread_provided = *provided = MPI_THREAD_SERIALIZED; } else { ompi_mpi_thread_provided = *provided = requested; } ompi_mpi_main_thread = opal_thread_get_self(); } ompi_mpi_thread_multiple = (ompi_mpi_thread_provided == MPI_THREAD_MULTIPLE); if ((OMPI_ENABLE_PROGRESS_THREADS == 1) || (*provided != MPI_THREAD_SINGLE)) { opal_set_using_threads(true); } /* Init coll for the comms */ if (OMPI_SUCCESS != (ret = mca_coll_base_comm_select(MPI_COMM_WORLD, NULL))) { error = "mca_coll_base_comm_select(MPI_COMM_WORLD) failed"; goto error; } if (OMPI_SUCCESS != (ret = mca_coll_base_comm_select(MPI_COMM_SELF, NULL))) { error = "mca_coll_base_comm_select(MPI_COMM_SELF) failed"; goto error; }#if OMPI_ENABLE_PROGRESS_THREADS && 0 /* BWB - XXX - FIXME - is this actually correct? */ /* setup I/O forwarding */ if (orte_process_info.seed == false) { if (OMPI_SUCCESS != (ret = ompi_mpi_init_io())) { error = "ompi_rte_init_io failed"; goto error; } }#endif /* * Dump all MCA parameters if requested */ if (ompi_mpi_show_mca_params) { ompi_show_all_mca_params(ompi_mpi_comm_world.c_my_rank, nprocs, orte_system_info.nodename); } /* Let system know we are at STG2 Barrier */ if (ORTE_SUCCESS != (ret = orte_smr.set_proc_state(orte_process_info.my_name, ORTE_PROC_STATE_AT_STG2, 0))) { ORTE_ERROR_LOG(ret); error = "set process state failed"; goto error; } /* check for timing request - get stop time and report elapsed time if so */ if (timing) { if (0 != gettimeofday(&ompistop, NULL)) { opal_output(0, "ompi_mpi_init: could not obtain stop time after compound_cmd"); } else { opal_output(0, "ompi_mpi_init: time from stage1 to stage2 %ld usec", (long int)((ompistop.tv_sec - stg2start.tv_sec)*1000000 + (ompistop.tv_usec - stg2start.tv_usec))); } } /* Second barrier -- wait for message from RMGR_PROC_STAGE_GATE_MGR to arrive */ if (ORTE_SUCCESS != (ret = orte_rml.xcast(ORTE_PROC_MY_NAME->jobid, false, NULL, orte_gpr.deliver_notify_msg))) { ORTE_ERROR_LOG(ret); error = "ompi_mpi_init: failed to see all procs register\n"; goto error; } /* check for timing request - get start time */ if (timing) { if (0 != gettimeofday(&stg3start, NULL)) { opal_output(0, "ompi_mpi_init: could not obtain start time for stg3"); } } /* wire up the oob interface, if requested. Do this here because it will go much faster before the event library is switched into non-blocking mode */ if (ompi_mpi_preconnect_oob) { if (OMPI_SUCCESS != (ret = ompi_init_do_oob_preconnect())) { error = "ompi_mpi_do_preconnect_oob() failed"; goto error; } } /* check for timing request - get stop time and report elapsed time if so, then start the clock again */ if (timing) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init[%ld]: time from stage 2 cast to complete oob wireup %ld usec", (long)ORTE_PROC_MY_NAME->vpid, (long int)((ompistop.tv_sec - ompistart.tv_sec)*1000000 + (ompistop.tv_usec - ompistart.tv_usec))); gettimeofday(&ompistart, NULL); }#if OMPI_ENABLE_PROGRESS_THREADS == 0 /* Start setting up the event engine for MPI operations. Don't block in the event library, so that communications don't take forever between procs in the dynamic code. This will increase CPU utilization for the remainder of MPI_INIT when we are blocking on ORTE-level events, but may greatly reduce non-TCP latency. */ opal_progress_events(OPAL_EVLOOP_NONBLOCK);#endif /* Check whether we have been spawned or not. We introduce that at the very end, since we need collectives, datatypes, ptls etc. up and running here.... */ if (OMPI_SUCCESS != (ret = ompi_comm_dyn_init())) { error = "ompi_comm_dyn_init() failed"; goto error; } error: if (ret != OMPI_SUCCESS) { const char *err_msg = opal_strerror(ret); opal_show_help("help-mpi-runtime", "mpi_init:startup:internal-failure", true, "MPI_INIT", "MPI_INIT", error, err_msg, ret); return ret; } /* put the event library in "high performance MPI mode" */ if (OMPI_SUCCESS != (ret = opal_progress_mpi_enable())) { error = "opal_progress_mpi_enable() failed"; /* This will loop back up above, but ret != OMPI_SUCCESS, so we'll end up returning out of this function before getting here (and therefore avoiding an infinite loop) */ goto error; } /* If we want the connection warmup, go do it */ if (ompi_mpi_preconnect_all) { if (OMPI_SUCCESS != (ret = ompi_init_do_preconnect())) { error = "ompi_mpi_do_preconnect_all() failed"; /* This will loop back up above, but ret != OMPI_SUCCESS, so we'll end up returning out of this function before getting here (and therefore avoiding an infinite loop) */ goto error; } } /* All done. Wasn't that simple? */ ompi_mpi_initialized = true; if (orte_debug_flag) { opal_output(0, "[%lu,%lu,%lu] ompi_mpi_init completed", ORTE_NAME_ARGS(orte_process_info.my_name)); } /* Do we need to wait for a TotalView-like debugger? */ ompi_wait_for_totalview(); /* check for timing request - get stop time and report elapsed time if so */ if (timing) { gettimeofday(&ompistop, NULL); opal_output(0, "ompi_mpi_init[%ld]: time from oob wireup to complete mpi_init %ld usec", (long)ORTE_PROC_MY_NAME->vpid, (long int)((ompistop.tv_sec - ompistart.tv_sec)*1000000 + (ompistop.tv_usec - ompistart.tv_usec))); } return MPI_SUCCESS;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?