diff --git a/ompi/mca/btl/sctp/btl_sctp_component.c b/ompi/mca/btl/sctp/btl_sctp_component.c index 68fade6740..dd61d236ff 100644 --- a/ompi/mca/btl/sctp/btl_sctp_component.c +++ b/ompi/mca/btl/sctp/btl_sctp_component.c @@ -818,9 +818,11 @@ mca_btl_base_module_t** mca_btl_sctp_component_init(int *num_btl_modules, for(i = 0; i < MCA_BTL_SCTP_PROC_TABLE_SIZE; i++) { recvr_proc_table[i].valid = 0; recvr_proc_table[i].sctp_assoc_id = 0; + recvr_proc_table[i].vpid = 0; recvr_proc_table[i].proc = NULL; sender_proc_table[i].valid = 0; sender_proc_table[i].sctp_assoc_id = 0; + sender_proc_table[i].vpid = 0; sender_proc_table[i].proc = NULL; } #endif diff --git a/ompi/mca/btl/sctp/btl_sctp_endpoint.c b/ompi/mca/btl/sctp/btl_sctp_endpoint.c index 6dc0381f70..0e3e227ed1 100644 --- a/ompi/mca/btl/sctp/btl_sctp_endpoint.c +++ b/ompi/mca/btl/sctp/btl_sctp_endpoint.c @@ -361,16 +361,16 @@ int mca_btl_sctp_endpoint_send(mca_btl_base_endpoint_t* btl_endpoint, mca_btl_sc int rc = OMPI_SUCCESS; /* What if there are multiple procs on this endpoint? Possible? */ - sctp_assoc_t vpid = (sctp_assoc_t) btl_endpoint->endpoint_proc->proc_name.vpid; + orte_vpid_t vpid = btl_endpoint->endpoint_proc->proc_name.vpid; OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock); - if((mca_btl_sctp_proc_check(vpid, sender_proc_table)) == INVALID_ENTRY) { + if((mca_btl_sctp_proc_check_vpid(vpid, sender_proc_table)) == INVALID_ENTRY) { opal_list_append(&btl_endpoint->endpoint_frags, (opal_list_item_t*)frag); rc = mca_btl_sctp_endpoint_start_connect(btl_endpoint); /* add the proc to sender_proc_table somewhere here */ - mca_btl_sctp_proc_add(vpid, btl_endpoint->endpoint_proc, sender_proc_table); + mca_btl_sctp_proc_add_vpid(vpid, btl_endpoint->endpoint_proc, sender_proc_table); } else { /* VALID_ENTRY */ @@ -1183,11 +1183,11 @@ static void mca_btl_sctp_endpoint_send_handler(int sd, short flags, void* user) /* 1 to many */ mca_btl_sctp_endpoint_t* btl_endpoint = (mca_btl_sctp_endpoint_t *)user; our_sctp_endpoint *current_our_endpoint = NULL; - sctp_assoc_t vpid; + orte_vpid_t vpid; send_handler_1_to_many_different_endpoint: - vpid = (sctp_assoc_t) btl_endpoint->endpoint_proc->proc_name.vpid; + vpid = btl_endpoint->endpoint_proc->proc_name.vpid; OPAL_THREAD_LOCK(&btl_endpoint->endpoint_send_lock); - if((mca_btl_sctp_proc_check(vpid, sender_proc_table)) == VALID_ENTRY) { + if((mca_btl_sctp_proc_check_vpid(vpid, sender_proc_table)) == VALID_ENTRY) { /* complete the current send */ do { mca_btl_sctp_frag_t* frag = btl_endpoint->endpoint_send_frag; diff --git a/ompi/mca/btl/sctp/btl_sctp_proc.c b/ompi/mca/btl/sctp/btl_sctp_proc.c index 3aaa3563a2..c9b9c2fd87 100644 --- a/ompi/mca/btl/sctp/btl_sctp_proc.c +++ b/ompi/mca/btl/sctp/btl_sctp_proc.c @@ -362,16 +362,17 @@ bool mca_btl_sctp_proc_accept(mca_btl_sctp_proc_t* btl_proc, struct sockaddr_in* * * TODO - change this to use a hash for constant time performance */ -int mca_btl_sctp_proc_check(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table) { +static int mca_btl_sctp_proc_check(int is_vpid, sctp_assoc_t id, orte_vpid_t vpid, struct mca_btl_sctp_proc_table_node *table) { #if MCA_BTL_SCTP_DONT_USE_HASH int i; for(i = 0; i < MCA_BTL_SCTP_PROC_TABLE_SIZE; i++) { /* sender_proc_table uses orte_vpid_t. * recvr_proc_table uses sctp_assoc_id. - * This code assumes sizeof(sctp_assoc_id) >= sizeof(orte_vpid_t). if this - * is false, we need a second _check function. + * Calls using this function use one or the other. */ - if(table[i].valid && table[i].sctp_assoc_id == id) { + if((0 == is_vpid && table[i].valid && table[i].sctp_assoc_id == id) || + (1 == is_vpid && table[i].valid && table[i].vpid == vpid)) + { return VALID_ENTRY; } else if(table[i].valid == 0) { /* once invalid is found, can return INVALID_ENTRY (added incrementally) */ @@ -391,6 +392,15 @@ int mca_btl_sctp_proc_check(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node #endif } +int mca_btl_sctp_proc_check_vpid(orte_vpid_t vpid, struct mca_btl_sctp_proc_table_node *table) { + return mca_btl_sctp_proc_check(1, 0, vpid, table); +} + +int mca_btl_sctp_proc_check_assoc_id(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table) { + return mca_btl_sctp_proc_check(0, id, 0, table); +} + + /** * void mca_btl_sctp_proc_add @@ -400,12 +410,13 @@ int mca_btl_sctp_proc_check(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node * TODO change this to a hash table that can expand to eliminate * MCA_BTL_SCTP_PROC_TABLE_SIZE limitation */ -void mca_btl_sctp_proc_add(sctp_assoc_t id, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table) { +static void mca_btl_sctp_proc_add(sctp_assoc_t id, orte_vpid_t vpid, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table) { #if MCA_BTL_SCTP_DONT_USE_HASH int i; for(i = 0; i < MCA_BTL_SCTP_PROC_TABLE_SIZE; i++) { - if(table[i].sctp_assoc_id == 0 && table[i].valid == 0) { + if(table[i].sctp_assoc_id == 0 && table[i].vpid == 0 && table[i].valid == 0) { table[i].sctp_assoc_id = id; + table[i].vpid = vpid; table[i].proc = proc; table[i].valid = 1; return; @@ -418,6 +429,14 @@ void mca_btl_sctp_proc_add(sctp_assoc_t id, struct mca_btl_sctp_proc_t *proc, st #endif } +void mca_btl_sctp_proc_add_vpid(orte_vpid_t vpid, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table) { + mca_btl_sctp_proc_add(0, vpid, proc, table); +} + +void mca_btl_sctp_proc_add_assoc_id(sctp_assoc_t id, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table) { + mca_btl_sctp_proc_add(id, 0, proc, table); +} + /** * mca_btl_sctp_proc_t* mca_btl_sctp_proc_get diff --git a/ompi/mca/btl/sctp/btl_sctp_proc.h b/ompi/mca/btl/sctp/btl_sctp_proc.h index 82cf40122f..ab5560810c 100644 --- a/ompi/mca/btl/sctp/btl_sctp_proc.h +++ b/ompi/mca/btl/sctp/btl_sctp_proc.h @@ -96,6 +96,7 @@ enum { struct mca_btl_sctp_proc_table_node { int valid; sctp_assoc_t sctp_assoc_id; + orte_vpid_t vpid; struct mca_btl_sctp_proc_t *proc; }; typedef struct mca_btl_sctp_proc_table_node mca_btl_sctp_proc_table_node; @@ -103,8 +104,10 @@ typedef struct mca_btl_sctp_proc_table_node mca_btl_sctp_proc_table_node; extern struct mca_btl_sctp_proc_table_node *recvr_proc_table; extern struct mca_btl_sctp_proc_table_node *sender_proc_table; -int mca_btl_sctp_proc_check(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table); -void mca_btl_sctp_proc_add(sctp_assoc_t id, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table); +int mca_btl_sctp_proc_check_vpid(orte_vpid_t vpid, struct mca_btl_sctp_proc_table_node *table); +int mca_btl_sctp_proc_check_assoc_id(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table); +void mca_btl_sctp_proc_add_vpid(orte_vpid_t vpid, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table); +void mca_btl_sctp_proc_add_assoc_id(sctp_assoc_t id, struct mca_btl_sctp_proc_t *proc, struct mca_btl_sctp_proc_table_node *table); mca_btl_sctp_proc_t *mca_btl_sctp_proc_get(sctp_assoc_t id, struct mca_btl_sctp_proc_table_node *table); #if defined(c_plusplus) || defined(__cplusplus) diff --git a/ompi/mca/btl/sctp/btl_sctp_recv_handler.c b/ompi/mca/btl/sctp/btl_sctp_recv_handler.c index 4d578d48c6..93f19d24d0 100644 --- a/ompi/mca/btl/sctp/btl_sctp_recv_handler.c +++ b/ompi/mca/btl/sctp/btl_sctp_recv_handler.c @@ -141,7 +141,7 @@ void mca_btl_sctp_recv_handler(int sd, short flags, void *user) { /* Check if sender is known to us. */ - if((mca_btl_sctp_proc_check(sri.sinfo_assoc_id, recvr_proc_table)) == VALID_ENTRY) { + if((mca_btl_sctp_proc_check_assoc_id(sri.sinfo_assoc_id, recvr_proc_table)) == VALID_ENTRY) { mca_btl_base_endpoint_t *btl_endpoint; mca_btl_sctp_frag_t* frag; @@ -233,7 +233,7 @@ data_still_pending_on_endpoint: CLOSE_THE_SOCKET(sd); return; } - mca_btl_sctp_proc_add(sri.sinfo_assoc_id, btl_proc, recvr_proc_table); + mca_btl_sctp_proc_add_assoc_id(sri.sinfo_assoc_id, btl_proc, recvr_proc_table); /* are there any existing peer instances will to accept this connection */