2005-07-01 01:28:35 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-07-01 01:28:35 +04:00
|
|
|
* 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"
|
|
|
|
|
2005-07-12 17:38:54 +04:00
|
|
|
#include <infiniband/verbs.h>
|
2006-09-07 17:05:41 +04:00
|
|
|
#include "ompi/mca/btl/btl.h"
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
struct mca_btl_openib_reg_t;
|
|
|
|
|
2005-11-10 23:15:02 +03:00
|
|
|
struct mca_btl_openib_header_t {
|
|
|
|
mca_btl_base_tag_t tag;
|
2006-12-17 03:50:59 +03:00
|
|
|
#if OMPI_ENABLE_HETEROGENEOUS_SUPPORT
|
|
|
|
uint8_t padding[1];
|
|
|
|
#endif
|
2006-09-05 20:02:09 +04:00
|
|
|
uint16_t credits;
|
2005-11-10 23:15:02 +03:00
|
|
|
};
|
|
|
|
typedef struct mca_btl_openib_header_t mca_btl_openib_header_t;
|
2006-09-05 20:02:09 +04:00
|
|
|
#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)
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2006-12-17 03:50:59 +03:00
|
|
|
#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)
|
|
|
|
|
|
|
|
|
2006-03-26 12:30:50 +04:00
|
|
|
struct mca_btl_openib_footer_t {
|
2006-06-28 15:25:09 +04:00
|
|
|
#if OMPI_ENABLE_DEBUG
|
2006-03-26 12:30:50 +04:00
|
|
|
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;
|
|
|
|
|
2007-01-13 02:14:45 +03:00
|
|
|
#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
|
2006-12-17 03:50:59 +03:00
|
|
|
|
2007-01-13 02:14:45 +03:00
|
|
|
#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)
|
2006-12-17 03:50:59 +03:00
|
|
|
#else
|
2007-01-13 02:14:45 +03:00
|
|
|
#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)
|
2006-12-17 03:50:59 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define MCA_BTL_OPENIB_CONTROL_CREDITS 0
|
|
|
|
#define MCA_BTL_OPENIB_CONTROL_RDMA 1
|
2006-03-26 12:30:50 +04:00
|
|
|
|
|
|
|
struct mca_btl_openib_control_header_t {
|
2007-01-13 02:14:45 +03:00
|
|
|
uint8_t type;
|
2006-03-26 12:30:50 +04:00
|
|
|
};
|
|
|
|
typedef struct mca_btl_openib_control_header_t mca_btl_openib_control_header_t;
|
|
|
|
|
|
|
|
struct mca_btl_openib_eager_rdma_header_t {
|
2007-01-13 02:14:45 +03:00
|
|
|
mca_btl_openib_control_header_t control;
|
|
|
|
uint8_t padding[3];
|
|
|
|
uint32_t rkey;
|
|
|
|
ompi_ptr_t rdma_start;
|
2006-03-26 12:30:50 +04:00
|
|
|
};
|
|
|
|
typedef struct mca_btl_openib_eager_rdma_header_t mca_btl_openib_eager_rdma_header_t;
|
2005-07-01 01:28:35 +04:00
|
|
|
|
2007-01-13 02:14:45 +03:00
|
|
|
#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)
|
|
|
|
|
|
|
|
|
2006-09-05 20:02:09 +04:00
|
|
|
struct mca_btl_openib_rdma_credits_header_t {
|
|
|
|
mca_btl_openib_control_header_t control;
|
2007-01-13 02:14:45 +03:00
|
|
|
uint8_t padding[1];
|
2006-09-05 20:02:09 +04:00
|
|
|
uint16_t rdma_credits;
|
|
|
|
};
|
|
|
|
typedef struct mca_btl_openib_rdma_credits_header_t mca_btl_openib_rdma_credits_header_t;
|
|
|
|
|
2006-12-17 03:50:59 +03:00
|
|
|
#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)
|
|
|
|
|
2006-03-30 19:26:21 +04:00
|
|
|
enum mca_btl_openib_frag_type_t {
|
|
|
|
MCA_BTL_OPENIB_FRAG_EAGER,
|
|
|
|
MCA_BTL_OPENIB_FRAG_MAX,
|
2007-02-28 16:43:38 +03:00
|
|
|
MCA_BTL_OPENIB_SEND_FRAG_FRAG,
|
|
|
|
MCA_BTL_OPENIB_RECV_FRAG_FRAG,
|
2006-07-27 18:09:30 +04:00
|
|
|
MCA_BTL_OPENIB_FRAG_EAGER_RDMA,
|
|
|
|
MCA_BTL_OPENIB_FRAG_CONTROL
|
2006-03-30 19:26:21 +04:00
|
|
|
};
|
|
|
|
typedef enum mca_btl_openib_frag_type_t mca_btl_openib_frag_type_t;
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/**
|
|
|
|
* IB send fragment derived type.
|
|
|
|
*/
|
|
|
|
struct mca_btl_openib_frag_t {
|
|
|
|
mca_btl_base_descriptor_t base;
|
|
|
|
struct mca_btl_base_endpoint_t *endpoint;
|
2006-08-28 15:03:56 +04:00
|
|
|
mca_btl_openib_footer_t *ftr;
|
|
|
|
mca_btl_openib_header_t *hdr;
|
|
|
|
mca_btl_base_segment_t segment;
|
2005-07-01 01:28:35 +04:00
|
|
|
size_t size;
|
2006-03-30 19:26:21 +04:00
|
|
|
int rc;
|
|
|
|
mca_btl_openib_frag_type_t type;
|
2005-07-01 01:28:35 +04:00
|
|
|
union{
|
2005-11-10 23:15:02 +03:00
|
|
|
struct ibv_recv_wr rd_desc;
|
2005-07-12 17:38:54 +04:00
|
|
|
struct ibv_send_wr sr_desc;
|
2005-07-20 19:17:18 +04:00
|
|
|
} wr_desc;
|
2005-07-12 17:38:54 +04:00
|
|
|
struct ibv_sge sg_entry;
|
2006-12-17 15:26:41 +03:00
|
|
|
struct mca_btl_openib_reg_t *registration;
|
2005-07-01 01:28:35 +04:00
|
|
|
};
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_frag_t;
|
2006-08-24 20:38:08 +04:00
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_frag_t);
|
2005-07-01 01:28:35 +04:00
|
|
|
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_send_frag_eager_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_send_frag_eager_t);
|
|
|
|
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_send_frag_max_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_send_frag_max_t);
|
|
|
|
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_send_frag_frag_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_send_frag_frag_t);
|
|
|
|
|
2007-02-28 16:43:38 +03:00
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_recv_frag_frag_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_recv_frag_frag_t);
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_recv_frag_eager_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_recv_frag_eager_t);
|
|
|
|
|
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_recv_frag_max_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_recv_frag_max_t);
|
|
|
|
|
2006-07-27 18:09:30 +04:00
|
|
|
typedef struct mca_btl_openib_frag_t mca_btl_openib_send_frag_control_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_DECLARATION(mca_btl_openib_send_frag_control_t);
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
/*
|
|
|
|
* Allocate an IB send descriptor
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_CREDIT_WAIT(btl, frag, rc) \
|
2005-07-01 01:28:35 +04:00
|
|
|
{ \
|
|
|
|
\
|
2006-08-24 20:38:08 +04:00
|
|
|
ompi_free_list_item_t *item; \
|
2006-07-27 18:09:30 +04:00
|
|
|
OMPI_FREE_LIST_WAIT(&((mca_btl_openib_module_t*)btl)->send_free_control, item, rc); \
|
2006-08-24 20:38:08 +04:00
|
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
|
|
|
|
2006-08-24 20:38:08 +04:00
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_EAGER(btl, frag, rc) \
|
2006-07-20 18:44:35 +04:00
|
|
|
{ \
|
|
|
|
\
|
2006-08-24 20:38:08 +04:00
|
|
|
ompi_free_list_item_t *item; \
|
2006-07-20 18:44:35 +04:00
|
|
|
OMPI_FREE_LIST_GET(&((mca_btl_openib_module_t*)btl)->send_free_eager, item, rc); \
|
2006-08-24 20:38:08 +04:00
|
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
2006-07-20 18:44:35 +04:00
|
|
|
}
|
|
|
|
|
2005-07-01 01:28:35 +04:00
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_MAX(btl, frag, rc) \
|
|
|
|
{ \
|
|
|
|
\
|
2006-06-13 02:09:03 +04:00
|
|
|
ompi_free_list_item_t *item; \
|
2006-07-20 18:44:35 +04:00
|
|
|
OMPI_FREE_LIST_GET(&((mca_btl_openib_module_t*)btl)->send_free_max, item, rc); \
|
2005-07-01 01:28:35 +04:00
|
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
|
|
|
}
|
|
|
|
|
2007-02-28 16:43:38 +03:00
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_SEND_FRAG(btl, frag, rc) \
|
2005-07-01 01:28:35 +04:00
|
|
|
{ \
|
|
|
|
\
|
2006-06-13 02:09:03 +04:00
|
|
|
ompi_free_list_item_t *item; \
|
2006-07-20 18:44:35 +04:00
|
|
|
OMPI_FREE_LIST_GET(&((mca_btl_openib_module_t*)btl)->send_free_frag, item, rc); \
|
2005-07-01 01:28:35 +04:00
|
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
|
|
|
}
|
|
|
|
|
2007-02-28 16:43:38 +03:00
|
|
|
#define MCA_BTL_IB_FRAG_ALLOC_RECV_FRAG(btl, frag, rc) \
|
|
|
|
{ \
|
|
|
|
\
|
|
|
|
ompi_free_list_item_t *item; \
|
|
|
|
OMPI_FREE_LIST_GET(&((mca_btl_openib_module_t*)btl)->recv_free_frag, item, rc); \
|
|
|
|
frag = (mca_btl_openib_frag_t*) item; \
|
|
|
|
}
|
|
|
|
|
2006-06-01 06:32:18 +04:00
|
|
|
#define MCA_BTL_IB_FRAG_RETURN(btl, frag) \
|
|
|
|
{ do { \
|
2006-09-05 13:16:22 +04:00
|
|
|
ompi_free_list_t* my_list = NULL; \
|
2006-06-01 06:32:18 +04:00
|
|
|
switch(frag->type) { \
|
|
|
|
case MCA_BTL_OPENIB_FRAG_EAGER_RDMA: \
|
|
|
|
case MCA_BTL_OPENIB_FRAG_EAGER: \
|
|
|
|
my_list = &btl->send_free_eager; \
|
|
|
|
break; \
|
|
|
|
case MCA_BTL_OPENIB_FRAG_MAX: \
|
|
|
|
my_list = &btl->send_free_max; \
|
|
|
|
break; \
|
2006-07-27 18:09:30 +04:00
|
|
|
case MCA_BTL_OPENIB_FRAG_CONTROL: \
|
|
|
|
my_list = &btl->send_free_control; \
|
|
|
|
break; \
|
2007-02-28 16:43:38 +03:00
|
|
|
case MCA_BTL_OPENIB_RECV_FRAG_FRAG: \
|
|
|
|
my_list = &btl->recv_free_frag; \
|
|
|
|
break; \
|
|
|
|
case MCA_BTL_OPENIB_SEND_FRAG_FRAG: \
|
2006-06-01 06:32:18 +04:00
|
|
|
my_list = &btl->send_free_frag; \
|
2006-07-27 18:09:30 +04:00
|
|
|
break; \
|
2006-06-01 06:32:18 +04:00
|
|
|
} \
|
2006-07-27 18:09:30 +04:00
|
|
|
OMPI_FREE_LIST_RETURN(my_list, (ompi_free_list_item_t*)(frag)); \
|
2006-06-01 06:32:18 +04:00
|
|
|
} while(0); \
|
2005-07-01 01:28:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct mca_btl_openib_module_t;
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|