/* * Look for an existing usnic proc based on a hashed RTE process * name. */ ompi_btl_usnic_endpoint_t * ompi_btl_usnic_proc_lookup_endpoint(ompi_btl_usnic_module_t *receiver, uint64_t sender_hashed_rte_name) { ompi_btl_usnic_proc_t *proc; ompi_btl_usnic_endpoint_t *endpoint; opal_list_item_t *item; MSGDEBUG1_OUT("lookup_endpoint: recvmodule=%p sendhash=0x%" PRIx64, (void *)receiver, sender_hashed_rte_name); for (item = opal_list_get_first(&receiver->all_endpoints); item != opal_list_get_end(&receiver->all_endpoints); item = opal_list_get_next(item)) { endpoint = container_of(item, ompi_btl_usnic_endpoint_t, endpoint_endpoint_li); proc = endpoint->endpoint_proc; if (ompi_rte_hash_name(&proc->proc_ompi->proc_name) == sender_hashed_rte_name) { MSGDEBUG1_OUT("lookup_endpoint: matched endpoint=%p", (void *)endpoint); return endpoint; } } /* Didn't find it */ return NULL; }
/* * Look for an existing SCTP process instance based on the globally unique * process identifier. */ mca_btl_sctp_proc_t* mca_btl_sctp_proc_lookup(const ompi_process_name_t *name) { mca_btl_sctp_proc_t* proc = NULL; OPAL_THREAD_LOCK(&mca_btl_sctp_component.sctp_lock); opal_hash_table_get_value_uint64(&mca_btl_sctp_component.sctp_procs, ompi_rte_hash_name(name), (void**)&proc); OPAL_THREAD_UNLOCK(&mca_btl_sctp_component.sctp_lock); return proc; }
mca_btl_sctp_proc_t* mca_btl_sctp_proc_create(ompi_proc_t* ompi_proc) { int rc; size_t size; mca_btl_sctp_proc_t* btl_proc; uint64_t hash = ompi_rte_hash_name(&ompi_proc->proc_name); OPAL_THREAD_LOCK(&mca_btl_sctp_component.sctp_lock); rc = opal_hash_table_get_value_uint64(&mca_btl_sctp_component.sctp_procs, hash, (void**)&btl_proc); if(OMPI_SUCCESS == rc) { OPAL_THREAD_UNLOCK(&mca_btl_sctp_component.sctp_lock); return btl_proc; } btl_proc = OBJ_NEW(mca_btl_sctp_proc_t); if(NULL == btl_proc) { return NULL; } btl_proc->proc_ompi = ompi_proc; /* add to hash table of all proc instance */ opal_hash_table_set_value_uint64(&mca_btl_sctp_component.sctp_procs, hash, btl_proc); OPAL_THREAD_UNLOCK(&mca_btl_sctp_component.sctp_lock); /* lookup sctp parameters exported by this proc */ rc = ompi_modex_recv( &mca_btl_sctp_component.super.btl_version, ompi_proc, (void**)&btl_proc->proc_addrs, &size ); if(rc != OMPI_SUCCESS) { BTL_ERROR(("mca_base_modex_recv: failed with return value=%d", rc)); OBJ_RELEASE(btl_proc); return NULL; } if(0 != (size % sizeof(mca_btl_sctp_addr_t))) { BTL_ERROR(("mca_base_modex_recv: invalid size %" PRIsize_t "\n", size)); return NULL; } btl_proc->proc_addr_count = size / sizeof(mca_btl_sctp_addr_t); /* allocate space for endpoint array - one for each exported address */ btl_proc->proc_endpoints = (mca_btl_base_endpoint_t**) malloc(btl_proc->proc_addr_count * sizeof(mca_btl_base_endpoint_t*)); if(NULL == btl_proc->proc_endpoints) { OBJ_RELEASE(btl_proc); return NULL; } if(NULL == mca_btl_sctp_component.sctp_local && ompi_proc == ompi_proc_local()) { mca_btl_sctp_component.sctp_local = btl_proc; } return btl_proc; }
void mca_btl_sctp_proc_destruct(mca_btl_sctp_proc_t* stcp_proc) { /* remove from list of all proc instances */ OPAL_THREAD_LOCK(&mca_btl_sctp_component.sctp_lock); opal_hash_table_remove_value_uint64(&mca_btl_sctp_component.sctp_procs, ompi_rte_hash_name(&stcp_proc->proc_ompi->proc_name)); OPAL_THREAD_UNLOCK(&mca_btl_sctp_component.sctp_lock); /* release resources */ if(NULL != stcp_proc->proc_endpoints) { free(stcp_proc->proc_endpoints); } OBJ_DESTRUCT(&stcp_proc->proc_lock); }
/* * Create an endpoint and claim the matched modex slot */ int ompi_btl_usnic_create_endpoint(ompi_btl_usnic_module_t *module, ompi_btl_usnic_proc_t *proc, ompi_btl_usnic_endpoint_t **endpoint_o) { int err; int modex_index; ompi_btl_usnic_endpoint_t *endpoint; /* look for matching modex info */ err = match_modex(module, proc, &modex_index); if (OMPI_SUCCESS != err) { opal_output_verbose(5, USNIC_OUT, "btl:usnic:create_endpoint: did not match usnic modex info for peer %s", OMPI_NAME_PRINT(&proc->proc_ompi->proc_name)); return err; } endpoint = OBJ_NEW(ompi_btl_usnic_endpoint_t); if (NULL == endpoint) { return OMPI_ERR_OUT_OF_RESOURCE; } /* Initalize the endpoint */ endpoint->endpoint_module = module; assert(modex_index >= 0 && modex_index < (int)proc->proc_modex_count); endpoint->endpoint_remote_addr = proc->proc_modex[modex_index]; /* Initialize endpoint sequence number info */ endpoint->endpoint_next_seq_to_send = module->local_addr.isn; endpoint->endpoint_ack_seq_rcvd = endpoint->endpoint_next_seq_to_send - 1; endpoint->endpoint_next_contig_seq_to_recv = endpoint->endpoint_remote_addr.isn; endpoint->endpoint_highest_seq_rcvd = endpoint->endpoint_next_contig_seq_to_recv - 1; endpoint->endpoint_rfstart = WINDOW_SIZE_MOD(endpoint->endpoint_next_contig_seq_to_recv); /* Defer creating the ibv_ah. Since calling ibv_create_ah() may trigger ARP resolution, it's better to batch all the endpoints' calls to ibv_create_ah() together to get some parallelism. */ endpoint->endpoint_remote_ah = NULL; /* Now claim that modex slot */ proc->proc_modex_claimed[modex_index] = true; MSGDEBUG1_OUT("create_endpoint: module=%p claimed endpoint=%p on proc=%p (hash=0x%" PRIx64 ")\n", (void *)module, (void *)endpoint, (void *)proc, ompi_rte_hash_name(&proc->proc_ompi->proc_name)); /* Save the endpoint on this proc's array of endpoints */ proc->proc_endpoints[proc->proc_endpoint_count] = endpoint; endpoint->endpoint_proc_index = proc->proc_endpoint_count; endpoint->endpoint_proc = proc; ++proc->proc_endpoint_count; OBJ_RETAIN(proc); /* also add endpoint to module's list of endpoints */ opal_list_append(&(module->all_endpoints), &(endpoint->endpoint_endpoint_li)); *endpoint_o = endpoint; return OMPI_SUCCESS; }
uint64_t usnic_compat_rte_hash_name(opal_process_name_t *pname) { return ompi_rte_hash_name(pname); }