📄 ns_proxy_general_fns.c
字号:
if (NULL == name) { name = "NULL"; } if (0 > (rc = orte_dss.pack(cmd, &name, 1, ORTE_STRING))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(cmd); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return rc; } if (0 > orte_rml.send_buffer(ORTE_NS_MY_REPLICA, cmd, ORTE_RML_TAG_NS, 0)) { ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); OBJ_RELEASE(cmd); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_COMM_FAILURE; } OBJ_RELEASE(cmd); if ((answer = OBJ_NEW(orte_buffer_t)) == NULL) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_OUT_OF_RESOURCE; } if (0 > orte_rml.recv_buffer(ORTE_NS_MY_REPLICA, answer, ORTE_RML_TAG_NS)) { ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); OBJ_RELEASE(answer); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_COMM_FAILURE; } count = 1; if (ORTE_SUCCESS != (rc = orte_dss.unpack(answer, &command, &count, ORTE_NS_CMD))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(answer); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return rc; } if (ORTE_NS_ASSIGN_OOB_TAG_CMD != command) { ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); OBJ_RELEASE(answer); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_COMM_FAILURE; } count = 1; if (ORTE_SUCCESS != (rc = orte_dss.unpack(answer, tag, &count, ORTE_RML_TAG))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(answer); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return rc; } OBJ_RELEASE(answer); /* add the new tag to the local list so we don't have to get it again */ tagitem = OBJ_NEW(orte_ns_proxy_tagitem_t); if (NULL == tagitem) { /* out of memory */ ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_OUT_OF_RESOURCE; } if (ORTE_SUCCESS != (rc = orte_pointer_array_add(&i, orte_ns_proxy.tags, tagitem))) { ORTE_ERROR_LOG(rc); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return rc; } tagitem->tag = *tag; (orte_ns_proxy.num_tags)++; if (NULL != name) { /* provided - can look it up later */ tagitem->name = strdup(name); } else { tagitem->name = NULL; } OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); /* all done */ return ORTE_SUCCESS;}int orte_ns_proxy_define_data_type(const char *name, orte_data_type_t *type){ orte_buffer_t* cmd; orte_buffer_t* answer; orte_ns_cmd_flag_t command; orte_ns_proxy_dti_t **dti, *dtip; orte_std_cntr_t count, i, j; int rc=ORTE_SUCCESS; if (NULL == name || 0 < *type) { ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); return ORTE_ERR_BAD_PARAM; } OPAL_THREAD_LOCK(&orte_ns_proxy.mutex); /* first, check to see if name is already on local list * if so, return id, ensure registered with dss */ dti = (orte_ns_proxy_dti_t**)orte_ns_proxy.dts->addr; for (i=0, j=0; j < orte_ns_proxy.num_dts && i < orte_ns_proxy.dts->size; i++) { if (NULL != dti[i]) { j++; if (dti[i]->name != NULL && 0 == strcmp(name, dti[i]->name)) { /* found name on list */ *type = dti[i]->id; OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_SUCCESS; } } } /* okay, not on local list - so go get one from tag server */ command = ORTE_NS_DEFINE_DATA_TYPE_CMD; *type = ORTE_DSS_ID_MAX; /* set the default error value */ if ((cmd = OBJ_NEW(orte_buffer_t)) == NULL) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_OUT_OF_RESOURCE; } if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, (void*)&command, 1, ORTE_NS_CMD))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(cmd); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return rc; } if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, (void*)&name, 1, ORTE_STRING))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(cmd); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return rc; } if (0 > orte_rml.send_buffer(ORTE_NS_MY_REPLICA, cmd, ORTE_RML_TAG_NS, 0)) { ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); OBJ_RELEASE(cmd); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_COMM_FAILURE; } OBJ_RELEASE(cmd); if ((answer = OBJ_NEW(orte_buffer_t)) == NULL) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_OUT_OF_RESOURCE; } if (0 > orte_rml.recv_buffer(ORTE_NS_MY_REPLICA, answer, ORTE_RML_TAG_NS)) { ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); OBJ_RELEASE(answer); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_COMM_FAILURE; } count = 1; if (ORTE_SUCCESS != (rc = orte_dss.unpack(answer, &command, &count, ORTE_NS_CMD))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(answer); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return rc; } if (ORTE_NS_ASSIGN_OOB_TAG_CMD != command) { ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); OBJ_RELEASE(answer); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_COMM_FAILURE; } count = 1; if (ORTE_SUCCESS != (rc = orte_dss.unpack(answer, type, &count, ORTE_DATA_TYPE))) { ORTE_ERROR_LOG(ORTE_ERR_UNPACK_FAILURE); OBJ_RELEASE(answer); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_UNPACK_FAILURE; } OBJ_RELEASE(answer); /* add the new id to the local list so we don't have to get it again */ dtip = OBJ_NEW(orte_ns_proxy_dti_t); if (NULL == dtip) { /* out of memory */ ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return ORTE_ERR_OUT_OF_RESOURCE; } dtip->name = strdup(name); if (ORTE_SUCCESS != (rc = orte_pointer_array_add(&i, orte_ns_proxy.dts, dtip))) { ORTE_ERROR_LOG(rc); OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); return rc; } dtip->id = *type; (orte_ns_proxy.num_dts)++; OPAL_THREAD_UNLOCK(&orte_ns_proxy.mutex); /* all done */ return rc;}/* * Take advantage of the way the RML uses the process name as its index into * the RML communicator table. Because the RML needs a name right away, it will * automatically assign us one when it receives a message - and it communicates * that assignment back to us automatically. Thus, to get a name for ourselves, * all we have to do is send a message! No response from the replica is required. */int orte_ns_proxy_create_my_name(void){ orte_buffer_t* cmd; orte_ns_cmd_flag_t command; int rc; command = ORTE_NS_CREATE_MY_NAME_CMD; cmd = OBJ_NEW(orte_buffer_t); if (cmd == NULL) { ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); return ORTE_ERR_OUT_OF_RESOURCE; } if (ORTE_SUCCESS != (rc = orte_dss.pack(cmd, &command, 1, ORTE_NS_CMD))) { ORTE_ERROR_LOG(rc); OBJ_RELEASE(cmd); return rc; } if (0 > orte_rml.send_buffer(ORTE_NS_MY_REPLICA, cmd, ORTE_RML_TAG_NS, 0)) { ORTE_ERROR_LOG(ORTE_ERR_COMM_FAILURE); OBJ_RELEASE(cmd); return ORTE_ERR_COMM_FAILURE; } OBJ_RELEASE(cmd); return ORTE_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -