int MPIDI_CH3I_Comm_handle_failed_procs(MPID_Group *new_failed_procs) { int mpi_errno = MPI_SUCCESS; MPID_Comm *comm; int flag = FALSE; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_COMM_HANDLE_FAILED_PROCS); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_COMM_HANDLE_FAILED_PROCS); /* mark communicators with new failed processes as collectively inactive and disable posting anysource receives */ COMM_FOREACH(comm) { /* if this comm is already collectively inactive and anysources are disabled, there's no need to check */ if (!comm->dev.anysource_enabled) continue; mpi_errno = nonempty_intersection(comm, new_failed_procs, &flag); if (mpi_errno) MPIU_ERR_POP(mpi_errno); if (flag) { MPIU_DBG_MSG_FMT(CH3_OTHER, VERBOSE, (MPIU_DBG_FDEST, "disabling AS on communicator %p (%#08x)", comm, comm->handle)); comm->dev.anysource_enabled = FALSE; } } /* Now that we've marked communicators with disable anysource, we complete-with-an-error all anysource receives posted on those communicators */ mpi_errno = MPIDI_CH3U_Complete_disabled_anysources(); if (mpi_errno) MPIU_ERR_POP(mpi_errno); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_COMM_HANDLE_FAILED_PROCS); return mpi_errno; fn_fail: goto fn_exit; }
int MPID_nem_lmt_vmsplice_initiate_lmt(MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt, MPID_Request *sreq) { int mpi_errno = MPI_SUCCESS; MPID_nem_pkt_lmt_rts_t * const rts_pkt = (MPID_nem_pkt_lmt_rts_t *)pkt; MPIDI_CH3I_VC *vc_ch = &vc->ch; int complete = 0; MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_LMT_VMSPLICE_INITIATE_LMT); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_LMT_VMSPLICE_INITIATE_LMT); /* re-use the same pipe per-pair,per-sender */ if (vc_ch->lmt_copy_buf_handle == NULL) { int err; char *pipe_name; MPIDI_CH3I_VC *vc_ch = &vc->ch; pipe_name = tempnam(NULL, "lmt_"); MPIR_ERR_CHKANDJUMP2(!pipe_name, mpi_errno, MPI_ERR_OTHER, "**tempnam", "**tempnam %d %s", errno, MPIU_Strerror(errno)); vc_ch->lmt_copy_buf_handle = MPIU_Strdup(pipe_name); /* XXX DJG hack */ #undef free free(pipe_name); err = mkfifo(vc_ch->lmt_copy_buf_handle, 0660); MPIR_ERR_CHKANDJUMP2(err < 0, mpi_errno, MPI_ERR_OTHER, "**mkfifo", "**mkfifo %d %s", errno, MPIU_Strerror(errno)); } /* can't start sending data yet, need full RTS/CTS handshake */ MPID_nem_lmt_send_RTS(vc, rts_pkt, vc_ch->lmt_copy_buf_handle, strlen(vc_ch->lmt_copy_buf_handle)+1); fn_fail: fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_LMT_VMSPLICE_INITIATE_LMT); return mpi_errno; }
static int vc_init(MPIDI_VC_t *vc) { int mpi_errno = MPI_SUCCESS; MPIDI_CH3I_VC *const vc_ch = &vc->ch; MPID_nem_ptl_vc_area *const vc_ptl = VC_PTL(vc); MPIDI_STATE_DECL(MPID_STATE_VC_INIT); MPIDI_FUNC_ENTER(MPID_STATE_VC_INIT); vc->sendNoncontig_fn = MPID_nem_ptl_SendNoncontig; vc_ch->iStartContigMsg = MPID_nem_ptl_iStartContigMsg; vc_ch->iSendContig = MPID_nem_ptl_iSendContig; vc_ch->num_pkt_handlers = 2; vc_ch->pkt_handler = MPID_nem_ptl_pkt_handlers; MPID_nem_ptl_pkt_handlers[MPIDI_NEM_PTL_PKT_CANCEL_SEND_REQ] = MPID_nem_ptl_pkt_cancel_send_req_handler; MPID_nem_ptl_pkt_handlers[MPIDI_NEM_PTL_PKT_CANCEL_SEND_RESP] = MPID_nem_ptl_pkt_cancel_send_resp_handler; vc_ch->lmt_initiate_lmt = MPID_nem_ptl_lmt_initiate_lmt; vc_ch->lmt_start_recv = MPID_nem_ptl_lmt_start_recv; vc_ch->lmt_start_send = MPID_nem_ptl_lmt_start_send; vc_ch->lmt_handle_cookie = MPID_nem_ptl_lmt_handle_cookie; vc_ch->lmt_done_send = MPID_nem_ptl_lmt_done_send; vc_ch->lmt_done_recv = MPID_nem_ptl_lmt_done_recv; vc->comm_ops = &comm_ops; vc_ch->next = NULL; vc_ch->prev = NULL; vc_ptl->id_initialized = FALSE; vc_ptl->num_queued_sends = 0; mpi_errno = MPID_nem_ptl_init_id(vc); MPIDI_FUNC_EXIT(MPID_STATE_VC_INIT); return mpi_errno; }
static int check_terminating_vcs(void) { int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_CHECK_TERMINATING_VCS); MPIDI_FUNC_ENTER(MPID_STATE_CHECK_TERMINATING_VCS); while (!TERMQ_EMPTY() && MPID_Request_is_complete(TERMQ_HEAD()->req)) { vc_term_element_t *ep; TERMQ_DEQUEUE(&ep); MPID_Request_release(ep->req); mpi_errno = shm_connection_terminated(ep->vc); if (mpi_errno) MPIU_ERR_POP(mpi_errno); MPIU_Free(ep); } fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_CHECK_TERMINATING_VCS); return mpi_errno; fn_fail: goto fn_exit; }
int MPID_Bsend_init(const void * buf, int count, MPI_Datatype datatype, int rank, int tag, MPID_Comm * comm, int context_offset, MPID_Request ** request) { MPID_Request * sreq; int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_MPID_BSEND_INIT); MPIDI_FUNC_ENTER(MPID_STATE_MPID_BSEND_INIT); MPIDI_Request_create_psreq(sreq, mpi_errno, goto fn_exit); MPIDI_Request_set_type(sreq, MPIDI_REQUEST_TYPE_BSEND); if (HANDLE_GET_KIND(datatype) != HANDLE_KIND_BUILTIN) { MPID_Datatype_get_ptr(datatype, sreq->dev.datatype_ptr); MPID_Datatype_add_ref(sreq->dev.datatype_ptr); } *request = sreq; fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPID_BSEND_INIT); return mpi_errno; }
int MPIDI_PG_To_string(MPIDI_PG_t *pg_ptr, char **str_ptr, int *lenStr) { int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_MPIDI_PG_TO_STRING); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_PG_TO_STRING); /* Replace this with the new string */ if (pg_ptr->connInfoToString) { (*pg_ptr->connInfoToString)( str_ptr, lenStr, pg_ptr ); } else { MPIR_ERR_SETANDJUMP(mpi_errno,MPI_ERR_INTERN,"**noConnInfoToString"); } /*printf( "PgToString: Pg string is %s\n", *str_ptr ); fflush(stdout);*/ fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_PG_TO_STRING); return mpi_errno; fn_fail: goto fn_exit; }
static int nonempty_intersection(MPID_Comm *comm, MPID_Group *group, int *flag) { int mpi_errno = MPI_SUCCESS; int i_g, i_c; MPIDI_VC_t *vc_g, *vc_c; MPIDI_STATE_DECL(MPID_STATE_NONEMPTY_INTERSECTION); MPIDI_FUNC_ENTER(MPID_STATE_NONEMPTY_INTERSECTION); /* handle common case fast */ if (comm == MPIR_Process.comm_world || comm == MPIR_Process.icomm_world) { *flag = TRUE; MPIU_DBG_MSG(CH3_OTHER, VERBOSE, "comm is comm_world or icomm_world"); goto fn_exit; } *flag = FALSE; /* FIXME: This algorithm assumes that the number of processes in group is very small (like 1). So doing a linear search for them in comm is better than sorting the procs in comm and group then doing a binary search */ for (i_g = 0; i_g < group->size; ++i_g) { /* FIXME: This won't work for dynamic procs */ MPIDI_PG_Get_vc(MPIDI_Process.my_pg, group->lrank_to_lpid[i_g].lpid, &vc_g); for (i_c = 0; i_c < comm->remote_size; ++i_c) { MPIDI_Comm_get_vc(comm, i_c, &vc_c); if (vc_g == vc_c) { *flag = TRUE; goto fn_exit; } } } fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_NONEMPTY_INTERSECTION); return mpi_errno; fn_fail: goto fn_exit; }
int MPIDI_CH3_SHM_Win_shared_query(MPID_Win *win_ptr, int target_rank, MPI_Aint *size, int *disp_unit, void *baseptr) { int comm_size; int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_WIN_SHARED_QUERY); MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPIDI_CH3_WIN_SHARED_QUERY); comm_size = win_ptr->comm_ptr->local_size; /* Scan the sizes to locate the first process that allocated a nonzero * amount of space */ if (target_rank == MPI_PROC_NULL) { int i; /* Default, if no processes have size > 0. */ *size = 0; *((void**) baseptr) = NULL; for (i = 0; i < comm_size; i++) { if (win_ptr->sizes[i] > 0) { *size = win_ptr->sizes[i]; *((void**) baseptr) = win_ptr->shm_base_addrs[i]; break; } } } else { *size = win_ptr->sizes[target_rank]; *((void**) baseptr) = win_ptr->shm_base_addrs[target_rank]; } fn_exit: MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPIDI_CH3_WIN_SHARED_QUERY); return mpi_errno; fn_fail: goto fn_exit; }
int MPIC_Wait(MPID_Request * request_ptr, mpir_errflag_t *errflag) { int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_MPIC_WAIT); MPIDI_PT2PT_FUNC_ENTER(MPID_STATE_MPIC_WAIT); MPIU_DBG_MSG_S(PT2PT, TYPICAL, "IN: errflag = %s", *errflag?"TRUE":"FALSE"); if (request_ptr->kind == MPID_REQUEST_SEND) request_ptr->status.MPI_TAG = 0; if (!MPID_Request_is_complete(request_ptr)) { MPID_Progress_state progress_state; MPID_Progress_start(&progress_state); while (!MPID_Request_is_complete(request_ptr)) { mpi_errno = MPID_Progress_wait(&progress_state); if (mpi_errno) { MPIU_ERR_POP(mpi_errno); } } MPID_Progress_end(&progress_state); } if (request_ptr->kind == MPID_REQUEST_RECV) MPIR_Process_status(&request_ptr->status, errflag); MPIR_TAG_CLEAR_ERROR_BITS(request_ptr->status.MPI_TAG); fn_exit: MPIU_DBG_MSG_D(PT2PT, TYPICAL, "OUT: errflag = %d", *errflag); MPIDI_PT2PT_FUNC_EXIT(MPID_STATE_MPIC_WAIT); return mpi_errno; fn_fail: /* --BEGIN ERROR HANDLING-- */ goto fn_exit; /* --END ERROR HANDLING-- */ }
int MPID_nem_ptl_get_id_from_bc(const char *business_card, ptl_process_t *id, ptl_pt_index_t *pt, ptl_pt_index_t *ptg, ptl_pt_index_t *ptc, ptl_pt_index_t *ptr, ptl_pt_index_t *ptrg, ptl_pt_index_t *ptrc) { int mpi_errno = MPI_SUCCESS; int ret; int len; MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_GET_ID_FROM_BC); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_GET_ID_FROM_BC); ret = MPIU_Str_get_binary_arg(business_card, NID_KEY, (char *)&id->phys.nid, sizeof(id->phys.nid), &len); MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(id->phys.nid), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard"); ret = MPIU_Str_get_binary_arg(business_card, PID_KEY, (char *)&id->phys.pid, sizeof(id->phys.pid), &len); MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(id->phys.pid), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard"); ret = MPIU_Str_get_binary_arg(business_card, PTI_KEY, (char *)pt, sizeof(pt), &len); MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(*pt), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard"); ret = MPIU_Str_get_binary_arg(business_card, PTIG_KEY, (char *)ptg, sizeof(ptg), &len); MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(*ptg), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard"); ret = MPIU_Str_get_binary_arg(business_card, PTIC_KEY, (char *)ptc, sizeof(ptc), &len); MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(*ptc), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard"); ret = MPIU_Str_get_binary_arg(business_card, PTIR_KEY, (char *)ptr, sizeof(ptr), &len); MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(*ptr), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard"); ret = MPIU_Str_get_binary_arg(business_card, PTIRG_KEY, (char *)ptrg, sizeof(ptr), &len); MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(*ptrc), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard"); ret = MPIU_Str_get_binary_arg(business_card, PTIRC_KEY, (char *)ptrc, sizeof(ptr), &len); MPIU_ERR_CHKANDJUMP(ret != MPIU_STR_SUCCESS || len != sizeof(*ptrc), mpi_errno, MPI_ERR_OTHER, "**badbusinesscard"); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_GET_ID_FROM_BC); return mpi_errno; fn_fail: goto fn_exit; }
int MPID_nem_tcp_vc_terminated(MPIDI_VC_t *vc) { /* This is called when the VC is to be terminated once all queued sends have been sent. */ int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_NEM_TCP_VC_TERMINATED); MPIDI_FUNC_ENTER(MPID_NEM_TCP_VC_TERMINATED); mpi_errno = MPID_nem_tcp_cleanup(vc); if (mpi_errno) MPIR_ERR_POP(mpi_errno); mpi_errno = MPIDI_CH3U_Handle_connection(vc, MPIDI_VC_EVENT_TERMINATED); if(mpi_errno) MPIR_ERR_POP(mpi_errno); fn_exit: MPIDI_FUNC_EXIT(MPID_NEM_TCP_VC_TERMINATED); return mpi_errno; fn_fail: MPIU_DBG_MSG_FMT(NEM_SOCK_DET, VERBOSE, (MPIU_DBG_FDEST, "failure. mpi_errno = %d", mpi_errno)); goto fn_exit; }
int MPID_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPID_Win * win_ptr) { int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_MPID_ACCUMULATE); MPIDI_RMA_FUNC_ENTER(MPID_STATE_MPID_ACCUMULATE); mpi_errno = MPIDI_CH3I_Accumulate(origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, op, win_ptr, NULL); fn_exit: MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_ACCUMULATE); return mpi_errno; /* --BEGIN ERROR HANDLING-- */ fn_fail: goto fn_exit; /* --END ERROR HANDLING-- */ }
int MPIDI_CH3_Prepare_rndv_get(MPIDI_VC_t * vc, MPID_Request * rreq) { int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PREPARE_RNDV_GET); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PREPARE_RNDV_GET); #ifdef CKPT MPIDI_CH3I_CR_lock(); #endif MPIU_Assert(VAPI_PROTOCOL_RGET == rreq->mrail.protocol); MPIDI_CH3I_MRAIL_Prepare_rndv(vc, rreq); #ifdef CKPT MPIDI_CH3I_CR_unlock(); #endif MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PREPARE_RNDV_GET); return mpi_errno; }
int MPID_nem_tcp_vc_terminate(MPIDI_VC_t *vc) { int mpi_errno = MPI_SUCCESS; int req_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_TCP_VC_TERMINATE); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_TCP_VC_TERMINATE); if (vc->state != MPIDI_VC_STATE_CLOSED) { /* VC is terminated as a result of a fault. Complete outstanding sends with an error and terminate connection immediately. */ MPIR_ERR_SET1(req_errno, MPIX_ERR_PROC_FAILED, "**comm_fail", "**comm_fail %d", vc->pg_rank); mpi_errno = MPID_nem_tcp_error_out_send_queue(vc, req_errno); if (mpi_errno) MPIR_ERR_POP(mpi_errno); mpi_errno = MPID_nem_tcp_vc_terminated(vc); if (mpi_errno) MPIR_ERR_POP(mpi_errno); } else { MPID_nem_tcp_vc_area *vc_tcp = VC_TCP(vc); /* VC is terminated as a result of the close protocol. Wait for sends to complete, then terminate. */ if (MPIDI_CH3I_Sendq_empty(vc_tcp->send_queue)) { /* The sendq is empty, so we can immediately terminate the connection. */ mpi_errno = MPID_nem_tcp_vc_terminated(vc); if (mpi_errno) MPIR_ERR_POP(mpi_errno); } /* else: just return. We'll call vc_terminated() from the commrdy_handler once the sendq is empty. */ } fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_TCP_VC_TERMINATE); return mpi_errno; fn_fail: goto fn_exit; }
static int handler_send(const ptl_event_t *e) { int mpi_errno = MPI_SUCCESS; MPID_Request *const sreq = e->user_ptr; int i, ret; MPIDI_STATE_DECL(MPID_STATE_HANDLER_SEND); MPIDI_FUNC_ENTER(MPID_STATE_HANDLER_SEND); MPIU_Assert(e->type == PTL_EVENT_SEND || e->type == PTL_EVENT_GET); /* if we are done, release all netmod resources */ if (MPID_cc_get(sreq->cc) == 1) { if (REQ_PTL(sreq)->md != PTL_INVALID_HANDLE) { ret = PtlMDRelease(REQ_PTL(sreq)->md); MPIR_ERR_CHKANDJUMP1(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmdrelease", "**ptlmdrelease %s", MPID_nem_ptl_strerror(ret)); } for (i = 0; i < MPID_NEM_PTL_NUM_CHUNK_BUFFERS; ++i) if (REQ_PTL(sreq)->chunk_buffer[i]) MPIU_Free(REQ_PTL(sreq)->chunk_buffer[i]); if (REQ_PTL(sreq)->get_me_p) MPIU_Free(REQ_PTL(sreq)->get_me_p); } mpi_errno = MPID_Request_complete(sreq); if (mpi_errno != MPI_SUCCESS) { MPIR_ERR_POP(mpi_errno); } fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_HANDLER_SEND); return mpi_errno; fn_fail: goto fn_exit; }
int rptli_post_control_buffer(ptl_handle_ni_t ni_handle, ptl_pt_index_t pt, ptl_handle_me_t * me_handle) { int ret; ptl_me_t me; ptl_process_t id; MPIDI_STATE_DECL(MPID_STATE_RPTLI_POST_CONTROL_BUFFER); MPIDI_FUNC_ENTER(MPID_STATE_RPTLI_POST_CONTROL_BUFFER); id.phys.nid = PTL_NID_ANY; id.phys.pid = PTL_PID_ANY; me.start = NULL; me.length = 0; me.ct_handle = PTL_CT_NONE; me.uid = PTL_UID_ANY; me.options = (PTL_ME_OP_PUT | PTL_ME_OP_GET | PTL_ME_USE_ONCE | PTL_ME_IS_ACCESSIBLE | PTL_ME_EVENT_LINK_DISABLE | PTL_ME_EVENT_UNLINK_DISABLE); me.match_id = id; me.match_bits = 0; me.ignore_bits = 0; me.min_free = 0; while (1) { ret = PtlMEAppend(ni_handle, pt, &me, PTL_PRIORITY_LIST, NULL, me_handle); if (ret != PTL_NO_SPACE) break; } RPTLU_ERR_POP(ret, "Error appending empty buffer to priority list\n"); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_RPTLI_POST_CONTROL_BUFFER); return ret; fn_fail: goto fn_exit; }
int MPIDI_CH3_VC_Destroy(struct MPIDI_VC* vc) { MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_VC_DESTROY); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_VC_DESTROY); #if !defined (_OSU_PSM_) if(vc->smp.sendq_head != NULL) { MPIU_Free(vc->smp.sendq_head); } if(vc->smp.sendq_tail != NULL) { MPIU_Free(vc->smp.sendq_tail); } if(vc->smp.recv_active != NULL) { MPIU_Free(vc->smp.recv_active); } if(vc->smp.send_active != NULL) { MPIU_Free(vc->smp.send_active); } if(vc->ch.req != NULL) { MPIU_Free(vc->ch.req); } #ifndef DAPL_DEFAULT_PROVIDER if(vc->mrail.cmanager.msg_channels != NULL) { MPIU_Free(vc->mrail.cmanager.msg_channels); } if(vc->mrail.srp.credits != NULL) { MPIU_Free(vc->mrail.srp.credits); } if(vc->mrail.rails != NULL) { MPIU_Free(vc->mrail.rails); } #endif /* #ifndef DAPL_DEFAULT_PROVIDER */ #endif /* #if !defined (_OSU_PSM_) */ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3_VC_DESTROY); return MPI_SUCCESS; }
int MPIDI_CH3U_Comm_register_destroy_hook(int (*hook_fn)(struct MPID_Comm *, void *), void *param) { int mpi_errno = MPI_SUCCESS; hook_elt *elt; MPIU_CHKPMEM_DECL(1); MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_COMM_REGISTER_DESTROY_HOOK); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_COMM_REGISTER_DESTROY_HOOK); MPIU_CHKPMEM_MALLOC(elt, hook_elt *, sizeof(hook_elt), mpi_errno, "hook_elt"); elt->hook_fn = hook_fn; elt->param = param; MPL_LL_PREPEND(destroy_hooks_head, destroy_hooks_tail, elt); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_COMM_REGISTER_DESTROY_HOOK); return mpi_errno; fn_fail: MPIU_CHKPMEM_REAP(); goto fn_exit; }
int MPID_nem_ptl_poll_finalize(void) { int mpi_errno = MPI_SUCCESS; int i; int ret; MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_POLL_FINALIZE); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_POLL_FINALIZE); for (i = 0; i < NUM_OVERFLOW_ME; ++i) { if (overflow_me_handle[i] != PTL_INVALID_HANDLE) { ret = PtlMEUnlink(overflow_me_handle[i]); MPIR_ERR_CHKANDJUMP1(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmeunlink", "**ptlmeunlink %s", MPID_nem_ptl_strerror(ret)); } MPL_free(overflow_buf[i]); } fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_POLL_FINALIZE); return mpi_errno; fn_fail: goto fn_exit; }
int MPID_nem_mxm_poll(int in_blocking_progress) { int mpi_errno = MPI_SUCCESS; MPID_Request *req = NULL; MPIDI_STATE_DECL(MPID_STATE_MXM_POLL); MPIDI_FUNC_ENTER(MPID_STATE_MXM_POLL); while (!MPID_nem_mxm_queue_empty(mxm_obj->sreq_queue)) { MPID_nem_mxm_queue_dequeue(&mxm_obj->sreq_queue, &req); _mxm_handle_sreq(req); } mpi_errno = _mxm_poll(); if (mpi_errno) MPIR_ERR_POP(mpi_errno); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MXM_POLL); return mpi_errno; fn_fail: goto fn_exit; }
int MPIDI_CH3U_Handle_send_req(MPIDI_VC_t * vc, MPID_Request * sreq, int *complete) { int mpi_errno = MPI_SUCCESS; int (*reqFn) (MPIDI_VC_t *, MPID_Request *, int *); MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3U_HANDLE_SEND_REQ); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3U_HANDLE_SEND_REQ); /* Use the associated function rather than switching on the old ca field */ /* Routines can call the attached function directly */ reqFn = sreq->dev.OnDataAvail; if (!reqFn) { MPIU_Assert(MPIDI_Request_get_type(sreq) != MPIDI_REQUEST_TYPE_GET_RESP); MPIDI_CH3U_Request_complete(sreq); *complete = 1; } else { mpi_errno = reqFn(vc, sreq, complete); } MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3U_HANDLE_SEND_REQ); return mpi_errno; }
int MPID_nem_lmt_dma_initiate_lmt(MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt, MPID_Request *sreq) { int mpi_errno = MPI_SUCCESS; MPID_nem_pkt_lmt_rts_t * const rts_pkt = (MPID_nem_pkt_lmt_rts_t *)pkt; MPIU_CHKPMEM_DECL(1); MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_LMT_DMA_INITIATE_LMT); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_LMT_DMA_INITIATE_LMT); MPIU_CHKPMEM_MALLOC(sreq->ch.s_cookie, knem_cookie_t *, sizeof(knem_cookie_t), mpi_errno, "s_cookie"); mpi_errno = send_sreq_data(vc, sreq, sreq->ch.s_cookie); if (mpi_errno) MPIU_ERR_POP(mpi_errno); MPID_nem_lmt_send_RTS(vc, rts_pkt, sreq->ch.s_cookie, sizeof(knem_cookie_t)); fn_exit: MPIU_CHKPMEM_COMMIT(); MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_LMT_DMA_INITIATE_LMT); return mpi_errno; fn_fail: MPIU_CHKPMEM_REAP(); goto fn_exit; }
int MPID_nem_scif_error_out_send_queue(struct MPIDI_VC *const vc, int req_errno) { int mpi_errno = MPI_SUCCESS; MPID_Request *req; MPID_nem_scif_vc_area *const vc_scif = VC_SCIF(vc); MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_SCIF_ERROR_OUT_SEND_QUEUE); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_SCIF_ERROR_OUT_SEND_QUEUE); /* we don't call onDataAvail or onFinal handlers because this is * an error condition and we just want to mark them as complete */ /* send queue */ while (!MPIDI_CH3I_Sendq_empty(vc_scif->send_queue)) { MPIDI_CH3I_Sendq_dequeue(&vc_scif->send_queue, &req); req->status.MPI_ERROR = req_errno; MPIDI_CH3U_Request_complete(req); } MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_SCIF_ERROR_OUT_SEND_QUEUE); return mpi_errno; }
int comm_created(MPID_Comm *comm, void *param) { int mpi_errno = MPI_SUCCESS; MPIDI_STATE_DECL(MPID_STATE_COMM_CREATED); MPIDI_FUNC_ENTER(MPID_STATE_COMM_CREATED); comm->dev.anysource_enabled = TRUE; /* Use the VC's eager threshold by default. */ comm->dev.eager_max_msg_sz = -1; /* Initialize the last acked failure to -1 */ comm->dev.last_ack_rank = -1; COMM_ADD(comm); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_COMM_CREATED); return mpi_errno; fn_fail: goto fn_exit; }
static int pkt_ckpt_marker_handler(MPIDI_VC_t *vc, MPIDI_CH3_Pkt_t *pkt, MPIDI_msg_sz_t *buflen, MPID_Request **req) { int mpi_errno = MPI_SUCCESS; MPID_nem_pkt_ckpt_marker_t * const ckpt_pkt = (MPID_nem_pkt_ckpt_marker_t *)pkt; MPIDI_STATE_DECL(MPID_STATE_PKT_CKPT_MARKER_HANDLER); MPIDI_FUNC_ENTER(MPID_STATE_PKT_CKPT_MARKER_HANDLER); if (!checkpointing) { mpi_errno = MPIDI_nem_ckpt_start(); if (mpi_errno) MPIU_ERR_POP(mpi_errno); } MPIU_Assert(current_wave == ckpt_pkt->wave); --marker_count; /* We're checkpointing the shared memory region, so we don't need to flush the channels between local processes, only remote processes */ if (marker_count == 0) { MPIDI_nem_ckpt_finish_checkpoint = TRUE; /* make sure we break out of receive loop into progress loop */ MPIDI_CH3_Progress_signal_completion(); } *buflen = sizeof(MPIDI_CH3_Pkt_t); *req = NULL; fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_PKT_CKPT_MARKER_HANDLER); return mpi_errno; fn_fail: goto fn_exit; }
int MPIDI_CH3_Rendezvous_push(MPIDI_VC_t * vc, MPID_Request * sreq) { MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_RNDV_PUSH); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_RNDV_PUSH); if (SMP_INIT && vc->smp.local_nodes >= 0 && vc->smp.local_nodes != g_smpi.my_local_id) { MPIU_Assert(sreq->mrail.protocol == VAPI_PROTOCOL_R3); MPIDI_CH3_SMP_Rendezvous_push(vc, sreq); return MPI_SUCCESS; } switch (sreq->mrail.protocol) { case VAPI_PROTOCOL_RPUT: MPIDI_CH3I_MRAILI_Rendezvous_rput_push(vc, sreq); break; case VAPI_PROTOCOL_RGET: MPIDI_CH3I_MRAILI_Rendezvous_rget_push(vc, sreq); break; #ifdef _ENABLE_UD_ case VAPI_PROTOCOL_UD_ZCOPY: MPIDI_CH3I_MRAILI_Rendezvous_zcopy_push(vc, sreq, &(MPIDI_CH3I_RDMA_Process.zcopy_info)); break; #endif default: MPIDI_CH3_Rendezvous_r3_push(vc, sreq); break; } MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_RNDV_PUSH); return MPI_SUCCESS; }
static int append_overflow(int i) { int mpi_errno = MPI_SUCCESS; int ret; ptl_me_t me; ptl_process_t id_any; MPIDI_STATE_DECL(MPID_STATE_APPEND_OVERFLOW); MPIDI_FUNC_ENTER(MPID_STATE_APPEND_OVERFLOW); MPIU_Assert(i >= 0 && i < NUM_OVERFLOW_ME); id_any.phys.pid = PTL_PID_ANY; id_any.phys.nid = PTL_NID_ANY; me.start = overflow_buf[i]; me.length = OVERFLOW_LENGTH; me.ct_handle = PTL_CT_NONE; me.uid = PTL_UID_ANY; me.options = ( PTL_ME_OP_PUT | PTL_ME_MANAGE_LOCAL | PTL_ME_NO_TRUNCATE | PTL_ME_MAY_ALIGN | PTL_ME_IS_ACCESSIBLE | PTL_ME_EVENT_LINK_DISABLE ); me.match_id = id_any; me.match_bits = 0; me.ignore_bits = ~((ptl_match_bits_t)0); me.min_free = PTL_LARGE_THRESHOLD; /* if there is no space to append the entry, process outstanding events and try again */ ret = PtlMEAppend(MPIDI_nem_ptl_ni, MPIDI_nem_ptl_pt, &me, PTL_OVERFLOW_LIST, (void *)(size_t)i, &overflow_me_handle[i]); MPIR_ERR_CHKANDJUMP1(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmeappend", "**ptlmeappend %s", MPID_nem_ptl_strerror(ret)); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_APPEND_OVERFLOW); return mpi_errno; fn_fail: goto fn_exit; }
int MPID_GPID_GetAllInComm( MPID_Comm *comm_ptr, int local_size, MPID_Gpid local_gpids[], int *singlePG ) { int mpi_errno = MPI_SUCCESS; int i; int *gpid = (int*)&local_gpids[0]; int lastPGID = -1, pgid; MPIDI_VCR vc; MPIDI_STATE_DECL(MPID_STATE_MPID_GPID_GETALLINCOMM); MPIDI_FUNC_ENTER(MPID_STATE_MPID_GPID_GETALLINCOMM); MPIU_Assert(comm_ptr->local_size == local_size); *singlePG = 1; for (i=0; i<comm_ptr->local_size; i++) { vc = comm_ptr->dev.vcrt->vcr_table[i]; /* Get the process group id as an int */ MPIDI_PG_IdToNum( vc->pg, &pgid ); *gpid++ = pgid; if (lastPGID != pgid) { if (lastPGID != -1) *singlePG = 0; lastPGID = pgid; } *gpid++ = vc->pg_rank; MPIU_DBG_MSG_FMT(COMM,VERBOSE, (MPIU_DBG_FDEST, "pgid=%d vc->pg_rank=%d", pgid, vc->pg_rank)); } MPIDI_FUNC_EXIT(MPID_STATE_MPID_GPID_GETALLINCOMM); return mpi_errno; }
static int MPIDI_Open_port(MPID_Info *info_ptr, char *port_name) { int mpi_errno = MPI_SUCCESS; int str_errno = MPIU_STR_SUCCESS; int len; int port_name_tag = 0; /* this tag is added to the business card, which is then returned as the port name */ int myRank = MPIR_Process.comm_world->rank; MPIDI_STATE_DECL(MPID_STATE_MPIDI_OPEN_PORT); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_OPEN_PORT); mpi_errno = get_port_name_tag(&port_name_tag); MPIR_ERR_CHKANDJUMP(mpi_errno,mpi_errno,MPI_ERR_OTHER,"**argstr_port_name_tag"); len = MPI_MAX_PORT_NAME; str_errno = MPIU_Str_add_int_arg(&port_name, &len, MPIDI_CH3I_PORT_NAME_TAG_KEY, port_name_tag); MPIR_ERR_CHKANDJUMP(str_errno, mpi_errno, MPI_ERR_OTHER, "**argstr_port_name_tag"); /* This works because Get_business_card uses the same MPIU_Str_xxx functions as above to add the business card to the input string */ /* FIXME: We should instead ask the mpid_pg routines to give us a connection string. There may need to be a separate step to restrict us to a connection information that is only valid for connections between processes that are started separately (e.g., may not use shared memory). We may need a channel-specific function to create an exportable connection string. */ mpi_errno = MPIDI_CH3_Get_business_card(myRank, port_name, len); MPIU_DBG_MSG_FMT(CH3, VERBOSE, (MPIU_DBG_FDEST, "port_name = %s", port_name)); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_OPEN_PORT); return mpi_errno; fn_fail: goto fn_exit; }
int MPIDI_CH3_Init(int has_parent, MPIDI_PG_t *pg_p, int pg_rank) { int mpi_errno = MPI_SUCCESS; int i; MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_INIT); MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_INIT); /* Override split_type */ MPID_Comm_fns = &comm_fns; mpi_errno = MPID_nem_init (pg_rank, pg_p, has_parent); if (mpi_errno) MPIR_ERR_POP (mpi_errno); nemesis_initialized = 1; MPIDI_CH3I_my_rank = pg_rank; MPIDI_CH3I_my_pg = pg_p; /* * Initialize Progress Engine */ mpi_errno = MPIDI_CH3I_Progress_init(); if (mpi_errno) MPIR_ERR_SETFATALANDJUMP (mpi_errno, MPI_ERR_OTHER, "**init_progress"); for (i = 0; i < pg_p->size; i++) { mpi_errno = MPIDI_CH3_VC_Init(&pg_p->vct[i]); if (mpi_errno) MPIR_ERR_POP(mpi_errno); } fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3_INIT); return mpi_errno; fn_fail: goto fn_exit; }