8ace07efed
1. Galen's fine-grain control of queue pair resources in the openib BTL. 1. Pasha's new implementation of asychronous HCA event handling. Pasha's new implementation doesn't take much explanation, but the new "multifrag" stuff does. Note that "svn merge" was not used to bring this new code from the /tmp/ib_multifrag branch -- something Bad happened in the periodic trunk pulls on that branch making an actual merge back to the trunk effectively impossible (i.e., lots and lots of arbitrary conflicts and artifical changes). :-( == Fine-grain control of queue pair resources == Galen's fine-grain control of queue pair resources to the OpenIB BTL (thanks to Gleb for fixing broken code and providing additional functionality, Pasha for finding broken code, and Jeff for doing all the svn work and regression testing). Prior to this commit, the OpenIB BTL created two queue pairs: one for eager size fragments and one for max send size fragments. When the use of the shared receive queue (SRQ) was specified (via "-mca btl_openib_use_srq 1"), these QPs would use a shared receive queue for receive buffers instead of the default per-peer (PP) receive queues and buffers. One consequence of this design is that receive buffer utilization (the size of the data received as a percentage of the receive buffer used for the data) was quite poor for a number of applications. The new design allows multiple QPs to be specified at runtime. Each QP can be setup to use PP or SRQ receive buffers as well as giving fine-grained control over receive buffer size, number of receive buffers to post, when to replenish the receive queue (low water mark) and for SRQ QPs, the number of outstanding sends can also be specified. The following is an example of the syntax to describe QPs to the OpenIB BTL using the new MCA parameter btl_openib_receive_queues: {{{ -mca btl_openib_receive_queues \ "P,128,16,4;S,1024,256,128,32;S,4096,256,128,32;S,65536,256,128,32" }}} Each QP description is delimited by ";" (semicolon) with individual fields of the QP description delimited by "," (comma). The above example therefore describes 4 QPs. The first QP is: P,128,16,4 Meaning: per-peer receive buffer QPs are indicated by a starting field of "P"; the first QP (shown above) is therefore a per-peer based QP. The second field indicates the size of the receive buffer in bytes (128 bytes). The third field indicates the number of receive buffers to allocate to the QP (16). The fourth field indicates the low watermark for receive buffers at which time the BTL will repost receive buffers to the QP (4). The second QP is: S,1024,256,128,32 Shared receive queue based QPs are indicated by a starting field of "S"; the second QP (shown above) is therefore a shared receive queue based QP. The second, third and fourth fields are the same as in the per-peer based QP. The fifth field is the number of outstanding sends that are allowed at a given time on the QP (32). This provides a "good enough" mechanism of flow control for some regular communication patterns. QPs MUST be specified in ascending receive buffer size order. This requirement may be removed prior to 1.3 release. This commit was SVN r15474.
287 строки
10 KiB
C
287 строки
10 KiB
C
/*
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
* University Research and Technology
|
|
* Corporation. All rights reserved.
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
* of Tennessee Research Foundation. 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_FRAG_H
|
|
#define MCA_BTL_IB_FRAG_H
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include <infiniband/verbs.h>
|
|
#include "ompi/mca/btl/btl.h"
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct mca_btl_openib_reg_t;
|
|
|
|
struct mca_btl_openib_header_t {
|
|
mca_btl_base_tag_t tag;
|
|
#if OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
uint8_t padding[1];
|
|
#endif
|
|
uint16_t credits;
|
|
};
|
|
typedef struct mca_btl_openib_header_t mca_btl_openib_header_t;
|
|
#define BTL_OPENIB_RDMA_CREDITS_FLAG (1<<15)
|
|
#define BTL_OPENIB_IS_RDMA_CREDITS(I) ((I)&BTL_OPENIB_RDMA_CREDITS_FLAG)
|
|
#define BTL_OPENIB_CREDITS(I) ((I)&~BTL_OPENIB_RDMA_CREDITS_FLAG)
|
|
|
|
#define BTL_OPENIB_HEADER_HTON(h) \
|
|
do { \
|
|
h.credits = htons(h.credits); \
|
|
} while (0)
|
|
|
|
#define BTL_OPENIB_HEADER_NTOH(h) \
|
|
do { \
|
|
h.credits = ntohs(h.credits); \
|
|
} while (0)
|
|
|
|
|
|
struct mca_btl_openib_footer_t {
|
|
#if OMPI_ENABLE_DEBUG
|
|
uint32_t seq;
|
|
#endif
|
|
union {
|
|
uint32_t size;
|
|
uint8_t buf[4];
|
|
} u;
|
|
};
|
|
typedef struct mca_btl_openib_footer_t mca_btl_openib_footer_t;
|
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
#define MCA_BTL_OPENIB_FTR_SIZE_REVERSE(ftr)
|
|
#else
|
|
#define MCA_BTL_OPENIB_FTR_SIZE_REVERSE(ftr) \
|
|
do { \
|
|
uint8_t tmp = (ftr).u.buf[0]; \
|
|
(ftr).u.buf[0]=(ftr).u.buf[2]; \
|
|
(ftr).u.buf[2]=tmp; \
|
|
} while (0)
|
|
#endif
|
|
|
|
#if OMPI_ENABLE_DEBUG
|
|
#define BTL_OPENIB_FOOTER_HTON(h) \
|
|
do { \
|
|
h.seq = htonl(h.seq); \
|
|
MCA_BTL_OPENIB_FTR_SIZE_REVERSE(h); \
|
|
} while (0)
|
|
|
|
#define BTL_OPENIB_FOOTER_NTOH(h) \
|
|
do { \
|
|
h.seq = ntohl(h.seq); \
|
|
MCA_BTL_OPENIB_FTR_SIZE_REVERSE(h); \
|
|
} while (0)
|
|
#else
|
|
#define BTL_OPENIB_FOOTER_HTON(h) \
|
|
do { \
|
|
MCA_BTL_OPENIB_FTR_SIZE_REVERSE(h); \
|
|
} while (0)
|
|
|
|
#define BTL_OPENIB_FOOTER_NTOH(h) \
|
|
do { \
|
|
MCA_BTL_OPENIB_FTR_SIZE_REVERSE(h); \
|
|
} while (0)
|
|
#endif
|
|
|
|
|
|
#define MCA_BTL_OPENIB_CONTROL_CREDITS 0
|
|
#define MCA_BTL_OPENIB_CONTROL_RDMA 1
|
|
|
|
struct mca_btl_openib_control_header_t {
|
|
uint8_t type;
|
|
};
|
|
typedef struct mca_btl_openib_control_header_t mca_btl_openib_control_header_t;
|
|
|
|
struct mca_btl_openib_eager_rdma_header_t {
|
|
mca_btl_openib_control_header_t control;
|
|
uint8_t padding[3];
|
|
uint32_t rkey;
|
|
ompi_ptr_t rdma_start;
|
|
};
|
|
typedef struct mca_btl_openib_eager_rdma_header_t mca_btl_openib_eager_rdma_header_t;
|
|
|
|
#define BTL_OPENIB_EAGER_RDMA_CONTROL_HEADER_HTON(h) \
|
|
do { \
|
|
h.rkey = htonl(h.rkey); \
|
|
h.rdma_start.lval = hton64(h.rdma_start.lval); \
|
|
} while (0)
|
|
|
|
#define BTL_OPENIB_EAGER_RDMA_CONTROL_HEADER_NTOH(h) \
|
|
do { \
|
|
h.rkey = ntohl(h.rkey); \
|
|
h.rdma_start.lval = ntoh64(h.rdma_start.lval); \
|
|
} while (0)
|
|
|
|
|
|
struct mca_btl_openib_rdma_credits_header_t {
|
|
mca_btl_openib_control_header_t control;
|
|
uint8_t padding[1];
|
|
uint16_t rdma_credits;
|
|
};
|
|
typedef struct mca_btl_openib_rdma_credits_header_t mca_btl_openib_rdma_credits_header_t;
|
|
|
|
#define BTL_OPENIB_RDMA_CREDITS_HEADER_HTON(h) \
|
|
do { \
|
|
h.rdma_credits = htons(h.rdma_credits); \
|
|
} while (0)
|
|
|
|
#define BTL_OPENIB_RDMA_CREDITS_HEADER_NTOH(h) \
|
|
do { \
|
|
h.rdma_credits = ntohs(h.rdma_credits); \
|
|
} while (0)
|
|
|
|
enum mca_btl_openib_frag_type_t {
|
|
MCA_BTL_OPENIB_FRAG_RECV,
|
|
MCA_BTL_OPENIB_FRAG_RECV_USER,
|
|
MCA_BTL_OPENIB_FRAG_SEND,
|
|
MCA_BTL_OPENIB_FRAG_SEND_USER,
|
|
MCA_BTL_OPENIB_FRAG_EAGER_RDMA,
|
|
MCA_BTL_OPENIB_FRAG_CONTROL
|
|
};
|
|
typedef enum mca_btl_openib_frag_type_t mca_btl_openib_frag_type_t;
|
|
|
|
/**
|
|
* IB send fragment derived type.
|
|
*/
|
|
struct mca_btl_openib_frag_t {
|
|
mca_btl_base_descriptor_t base;
|
|
struct mca_btl_base_endpoint_t *endpoint;
|
|
mca_btl_openib_footer_t *ftr;
|
|
mca_btl_openib_header_t *hdr;
|
|
mca_btl_base_segment_t segment;
|
|
size_t size;
|
|
int rc;
|
|
mca_btl_openib_frag_type_t type;
|
|
union{
|
|
struct ibv_recv_wr rd_desc;
|
|
struct ibv_send_wr sr_desc;
|
|
} wr_desc;
|
|
struct ibv_sge sg_entry;
|
|
struct mca_btl_openib_reg_t *registration;
|
|
ompi_free_list_t* list;
|
|
uint8_t qp_idx;
|
|
};
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_frag_t;
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_frag_t);
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_send_frag_t;
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_send_frag_t);
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_send_user_frag_t;
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_send_user_frag_t);
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_recv_user_frag_t;
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_recv_user_frag_t);
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_recv_frag_t;
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_recv_frag_t);
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_send_frag_control_t;
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_send_frag_control_t);
|
|
|
|
/*
|
|
* Allocate an IB send descriptor
|
|
*
|
|
*/
|
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_CREDIT_WAIT(btl, frag, rc) \
|
|
{ \
|
|
\
|
|
ompi_free_list_item_t *item; \
|
|
OMPI_FREE_LIST_WAIT(&((mca_btl_openib_module_t*)btl)->send_free_control, item, rc); \
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
|
}
|
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC(btl, frag, rc, prio) \
|
|
do { \
|
|
ompi_free_list_item_t *item; \
|
|
OMPI_FREE_LIST_GET( \
|
|
&((mca_btl_openib_module_t*)btl)->send_free[prio], \
|
|
item, rc); \
|
|
frag = (mca_btl_openib_frag_t*)item; \
|
|
} while (0)
|
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_BY_SIZE(btl, frag, _size, rc) \
|
|
do { \
|
|
int qp; \
|
|
ompi_free_list_item_t* item = NULL; \
|
|
for(qp = 0; qp < mca_btl_openib_component.num_qps; qp++) { \
|
|
if(mca_btl_openib_component.qp_infos[qp].size >= _size) { \
|
|
OMPI_FREE_LIST_GET( \
|
|
&((mca_btl_openib_module_t*) btl)->qps[qp].send_free, \
|
|
item, rc); \
|
|
if(item) \
|
|
break; \
|
|
} \
|
|
} \
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
|
} while(0);
|
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_SEND_USER(btl, frag, rc) \
|
|
{ \
|
|
\
|
|
ompi_free_list_item_t *item; \
|
|
OMPI_FREE_LIST_GET(&((mca_btl_openib_module_t*)btl)->send_user_free, item, rc); \
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
|
}
|
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_RECV_USER(btl, frag, rc) \
|
|
{ \
|
|
\
|
|
ompi_free_list_item_t *item; \
|
|
OMPI_FREE_LIST_GET(&((mca_btl_openib_module_t*)btl)->recv_user_free, item, rc); \
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
|
}
|
|
|
|
#define MCA_BTL_IB_FRAG_RETURN(btl, frag) \
|
|
{ do { \
|
|
OMPI_FREE_LIST_RETURN(frag->list, \
|
|
(ompi_free_list_item_t*)(frag)); \
|
|
} while(0); \
|
|
}
|
|
|
|
#define MCA_BTL_OPENIB_CLEAN_PENDING_FRAGS(btl,list) \
|
|
while(!opal_list_is_empty(list)){ \
|
|
opal_list_item_t *frag_item; \
|
|
frag_item = opal_list_remove_first(list); \
|
|
MCA_BTL_IB_FRAG_RETURN(btl, ((mca_btl_openib_frag_t*)frag_item)); \
|
|
} \
|
|
|
|
struct mca_btl_openib_module_t;
|
|
|
|
struct mca_btl_openib_frag_init_data_t {
|
|
uint8_t order;
|
|
size_t length;
|
|
mca_btl_openib_frag_type_t type;
|
|
ompi_free_list_t* list;
|
|
};
|
|
typedef struct mca_btl_openib_frag_init_data_t mca_btl_openib_frag_init_data_t;
|
|
|
|
void mca_btl_openib_frag_init(ompi_free_list_item_t* item, void* ctx);
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
}
|
|
#endif
|
|
#endif
|