static int clear_nacks(ptl_process_t target_id) { struct rptl_target *target; struct rptl_op *op; int ret = PTL_OK; MPIDI_STATE_DECL(MPID_STATE_CLEAR_NACKS); MPIDI_FUNC_ENTER(MPID_STATE_CLEAR_NACKS); ret = find_target(target_id, &target); RPTLU_ERR_POP(ret, "error finding target\n"); for (op = target->data_op_list; op; op = op->next) { if ((op->op_type == RPTL_OP_PUT && IDS_ARE_EQUAL(op->u.put.target_id, target_id)) || (op->op_type == RPTL_OP_GET && IDS_ARE_EQUAL(op->u.get.target_id, target_id))) { if (op->state == RPTL_OP_STATE_NACKED) op->state = RPTL_OP_STATE_QUEUED; } } target->state = RPTL_TARGET_STATE_ACTIVE; ret = poke_progress(); RPTLU_ERR_POP(ret, "error in poke_progress\n"); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_CLEAR_NACKS); return ret; fn_fail: goto fn_exit; }
static HYD_status fn_info_putnodeattr(int fd, char *args[]) { struct HYD_string_stash stash; char *key, *val, *thrid, *cmd; struct HYD_pmcd_token *tokens = NULL; int token_count, ret; struct HYD_pmcd_pmi_v2_reqs *req; HYD_status status = HYD_SUCCESS; HYDU_FUNC_ENTER(); status = HYD_pmcd_pmi_args_to_tokens(args, &tokens, &token_count); HYDU_ERR_POP(status, "unable to convert args to tokens\n"); key = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "key"); HYDU_ERR_CHKANDJUMP(status, key == NULL, HYD_INTERNAL_ERROR, "unable to find key token\n"); val = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "value"); HYDU_ERR_CHKANDJUMP(status, val == NULL, HYD_INTERNAL_ERROR, "unable to find value token\n"); thrid = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "thrid"); status = HYD_pmcd_pmi_add_kvs(key, val, HYD_pmcd_pmip.local.kvs, &ret); HYDU_ERR_POP(status, "unable to put data into kvs\n"); HYD_STRING_STASH_INIT(stash); HYD_STRING_STASH(stash, MPL_strdup("cmd=info-putnodeattr-response;"), status); if (thrid) { HYD_STRING_STASH(stash, MPL_strdup("thrid="), status); HYD_STRING_STASH(stash, MPL_strdup(thrid), status); HYD_STRING_STASH(stash, MPL_strdup(";"), status); } HYD_STRING_STASH(stash, MPL_strdup("rc="), status); HYD_STRING_STASH(stash, HYDU_int_to_str(ret), status); HYD_STRING_STASH(stash, MPL_strdup(";"), status); HYD_STRING_SPIT(stash, cmd, status); send_cmd_downstream(fd, cmd); MPL_free(cmd); for (req = pending_reqs; req; req = req->next) { if (!strcmp(req->key, key)) { /* Poke the progress engine before exiting */ status = poke_progress(key); HYDU_ERR_POP(status, "poke progress error\n"); break; } } fn_exit: if (tokens) HYD_pmcd_pmi_free_tokens(tokens, token_count); HYDU_FUNC_EXIT(); return status; fn_fail: goto fn_exit; }
static int rptl_put(ptl_handle_md_t md_handle, ptl_size_t local_offset, ptl_size_t length, ptl_ack_req_t ack_req, ptl_process_t target_id, ptl_pt_index_t pt_index, ptl_match_bits_t match_bits, ptl_size_t remote_offset, void *user_ptr, ptl_hdr_data_t hdr_data, enum rptl_pt_type pt_type) { struct rptl_op *op; int ret = PTL_OK; struct rptl_target *target; MPIDI_STATE_DECL(MPID_STATE_RPTL_PUT); MPIDI_FUNC_ENTER(MPID_STATE_RPTL_PUT); ret = find_target(target_id, &target); RPTLU_ERR_POP(ret, "error finding target structure\n"); ret = rptli_op_alloc(&op, target); RPTLU_ERR_POP(ret, "error allocating op\n"); op->op_type = RPTL_OP_PUT; op->state = RPTL_OP_STATE_QUEUED; /* store the user parameters */ op->u.put.md_handle = md_handle; op->u.put.local_offset = local_offset; op->u.put.length = length; op->u.put.ack_req = ack_req; op->u.put.target_id = target_id; op->u.put.pt_index = pt_index; op->u.put.match_bits = match_bits; op->u.put.remote_offset = remote_offset; op->u.put.user_ptr = user_ptr; op->u.put.hdr_data = hdr_data; /* place to store the send and ack events */ op->u.put.send = NULL; op->u.put.ack = NULL; op->u.put.pt_type = pt_type; op->events_ready = 0; op->target = target; if (op->u.put.pt_type == RPTL_PT_DATA) MPL_DL_APPEND(target->data_op_list, op); else MPL_DL_APPEND(target->control_op_list, op); ret = poke_progress(); RPTLU_ERR_POP(ret, "Error from poke_progress\n"); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_RPTL_PUT); return ret; fn_fail: goto fn_exit; }
static int get_event_info(ptl_event_t * event, struct rptl **ret_rptl, struct rptl_op **ret_op) { struct rptl *rptl; struct rptl_op *op; int ret = PTL_OK; MPIDI_STATE_DECL(MPID_STATE_GET_EVENT_INFO); MPIDI_FUNC_ENTER(MPID_STATE_GET_EVENT_INFO); if (event->type == PTL_EVENT_SEND || event->type == PTL_EVENT_REPLY || event->type == PTL_EVENT_ACK) { op = (struct rptl_op *) event->user_ptr; rptl_info.origin_events_left++; if (event->type != PTL_EVENT_SEND) op->target->issued_data_ops--; /* see if there are any pending ops to be issued */ ret = poke_progress(); RPTLU_ERR_POP(ret, "Error returned from poke_progress\n"); assert(op); rptl = NULL; } else { /* for all target-side events, we look up the rptl based on * the pt_index */ for (rptl = rptl_info.rptl_list; rptl; rptl = rptl->next) if (rptl->data.pt == event->pt_index || rptl->control.pt == event->pt_index) break; assert(rptl); op = NULL; } *ret_rptl = rptl; *ret_op = op; fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_GET_EVENT_INFO); return ret; fn_fail: goto fn_exit; }
int MPID_nem_ptl_rptl_get(ptl_handle_md_t md_handle, ptl_size_t local_offset, ptl_size_t length, ptl_process_t target_id, ptl_pt_index_t pt_index, ptl_match_bits_t match_bits, ptl_size_t remote_offset, void *user_ptr) { struct rptl_op *op; int ret = PTL_OK; struct rptl_target *target; MPIDI_STATE_DECL(MPID_STATE_MPID_NEM_PTL_RPTL_GET); MPIDI_FUNC_ENTER(MPID_STATE_MPID_NEM_PTL_RPTL_GET); ret = find_target(target_id, &target); RPTLU_ERR_POP(ret, "error finding target structure\n"); ret = rptli_op_alloc(&op, target); RPTLU_ERR_POP(ret, "error allocating op\n"); op->op_type = RPTL_OP_GET; op->state = RPTL_OP_STATE_QUEUED; /* store the user parameters */ op->u.get.md_handle = md_handle; op->u.get.local_offset = local_offset; op->u.get.length = length; op->u.get.target_id = target_id; op->u.get.pt_index = pt_index; op->u.get.match_bits = match_bits; op->u.get.remote_offset = remote_offset; op->u.get.user_ptr = user_ptr; op->events_ready = 0; op->target = target; MPL_DL_APPEND(target->data_op_list, op); ret = poke_progress(); RPTLU_ERR_POP(ret, "Error from poke_progress\n"); fn_exit: MPIDI_FUNC_EXIT(MPID_STATE_MPID_NEM_PTL_RPTL_GET); return ret; fn_fail: goto fn_exit; }
static HYD_status fn_kvs_fence(int fd, int pid, int pgid, char *args[]) { struct HYD_proxy *proxy; struct HYD_pmcd_pmi_pg_scratch *pg_scratch; struct HYD_string_stash stash; char *cmd, *thrid; struct HYD_pmcd_token *tokens; int token_count, i; static int fence_count = 0; HYD_status status = HYD_SUCCESS; HYDU_FUNC_ENTER(); status = HYD_pmcd_pmi_args_to_tokens(args, &tokens, &token_count); HYDU_ERR_POP(status, "unable to convert args to tokens\n"); thrid = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "thrid"); proxy = HYD_pmcd_pmi_find_proxy(fd); HYDU_ASSERT(proxy, status); pg_scratch = (struct HYD_pmcd_pmi_pg_scratch *) proxy->pg->pg_scratch; /* Try to find the epoch point of this process */ for (i = 0; i < proxy->pg->pg_process_count; i++) if (pg_scratch->ecount[i].fd == fd && pg_scratch->ecount[i].pid == pid) pg_scratch->ecount[i].epoch++; if (i == proxy->pg->pg_process_count) { /* couldn't find the current process; find a NULL entry */ for (i = 0; i < proxy->pg->pg_process_count; i++) if (pg_scratch->ecount[i].fd == HYD_FD_UNSET) break; pg_scratch->ecount[i].fd = fd; pg_scratch->ecount[i].pid = pid; pg_scratch->ecount[i].epoch = 1; } HYD_STRING_STASH_INIT(stash); HYD_STRING_STASH(stash, HYDU_strdup("cmd=kvs-fence-response;"), status); if (thrid) { HYD_STRING_STASH(stash, HYDU_strdup("thrid="), status); HYD_STRING_STASH(stash, HYDU_strdup(thrid), status); HYD_STRING_STASH(stash, HYDU_strdup(";"), status); } HYD_STRING_STASH(stash, HYDU_strdup("rc=0;"), status); HYD_STRING_SPIT(stash, cmd, status); status = cmd_response(fd, pid, cmd); HYDU_ERR_POP(status, "send command failed\n"); HYDU_FREE(cmd); fence_count++; if (fence_count % proxy->pg->pg_process_count == 0) { /* Poke the progress engine before exiting */ status = poke_progress(NULL); HYDU_ERR_POP(status, "poke progress error\n"); } fn_exit: HYD_pmcd_pmi_free_tokens(tokens, token_count); HYDU_FUNC_EXIT(); return status; fn_fail: goto fn_exit; }
static HYD_status fn_kvs_put(int fd, int pid, int pgid, char *args[]) { struct HYD_string_stash stash; char *key, *val, *thrid, *cmd; int ret; struct HYD_proxy *proxy; struct HYD_pmcd_pmi_pg_scratch *pg_scratch; struct HYD_pmcd_token *tokens; int token_count; struct HYD_pmcd_pmi_v2_reqs *req; HYD_status status = HYD_SUCCESS; HYDU_FUNC_ENTER(); status = HYD_pmcd_pmi_args_to_tokens(args, &tokens, &token_count); HYDU_ERR_POP(status, "unable to convert args to tokens\n"); key = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "key"); HYDU_ERR_CHKANDJUMP(status, key == NULL, HYD_INTERNAL_ERROR, "unable to find key token\n"); val = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "value"); if (val == NULL) { /* the user sent an empty string */ val = HYDU_strdup(""); } thrid = HYD_pmcd_pmi_find_token_keyval(tokens, token_count, "thrid"); proxy = HYD_pmcd_pmi_find_proxy(fd); HYDU_ASSERT(proxy, status); pg_scratch = (struct HYD_pmcd_pmi_pg_scratch *) proxy->pg->pg_scratch; status = HYD_pmcd_pmi_add_kvs(key, val, pg_scratch->kvs, &ret); HYDU_ERR_POP(status, "unable to put data into kvs\n"); HYD_STRING_STASH_INIT(stash); HYD_STRING_STASH(stash, HYDU_strdup("cmd=kvs-put-response;"), status); if (thrid) { HYD_STRING_STASH(stash, HYDU_strdup("thrid="), status); HYD_STRING_STASH(stash, HYDU_strdup(thrid), status); HYD_STRING_STASH(stash, HYDU_strdup(";"), status); } HYD_STRING_STASH(stash, HYDU_strdup("rc="), status); HYD_STRING_STASH(stash, HYDU_int_to_str(ret), status); HYD_STRING_STASH(stash, HYDU_strdup(";"), status); HYD_STRING_SPIT(stash, cmd, status); status = cmd_response(fd, pid, cmd); HYDU_ERR_POP(status, "send command failed\n"); HYDU_FREE(cmd); for (req = pending_reqs; req; req = req->next) { if (!strcmp(req->key, key)) { /* Poke the progress engine before exiting */ status = poke_progress(key); HYDU_ERR_POP(status, "poke progress error\n"); break; } } fn_exit: HYD_pmcd_pmi_free_tokens(tokens, token_count); HYDU_FUNC_EXIT(); return status; fn_fail: goto fn_exit; }