2005-07-20 01:04:22 +04:00
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MCA_BTL_IB_ENDPOINT_H
|
|
|
|
#define MCA_BTL_IB_ENDPOINT_H
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-04 03:09:55 +04:00
|
|
|
#include "opal/event/event.h"
|
2005-07-01 01:28:35 +04:00
|
|
|
#include "mca/pml/pml.h"
|
|
|
|
#include "mca/btl/btl.h"
|
|
|
|
#include "btl_openib_frag.h"
|
|
|
|
#include "btl_openib.h"
|
2005-07-15 19:13:19 +04:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
extern int errno;
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_endpoint_t);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State of IB endpoint connection.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
/* Defines the state in which this BTL instance
|
|
|
|
* has started the process of connection */
|
|
|
|
MCA_BTL_IB_CONNECTING,
|
|
|
|
|
|
|
|
/* Waiting for ack from endpoint */
|
|
|
|
MCA_BTL_IB_CONNECT_ACK,
|
|
|
|
|
|
|
|
/* Connected ... both sender & receiver have
|
|
|
|
* buffers associated with this connection */
|
|
|
|
MCA_BTL_IB_CONNECTED,
|
|
|
|
|
|
|
|
/* Connection is closed, there are no resources
|
|
|
|
* associated with this */
|
|
|
|
MCA_BTL_IB_CLOSED,
|
|
|
|
|
|
|
|
/* Maximum number of retries have been used.
|
|
|
|
* Report failure on send to upper layer */
|
|
|
|
MCA_BTL_IB_FAILED
|
|
|
|
} mca_btl_openib_endpoint_state_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An abstraction that represents a connection to a endpoint process.
|
|
|
|
* An instance of mca_btl_base_endpoint_t is associated w/ each process
|
|
|
|
* and BTL pair at startup. However, connections to the endpoint
|
|
|
|
* are established dynamically on an as-needed basis:
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct mca_btl_base_endpoint_t {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t super;
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
struct mca_btl_openib_module_t* endpoint_btl;
|
|
|
|
/**< BTL instance that created this connection */
|
|
|
|
|
|
|
|
struct mca_btl_openib_proc_t* endpoint_proc;
|
|
|
|
/**< proc structure corresponding to endpoint */
|
|
|
|
|
|
|
|
mca_btl_openib_endpoint_state_t endpoint_state;
|
|
|
|
/**< current state of the connection */
|
|
|
|
|
|
|
|
size_t endpoint_retries;
|
|
|
|
/**< number of connection retries attempted */
|
|
|
|
|
|
|
|
double endpoint_tstamp;
|
|
|
|
/**< timestamp of when the first connection was attempted */
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_mutex_t endpoint_send_lock;
|
2005-07-01 01:28:35 +04:00
|
|
|
/**< lock for concurrent access to endpoint state */
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_mutex_t endpoint_recv_lock;
|
2005-07-01 01:28:35 +04:00
|
|
|
/**< lock for concurrent access to endpoint state */
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_t pending_send_frags;
|
2005-07-20 01:04:22 +04:00
|
|
|
/**< list of pending send frags for this endpotint */
|
2005-07-12 17:38:54 +04:00
|
|
|
|
|
|
|
uint32_t rem_qp_num_high;
|
|
|
|
uint32_t rem_qp_num_low;
|
|
|
|
/* Remote QP number (Low and High priority) */
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-12 17:38:54 +04:00
|
|
|
uint16_t rem_lid;
|
2005-07-01 01:28:35 +04:00
|
|
|
/* Local identifier of the remote process */
|
|
|
|
|
2005-07-12 17:38:54 +04:00
|
|
|
|
|
|
|
uint32_t rem_psn_high;
|
|
|
|
uint32_t rem_psn_low;
|
|
|
|
/* Remote processes port sequence number (Low and High) */
|
|
|
|
|
|
|
|
uint32_t lcl_psn_high;
|
|
|
|
uint32_t lcl_psn_low;
|
|
|
|
/* Local processes port sequence number (Low and High) */
|
|
|
|
|
|
|
|
struct ibv_qp* lcl_qp_high;
|
|
|
|
struct ibv_qp* lcl_qp_low;
|
|
|
|
/* Local QP (Low and High) */
|
|
|
|
|
|
|
|
struct ibv_qp_attr* lcl_qp_attr_high;
|
|
|
|
struct ibv_qp_attr* lcl_qp_attr_low;
|
|
|
|
/* Local QP attributes (Low and High) */
|
2005-07-20 01:04:22 +04:00
|
|
|
|
|
|
|
uint32_t rr_posted_high; /**< number of high priority rr posted to the nic*/
|
|
|
|
uint32_t rr_posted_low; /**< number of low priority rr posted to the nic*/
|
2005-07-12 17:38:54 +04:00
|
|
|
|
2005-07-20 01:04:22 +04:00
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct mca_btl_base_endpoint_t mca_btl_base_endpoint_t;
|
|
|
|
typedef mca_btl_base_endpoint_t mca_btl_openib_endpoint_t;
|
|
|
|
|
|
|
|
int mca_btl_openib_endpoint_send(mca_btl_base_endpoint_t* endpoint, struct mca_btl_openib_frag_t* frag);
|
|
|
|
int mca_btl_openib_endpoint_connect(mca_btl_base_endpoint_t*);
|
|
|
|
void mca_btl_openib_post_recv(void);
|
|
|
|
|
|
|
|
|
|
|
|
void mca_btl_openib_progress_send_frags(mca_btl_openib_endpoint_t*);
|
|
|
|
|
|
|
|
static inline int mca_btl_openib_endpoint_post_rr_sub(int cnt,
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_endpoint_t* endpoint,
|
|
|
|
ompi_free_list_t* frag_list,
|
|
|
|
uint32_t* rr_posted,
|
|
|
|
struct ibv_qp* qp
|
|
|
|
)
|
2005-07-01 01:28:35 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
int rc, i;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t* item;
|
2005-07-01 01:28:35 +04:00
|
|
|
mca_btl_openib_frag_t* frag;
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t *openib_btl = endpoint->endpoint_btl;
|
|
|
|
struct ibv_recv_wr* bad_wr;
|
2005-07-13 04:17:08 +04:00
|
|
|
struct ibv_recv_wr* rr_desc_post = openib_btl->rr_desc_post;
|
2005-07-13 01:49:30 +04:00
|
|
|
|
2005-07-12 17:38:54 +04:00
|
|
|
/* prepare frags and post receive requests, given, this is ugly,
|
|
|
|
* if openib doesn't plan on supporting a post_list method than
|
|
|
|
* this should be changed to simply loop through and post receives
|
|
|
|
* without bothering with the rr_desc_post array as it is not needed
|
|
|
|
*/
|
2005-07-01 01:28:35 +04:00
|
|
|
for(i = 0; i < cnt; i++) {
|
|
|
|
OMPI_FREE_LIST_WAIT(frag_list, item, rc);
|
|
|
|
frag = (mca_btl_openib_frag_t*) item;
|
|
|
|
frag->endpoint = endpoint;
|
2005-07-12 17:38:54 +04:00
|
|
|
frag->sg_entry.length = frag->size +
|
|
|
|
((unsigned char*) frag->segment.seg_addr.pval-
|
|
|
|
(unsigned char*) frag->hdr);
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
rr_desc_post[i] = frag->rr_desc;
|
2005-07-12 17:38:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; i< cnt; i++){
|
|
|
|
if(ibv_post_recv(qp,
|
2005-07-13 04:17:08 +04:00
|
|
|
&rr_desc_post[i],
|
2005-07-12 17:38:54 +04:00
|
|
|
&bad_wr)) {
|
2005-07-15 19:13:19 +04:00
|
|
|
opal_output(0, "%s: error posting receive errno says %s\n", __func__, strerror(errno));
|
2005-07-12 17:38:54 +04:00
|
|
|
return OMPI_ERROR;
|
2005-07-20 01:04:22 +04:00
|
|
|
}
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_ADD32(rr_posted, cnt);
|
2005-07-01 01:28:35 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int mca_btl_openib_endpoint_post_rr( mca_btl_openib_endpoint_t * endpoint, int additional){
|
2005-07-12 17:38:54 +04:00
|
|
|
mca_btl_openib_module_t * openib_btl = endpoint->endpoint_btl;
|
2005-07-01 01:28:35 +04:00
|
|
|
int rc;
|
2005-07-12 17:38:54 +04:00
|
|
|
OPAL_THREAD_LOCK(&openib_btl->ib_lock);
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-20 01:04:22 +04:00
|
|
|
if(endpoint->rr_posted_high <= mca_btl_openib_component.ib_rr_buf_min+additional && endpoint->rr_posted_high < mca_btl_openib_component.ib_rr_buf_max){
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-20 01:04:22 +04:00
|
|
|
rc = mca_btl_openib_endpoint_post_rr_sub(mca_btl_openib_component.ib_rr_buf_max - endpoint->rr_posted_high,
|
2005-07-13 01:49:30 +04:00
|
|
|
endpoint,
|
|
|
|
&openib_btl->recv_free_eager,
|
2005-07-20 01:04:22 +04:00
|
|
|
&endpoint->rr_posted_high,
|
2005-07-13 01:49:30 +04:00
|
|
|
endpoint->lcl_qp_high
|
|
|
|
);
|
2005-07-01 01:28:35 +04:00
|
|
|
if(rc != OMPI_SUCCESS){
|
2005-07-12 17:38:54 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&openib_btl->ib_lock);
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
2005-07-20 01:04:22 +04:00
|
|
|
if(endpoint->rr_posted_low <= mca_btl_openib_component.ib_rr_buf_min+additional && endpoint->rr_posted_low < mca_btl_openib_component.ib_rr_buf_max){
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2005-07-20 01:04:22 +04:00
|
|
|
rc = mca_btl_openib_endpoint_post_rr_sub(mca_btl_openib_component.ib_rr_buf_max - endpoint->rr_posted_low,
|
2005-07-13 01:49:30 +04:00
|
|
|
endpoint,
|
|
|
|
&openib_btl->recv_free_max,
|
2005-07-20 01:04:22 +04:00
|
|
|
&endpoint->rr_posted_low,
|
2005-07-13 01:49:30 +04:00
|
|
|
endpoint->lcl_qp_low
|
2005-07-01 01:28:35 +04:00
|
|
|
);
|
|
|
|
if(rc != OMPI_SUCCESS) {
|
2005-07-12 17:38:54 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&openib_btl->ib_lock);
|
2005-07-01 01:28:35 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2005-07-12 17:38:54 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&openib_btl->ib_lock);
|
2005-07-01 01:28:35 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DUMP_ENDPOINT(endpoint_ptr) { \
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "[%s:%d] ", __FILE__, __LINE__); \
|
|
|
|
opal_output(0, "Dumping endpoint %d state", \
|
2005-07-01 01:28:35 +04:00
|
|
|
endpoint->endpoint_proc->proc_guid.vpid); \
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "Local QP hndl : %d", \
|
2005-07-01 01:28:35 +04:00
|
|
|
endpoint_ptr->endpoint_conn->lres->qp_hndl); \
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "Local QP num : %d", \
|
2005-07-01 01:28:35 +04:00
|
|
|
endpoint_ptr->endpoint_conn->lres->qp_prop.qp_num); \
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "Remote QP num : %d", \
|
2005-07-01 01:28:35 +04:00
|
|
|
endpoint_ptr->endpoint_conn->rres->qp_num); \
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "Remote LID : %d", \
|
2005-07-01 01:28:35 +04:00
|
|
|
endpoint_ptr->endpoint_conn->rres->lid); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|