1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 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
#define MCA_BTL_IB_FRAG_ALIGN (8)
#include "ompi_config.h"
#include "btl_openib.h"
#include <infiniband/verbs.h>
#include "ompi/mca/mpool/openib/mpool_openib.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_btl_openib_frag_t);
struct mca_btl_openib_header_t {
mca_btl_base_tag_t tag;
int16_t credits;
int16_t rdma_credits;
};
typedef struct mca_btl_openib_header_t mca_btl_openib_header_t;
struct mca_btl_openib_footer_t {
#ifdef 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;
typedef enum {
MCA_BTL_OPENIB_CONTROL_NOOP,
MCA_BTL_OPENIB_CONTROL_RDMA
} mca_btl_openib_control_t;
struct mca_btl_openib_control_header_t {
mca_btl_openib_control_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;
ompi_ptr_t rdma_start;
uint32_t rkey;
};
typedef struct mca_btl_openib_eager_rdma_header_t mca_btl_openib_eager_rdma_header_t;
enum mca_btl_openib_frag_type_t {
MCA_BTL_OPENIB_FRAG_EAGER,
MCA_BTL_OPENIB_FRAG_MAX,
MCA_BTL_OPENIB_FRAG_FRAG,
MCA_BTL_OPENIB_FRAG_EAGER_RDMA
};
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;
mca_btl_base_segment_t segment;
struct mca_btl_base_endpoint_t *endpoint;
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 ibv_mr *mr;
mca_btl_openib_header_t *hdr;
mca_btl_openib_footer_t *ftr;
mca_mpool_openib_registration_t * openib_reg;
};
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_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);
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);
/*
* Allocate an IB send descriptor
*
*/
#define MCA_BTL_IB_FRAG_ALLOC_EAGER(btl, frag, rc) \
{ \
\
ompi_free_list_item_t *item; \
OMPI_FREE_LIST_WAIT(&((mca_btl_openib_module_t*)btl)->send_free_eager, item, rc); \
frag = (mca_btl_openib_frag_t*) item; \
}
#define MCA_BTL_IB_FRAG_ALLOC_MAX(btl, frag, rc) \
{ \
\
ompi_free_list_item_t *item; \
OMPI_FREE_LIST_WAIT(&((mca_btl_openib_module_t*)btl)->send_free_max, item, rc); \
frag = (mca_btl_openib_frag_t*) item; \
}
#define MCA_BTL_IB_FRAG_ALLOC_FRAG(btl, frag, rc) \
{ \
\
ompi_free_list_item_t *item; \
OMPI_FREE_LIST_WAIT(&((mca_btl_openib_module_t*)btl)->send_free_frag, item, rc); \
frag = (mca_btl_openib_frag_t*) item; \
}
#define MCA_BTL_IB_FRAG_RETURN(btl, frag) \
{ do { \
ompi_free_list_t* my_list; \
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; \
case MCA_BTL_OPENIB_FRAG_FRAG: \
my_list = &btl->send_free_frag; \
} \
OMPI_FREE_LIST_RETURN(my_list, (ompi_free_list_item_t*)(frag)); \
} while(0); \
}
#define MCA_BTL_IB_FRAG_PROGRESS(frag) \
do { \
switch(frag->wr_desc.sr_desc.opcode) { \
case IBV_WR_SEND: \
if(OMPI_SUCCESS != mca_btl_openib_endpoint_send(frag->endpoint, frag)) { \
BTL_ERROR(("error in posting pending send\n")); \
} \
break; \
case IBV_WR_RDMA_WRITE: \
if(OMPI_SUCCESS != mca_btl_openib_put((mca_btl_base_module_t*) openib_btl, \
frag->endpoint, \
(mca_btl_base_descriptor_t*) frag)) { \
BTL_ERROR(("error in posting pending rdma write\n")); \
} \
break; \
case IBV_WR_RDMA_READ: \
if(OMPI_SUCCESS != mca_btl_openib_get((mca_btl_base_module_t *) openib_btl, \
frag->endpoint, \
(mca_btl_base_descriptor_t*) frag)) { \
BTL_ERROR(("error in posting pending rdma read\n")); \
} \
break; \
default: \
BTL_ERROR(("error in posting pending operation, invalide opcode %d\n", frag->wr_desc.sr_desc.opcode)); \
break; \
} \
} while (0)
struct mca_btl_openib_module_t;
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif
|