int MPIR_Init_async_thread(void) { #if MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE int mpi_errno = MPI_SUCCESS; MPIR_Comm *comm_self_ptr; int err = 0; MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPIR_INIT_ASYNC_THREAD); MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPIR_INIT_ASYNC_THREAD); /* Dup comm world for the progress thread */ MPIR_Comm_get_ptr(MPI_COMM_SELF, comm_self_ptr); mpi_errno = MPIR_Comm_dup_impl(comm_self_ptr, &progress_comm_ptr); if (mpi_errno) MPIR_ERR_POP(mpi_errno); MPID_Thread_cond_create(&progress_cond, &err); MPIR_ERR_CHKANDJUMP1(err, mpi_errno, MPI_ERR_OTHER, "**cond_create", "**cond_create %s", strerror(err)); MPID_Thread_mutex_create(&progress_mutex, &err); MPIR_ERR_CHKANDJUMP1(err, mpi_errno, MPI_ERR_OTHER, "**mutex_create", "**mutex_create %s", strerror(err)); MPID_Thread_create((MPID_Thread_func_t) progress_fn, NULL, &progress_thread_id, &err); MPIR_ERR_CHKANDJUMP1(err, mpi_errno, MPI_ERR_OTHER, "**mutex_create", "**mutex_create %s", strerror(err)); MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPIR_INIT_ASYNC_THREAD); fn_exit: return mpi_errno; fn_fail: goto fn_exit; #else return MPI_SUCCESS; #endif /* MPICH_THREAD_LEVEL == MPI_THREAD_MULTIPLE */ }
int MPIDI_CH3I_Progress_init(void) { int i; int mpi_errno = MPI_SUCCESS; MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_INIT); MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_INIT); MPIR_THREAD_CHECK_BEGIN; /* FIXME should be appropriately abstracted somehow */ # if defined(MPICH_IS_THREADED) && (MPICH_THREAD_GRANULARITY == MPICH_THREAD_GRANULARITY__GLOBAL) { int err; MPID_Thread_cond_create(&MPIDI_CH3I_progress_completion_cond, &err); MPIR_Assert(err == 0); } # endif MPIR_THREAD_CHECK_END; mpi_errno = MPIDI_CH3I_Sock_init(); if (mpi_errno != MPI_SUCCESS) { MPIR_ERR_POP(mpi_errno); } /* create sock set */ mpi_errno = MPIDI_CH3I_Sock_create_set(&MPIDI_CH3I_sock_set); if (mpi_errno != MPI_SUCCESS) { MPIR_ERR_POP(mpi_errno); } /* establish non-blocking listener */ mpi_errno = MPIDU_CH3I_SetupListener( MPIDI_CH3I_sock_set ); if (mpi_errno) { MPIR_ERR_POP(mpi_errno); } /* Initialize the code to handle incoming packets */ mpi_errno = MPIDI_CH3_PktHandler_Init( pktArray, MPIDI_CH3_PKT_END_CH3+1 ); if (mpi_errno) { MPIR_ERR_POP(mpi_errno); } /* Initialize progress hook slots */ for (i = 0; i < MAX_PROGRESS_HOOKS; i++) { progress_hooks[i].func_ptr = NULL; progress_hooks[i].active = FALSE; } fn_exit: MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_INIT); return mpi_errno; fn_fail: goto fn_exit; }