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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
|
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2008 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 (c) 2006 Sandia National Laboratories. All rights
* reserved.
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include <errno.h>
#include <string.h>
#include "ompi_config.h"
#include "opal/class/opal_bitmap.h"
#include "opal/prefetch.h"
#include "opal/util/output.h"
#include "opal/datatype/opal_convertor.h"
#include "ompi/mca/btl/btl.h"
#include "ompi/mca/btl/base/btl_base_error.h"
#include "ompi/mca/mpool/base/base.h"
#include "ompi/mca/mpool/mpool.h"
#include "ompi/mca/mpool/rdma/mpool_rdma.h"
#include "btl_ofud.h"
#include "btl_ofud_frag.h"
#include "btl_ofud_proc.h"
#include "btl_ofud_endpoint.h"
mca_btl_ud_module_t mca_btl_ofud_module = {
{
&mca_btl_ofud_component.super,
0, /* eager_limit */
0, /* min_send_size */
0, /* max_send_size */
0, /* rdma_pipeline_send_length */
0, /* rdma_pipeline_frag_size */
0, /* min_rdma_pipeline_size */
0, /* exclusivity */
0, /* latency */
0, /* bandwidth */
MCA_BTL_FLAGS_SEND,
mca_btl_ud_add_procs,
mca_btl_ud_del_procs,
NULL,
mca_btl_ud_finalize,
mca_btl_ud_alloc,
mca_btl_ud_free,
mca_btl_ud_prepare_src,
NULL, /*mca_btl_ud_prepare_dst */
mca_btl_ud_send,
NULL, /* send immediate */
NULL, /*mca_btl_ud_put */
NULL, /*mca_btl_ud_get */
mca_btl_base_dump,
NULL, /* mpool */
NULL, /* register error */
mca_btl_ud_ft_event
}
};
/*
* Add procs to this BTL module, receiving endpoint information from the modex.
*/
int mca_btl_ud_add_procs(struct mca_btl_base_module_t* btl,
size_t nprocs,
struct ompi_proc_t **ompi_procs,
struct mca_btl_base_endpoint_t** peers,
opal_bitmap_t* reachable)
{
mca_btl_ud_module_t* ud_btl = (mca_btl_ud_module_t*)btl;
struct ibv_ah_attr ah_attr;
int i, rc;
/* Set up the endpoint lookup table if it hasn't been already */
/* We do this here so we can initialize the table to a reasonable size
based on nprocs */
#if 0
if(NULL == ud_btl->ep_lookup) {
ud_btl->ep_lookup = malloc(sizeof(opal_hash_table_t));
OBJ_CONSTRUCT(ud_btl->ep_lookup, opal_hash_table_t);
opal_hash_table_init(ud_btl->ep_lookup, nprocs);
}
#endif
for(i = 0; i < (int)nprocs; i++) {
struct ompi_proc_t* ompi_proc = ompi_procs[i];
mca_btl_ud_proc_t* ib_proc;
mca_btl_base_endpoint_t* ib_peer;
if(NULL == (ib_proc = mca_btl_ud_proc_create(ompi_proc))) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
/* The btl_proc datastructure is shared by all IB BTL instances that are
* trying to reach this destination. Cache the peer instance on the
* btl_proc.
*/
ib_peer = OBJ_NEW(mca_btl_ud_endpoint_t);
if(NULL == ib_peer) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
OPAL_THREAD_LOCK(&ib_proc->proc_lock);
rc = mca_btl_ud_proc_insert(ib_proc, ib_peer);
if(rc != OMPI_SUCCESS) {
OBJ_RELEASE(ib_peer);
OPAL_THREAD_UNLOCK(&ib_proc->proc_lock);
continue;
}
BTL_VERBOSE(("modex_recv QP num %d, LID = %d",
ib_peer->rem_addr.qp_num, ib_peer->rem_addr.lid));
/* Set up IB address handles for the endpoint */
ah_attr.is_global = 0;
ah_attr.dlid = ib_peer->rem_addr.lid;
ah_attr.sl = mca_btl_ofud_component.ib_service_level;
ah_attr.src_path_bits = mca_btl_ofud_component.ib_src_path_bits;
ah_attr.port_num = ud_btl->ib_port_num;
ib_peer->rmt_ah = ibv_create_ah(ud_btl->ib_pd, &ah_attr);
if(NULL == ib_peer->rmt_ah) {
BTL_ERROR(("error creating address handle: %s\n", strerror(errno)));
OPAL_THREAD_UNLOCK(&ib_proc->proc_lock);
continue;
}
/* Insert a pointer to the endpoint in the BTL lookup table */
#if 0
opal_hash_table_set_value_uint64(ud_btl->ep_lookup,
((uint64_t)ib_peer->rem_addr.lid << 32) |
ib_peer->rem_addr.qp_num,
ib_peer);
#endif
opal_bitmap_set_bit(reachable, i);
OPAL_THREAD_UNLOCK(&ib_proc->proc_lock);
peers[i] = ib_peer;
}
return OMPI_SUCCESS;
}
/*
* Delete the proc as reachable from this btl module
*/
int mca_btl_ud_del_procs(struct mca_btl_base_module_t* btl,
size_t nprocs,
struct ompi_proc_t** procs,
struct mca_btl_base_endpoint_t** peers)
{
size_t i;
for(i = 0; i < nprocs; i++) {
mca_btl_ud_endpoint_t* endpoint = (mca_btl_ud_endpoint_t*)peers[i];
mca_btl_ud_proc_t* proc = mca_btl_ud_proc_lookup_ompi(procs[i]);
#if 0
opal_hash_table_remove_value_uint64(ud_btl->ep_lookup,
((uint64_t)endpoint->rem_addr.lid << 32) |
endpoint->rem_addr.qp_num);
#endif
if(NULL != proc) {
mca_btl_ud_proc_remove(proc, endpoint);
}
OBJ_RELEASE(endpoint);
}
return OMPI_SUCCESS;
}
/**
* Allocate a segment.
*
* @param btl (IN) BTL module
* @param size (IN) Request segment size.
*
* When allocating a segment we pull a pre-alllocated segment
* from one of two free lists, an eager list and a max list
*/
mca_btl_base_descriptor_t* mca_btl_ud_alloc(struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
uint8_t order,
size_t size,
uint32_t flags)
{
mca_btl_ud_frag_t* frag = NULL;
int rc;
if(OPAL_LIKELY(size <= mca_btl_ofud_module.super.btl_eager_limit)) {
MCA_BTL_UD_ALLOC_FRAG(btl, frag, rc);
}
if(NULL == frag) {
return NULL;
}
frag->base.order = MCA_BTL_NO_ORDER;
frag->base.des_flags = flags;
frag->segment.seg_len = size;
return (mca_btl_base_descriptor_t*)frag;
}
/**
* Return a segment
*
* Return the segment to the appropriate
* preallocated segment list
*/
int mca_btl_ud_free(struct mca_btl_base_module_t* btl,
mca_btl_base_descriptor_t* des)
{
mca_btl_ud_frag_t* frag = (mca_btl_ud_frag_t*)des;
if(OPAL_LIKELY(frag->type == MCA_BTL_UD_FRAG_SEND)) {
MCA_BTL_UD_RETURN_FRAG(btl, frag);
} else if(frag->type == MCA_BTL_UD_FRAG_USER && frag->ud_reg != NULL) {
btl->btl_mpool->mpool_deregister(btl->btl_mpool,
(mca_mpool_base_registration_t*)frag->ud_reg);
MCA_BTL_UD_RETURN_USER_FRAG(btl, frag);
}
return OMPI_SUCCESS;
}
/**
* register user buffer or pack
* data into pre-registered buffer and return a
* descriptor that can be
* used for send/put.
*
* @param btl (IN) BTL module
* @param peer (IN) BTL peer addressing
*
* prepare source's behavior depends on the following:
* Has a valid memory registration been passed to prepare_src?
* if so we attempt to use the pre-registred user-buffer, if the memory
* registration is to small (only a portion of the user buffer) then we must
* reregister the user buffer
* Has the user requested the memory to be left pinned?
* if so we insert the memory registration into a memory tree for later
* lookup, we may also remove a previous registration if a MRU (most recently
* used) list of registions is full, this prevents resources from being
* exhausted.
* Is the requested size larger than the btl's max send size?
* if so and we aren't asked to leave the registration pinned then we
* register the memory if the user's buffer is contiguous.
* Otherwise we choose from two free lists of pre-registered memory in which
* to pack the data into.
*
*/
mca_btl_base_descriptor_t* mca_btl_ud_prepare_src(
struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
mca_mpool_base_registration_t* registration,
struct opal_convertor_t* convertor,
uint8_t order,
size_t reserve,
size_t* size,
uint32_t flags)
{
mca_btl_ud_frag_t* frag = NULL;
struct iovec iov;
uint32_t iov_count = 1;
size_t max_data = *size;
int rc;
if(opal_convertor_need_buffers(convertor) == 0 && reserve == 0 &&
(registration != NULL || max_data > btl->btl_max_send_size)) {
/* The user buffer is contigous and we are asked to send more than
the max send size. */
MCA_BTL_UD_ALLOC_USER_FRAG(btl, frag, rc);
if(NULL == frag) {
return NULL;
}
iov.iov_len = max_data;
iov.iov_base = NULL;
opal_convertor_pack(convertor, &iov, &iov_count, &max_data);
frag->segment.seg_len = max_data;
frag->segment.seg_addr.pval = iov.iov_base;
frag->base.des_flags = flags;
frag->base.order = MCA_BTL_NO_ORDER;
if(NULL == registration) {
rc = btl->btl_mpool->mpool_register(btl->btl_mpool, iov.iov_base,
max_data, 0, ®istration);
if(OMPI_SUCCESS != rc || NULL == registration) {
MCA_BTL_UD_RETURN_USER_FRAG(btl, frag);
}
return NULL;
}
frag->ud_reg = (mca_btl_ud_reg_t*)registration;
frag->sg_entry.lkey = frag->ud_reg->mr->lkey;
frag->sg_entry.addr = (unsigned long)iov.iov_base;
frag->base.des_src = &frag->segment;
frag->base.des_src_cnt = 1;
frag->base.des_dst = NULL;
frag->base.des_dst_cnt = 0;
*size = max_data;
return &frag->base;
}
if(max_data + reserve > btl->btl_eager_limit) {
max_data = btl->btl_eager_limit - reserve;
}
MCA_BTL_UD_ALLOC_FRAG(btl, frag, rc);
if(OPAL_UNLIKELY(NULL == frag)) {
return NULL;
}
iov.iov_len = max_data;
iov.iov_base = (unsigned char*)frag->segment.seg_addr.pval + reserve;
rc = opal_convertor_pack(convertor, &iov, &iov_count, &max_data);
if(OPAL_UNLIKELY(rc < 0)) {
MCA_BTL_UD_RETURN_FRAG(btl, frag);
return NULL;
}
frag->segment.seg_len = max_data + reserve;
frag->sg_entry.length =
max_data + reserve + sizeof(mca_btl_ud_header_t);
frag->base.des_src = &frag->segment;
frag->base.des_src_cnt = 1;
frag->base.des_dst = NULL;
frag->base.des_dst_cnt = 0;
frag->base.des_flags = flags;
frag->base.order = MCA_BTL_NO_ORDER;
*size = max_data;
return &frag->base;
}
int mca_btl_ud_finalize(struct mca_btl_base_module_t* btl)
{
mca_btl_ud_module_t* ud_btl = (mca_btl_ud_module_t*)btl;
int32_t i;
for(i = 0; i < MCA_BTL_UD_NUM_QP; i++) {
ibv_destroy_qp(ud_btl->ib_qp[i]);
}
ibv_dealloc_pd(ud_btl->ib_pd);
OBJ_DESTRUCT(&ud_btl->ud_lock);
OBJ_DESTRUCT(&ud_btl->pending_frags);
OBJ_DESTRUCT(&ud_btl->send_frags);
OBJ_DESTRUCT(&ud_btl->user_frags);
OBJ_DESTRUCT(&ud_btl->recv_frags);
mca_mpool_base_module_destroy(ud_btl->super.btl_mpool);
return OMPI_SUCCESS;
}
/*
* Initiate a send.
*/
int mca_btl_ud_send(struct mca_btl_base_module_t* btl,
struct mca_btl_base_endpoint_t* endpoint,
struct mca_btl_base_descriptor_t* descriptor,
mca_btl_base_tag_t tag)
{
int rc;
mca_btl_ud_frag_t* frag = (mca_btl_ud_frag_t*)descriptor;
MCA_BTL_UD_START_TIME(post_send);
frag->endpoint = endpoint;
frag->hdr->tag = tag;
rc = mca_btl_ud_endpoint_post_send((mca_btl_ud_module_t*)btl, frag);
MCA_BTL_UD_END_TIME(post_send);
return rc;
}
/*
* RDMA Memory Pool (de)register callbacks
*/
static int mca_btl_ud_reg_mr(void* reg_data, void* base, size_t size,
mca_mpool_base_registration_t* reg)
{
mca_btl_ud_module_t* mod = (mca_btl_ud_module_t*)reg_data;
mca_btl_ud_reg_t* ud_reg = (mca_btl_ud_reg_t*)reg;
ud_reg->mr = ibv_reg_mr(mod->ib_pd, base, size, IBV_ACCESS_LOCAL_WRITE |
IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ);
if(NULL == ud_reg->mr)
return OMPI_ERR_OUT_OF_RESOURCE;
return OMPI_SUCCESS;
}
static int mca_btl_ud_dereg_mr(void* reg_data,
mca_mpool_base_registration_t* reg)
{
mca_btl_ud_reg_t* ud_reg = (mca_btl_ud_reg_t*)reg;
if(ud_reg->mr != NULL) {
if(ibv_dereg_mr(ud_reg->mr)) {
opal_output(0, "%s: error unpinning UD memory: %s\n",
__func__, strerror(errno));
return OMPI_ERROR;
}
}
ud_reg->mr = NULL;
return OMPI_SUCCESS;
}
/*
* Create a single UD queue pair. Since UD is connectionless, the QP is
* useable immediately.
*/
/* TODO - can remove cq/psn args now with only one type of frag */
static int mca_btl_ud_init_qp(mca_btl_ud_module_t* ud_btl,
struct ibv_cq* cq,
struct ibv_qp** qp,
uint32_t lcl_psn)
{
struct ibv_qp_attr qp_attr;
struct ibv_qp_init_attr qp_init_attr;
memset(&qp_init_attr, 0, sizeof(struct ibv_qp_init_attr));
qp_init_attr.send_cq = cq;
qp_init_attr.recv_cq = cq;
qp_init_attr.cap.max_send_wr = mca_btl_ofud_component.sd_num;
qp_init_attr.cap.max_recv_wr = mca_btl_ofud_component.rd_num;
qp_init_attr.cap.max_send_sge = 1;
qp_init_attr.cap.max_recv_sge = 1;
/* TODO - find the best value for max_inline_data */
qp_init_attr.cap.max_inline_data = 200;
qp_init_attr.qp_type = IBV_QPT_UD;
*qp = ibv_create_qp(ud_btl->ib_pd, &qp_init_attr);
if(NULL == *qp) {
BTL_ERROR(("error creating QP: %s\n", strerror(errno)));
return OMPI_ERROR;
}
if(0 == (ud_btl->ib_inline_max = qp_init_attr.cap.max_inline_data)) {
BTL_ERROR(("ibv_create_qp: returned 0 byte(s) for max inline data"));
}
BTL_VERBOSE(("ib_inline_max %lu\n", (unsigned long) ud_btl->ib_inline_max));
qp_attr.qp_state = IBV_QPS_INIT;
qp_attr.pkey_index = mca_btl_ofud_component.ib_pkey_ix;
qp_attr.qkey = mca_btl_ofud_component.ib_qkey;
qp_attr.port_num = ud_btl->ib_port_num;
if(ibv_modify_qp(*qp, &qp_attr,
IBV_QP_STATE | IBV_QP_PKEY_INDEX |
IBV_QP_PORT | IBV_QP_QKEY)) {
BTL_ERROR(("error modifying QP to INIT: %s", strerror(errno)));
goto destroy_qp;
}
qp_attr.qp_state = IBV_QPS_RTR;
if(ibv_modify_qp(*qp, &qp_attr, IBV_QP_STATE)) {
BTL_ERROR(("error modifing QP to RTR: %s", strerror(errno)));
goto destroy_qp;
}
qp_attr.qp_state = IBV_QPS_RTS;
qp_attr.sq_psn = lcl_psn;
if (ibv_modify_qp(*qp, &qp_attr, IBV_QP_STATE | IBV_QP_SQ_PSN)) {
BTL_ERROR(("error modifying QP to RTS: %s", strerror(errno)));
goto destroy_qp;
}
return OMPI_SUCCESS;
destroy_qp:
ibv_destroy_qp(*qp);
*qp = NULL;
return OMPI_ERROR;
}
/*
* Initialize the btl module by allocating a protection domain,
* memory pool, completion queue, and free lists
*/
int mca_btl_ud_module_init(mca_btl_ud_module_t *ud_btl)
{
struct mca_mpool_base_resources_t mpool_resources;
struct ibv_context *ctx = ud_btl->ib_dev_context;
struct ibv_recv_wr* bad_wr;
mca_btl_ud_frag_t* frag;
ompi_free_list_item_t* item;
uint32_t length,length_payload;
int32_t rc, i;
ud_btl->sd_wqe = mca_btl_ofud_component.sd_num;
ud_btl->ib_pd = ibv_alloc_pd(ctx);
if(NULL == ud_btl->ib_pd) {
BTL_ERROR(("error allocating PD for %s: %s\n",
ibv_get_device_name(ud_btl->ib_dev), strerror(errno)));
return OMPI_ERROR;
}
mpool_resources.reg_data = (void*)ud_btl;
mpool_resources.sizeof_reg = sizeof(mca_btl_ud_reg_t);
mpool_resources.register_mem = mca_btl_ud_reg_mr;
mpool_resources.deregister_mem = mca_btl_ud_dereg_mr;
ud_btl->super.btl_mpool =
mca_mpool_base_module_create(mca_btl_ofud_component.ud_mpool_name,
&ud_btl->super, &mpool_resources);
if(NULL == ud_btl->super.btl_mpool) {
BTL_ERROR(("error creating IB mpool for %s: %s\n",
ibv_get_device_name(ud_btl->ib_dev), strerror(errno)));
goto dealloc_pd;
}
/* Create the completion queue */
length = mca_btl_ofud_component.rd_num + mca_btl_ofud_component.sd_num;
ud_btl->ib_cq = ibv_create_cq(ctx, length, NULL, NULL, 0);
if(NULL == ud_btl->ib_cq) {
BTL_ERROR(("error creating CQ for %s: %s\n",
ibv_get_device_name(ud_btl->ib_dev), strerror(errno)));
goto mpool_destroy;
}
/* Set up our packet sequence numbers */
ud_btl->addr.psn = lrand48() & 0xffffff;
/* Set up the QPs for this BTL */
for(i = 0; i < MCA_BTL_UD_NUM_QP; i++) {
if(OMPI_SUCCESS != mca_btl_ud_init_qp(ud_btl,
ud_btl->ib_cq, &ud_btl->ib_qp[i], ud_btl->addr.psn)) {
goto qp_destroy;
}
}
/* Place our QP numbers in our local address information */
ud_btl->addr.qp_num = ud_btl->ib_qp[0]->qp_num;
ud_btl->ib_qp_next = 0;
/*ud_btl->rd_posted = mca_btl_ofud_component.rd_num_init;*/
/* Initialize pool of receive fragments first, since an error may occur */
/* TODO - no need for a free list with a static buffer count */
OBJ_CONSTRUCT(&ud_btl->recv_frags, ompi_free_list_t);
length = sizeof(mca_btl_ud_frag_t) + sizeof(mca_btl_ud_header_t) +
ud_btl->super.btl_eager_limit + 2 * MCA_BTL_IB_FRAG_ALIGN;
length_payload=sizeof(mca_btl_ud_frag_t) + sizeof(mca_btl_ud_header_t) +
ud_btl->super.btl_eager_limit + 2 * MCA_BTL_IB_FRAG_ALIGN -
sizeof(mca_btl_ud_recv_frag_t);
ompi_free_list_init_new(&ud_btl->recv_frags,
length + sizeof(mca_btl_ud_ib_header_t),
opal_cache_line_size,
OBJ_CLASS(mca_btl_ud_recv_frag_t),
length_payload,opal_cache_line_size,
mca_btl_ofud_component.rd_num,
mca_btl_ofud_component.rd_num,
mca_btl_ofud_component.rd_num,
ud_btl->super.btl_mpool);
#if 0
ompi_free_list_init_new(&ud_btl->recv_frags,
length + sizeof(mca_btl_ud_ib_header_t),
opal_cache_line_size,
OBJ_CLASS(mca_btl_ud_recv_frag_t),
length_payload,opal_cache_line_size,
mca_btl_ofud_component.rd_num_init,
mca_btl_ofud_component.rd_num_max,
mca_btl_ofud_component.rd_num_inc,
ud_btl->super.btl_mpool);
#endif
/* Post receive descriptors */
for(i = 0; i < mca_btl_ofud_component.rd_num; i++) {
OMPI_FREE_LIST_GET(&ud_btl->recv_frags, item, rc);
frag = (mca_btl_ud_frag_t*)item;
if(NULL == frag) {
BTL_ERROR(("error getting receive buffer from free list\n"));
goto obj_destruct;
}
frag->type = MCA_BTL_UD_FRAG_RECV;
frag->sg_entry.length = mca_btl_ofud_module.super.btl_eager_limit +
sizeof(mca_btl_ud_header_t) + sizeof(mca_btl_ud_ib_header_t);
if(ibv_post_recv(ud_btl->ib_qp[0],
&frag->wr_desc.rd_desc, &bad_wr)) {
BTL_ERROR(("error posting recv, errno %s\n", strerror(errno)));
goto obj_destruct;
}
}
/* No more errors anticipated - initialize everything else */
OBJ_CONSTRUCT(&ud_btl->ud_lock, opal_mutex_t);
OBJ_CONSTRUCT(&ud_btl->pending_frags, opal_list_t);
OBJ_CONSTRUCT(&ud_btl->send_frags, ompi_free_list_t);
OBJ_CONSTRUCT(&ud_btl->user_frags, ompi_free_list_t);
ompi_free_list_init_new(&ud_btl->send_frags,
length,
opal_cache_line_size,
OBJ_CLASS(mca_btl_ud_send_frag_t),
length_payload,opal_cache_line_size,
mca_btl_ofud_component.sd_num >> 1,
-1,
mca_btl_ofud_component.sd_num << 2,
ud_btl->super.btl_mpool);
/* Initialize pool of user fragments */
length = sizeof(mca_btl_ud_frag_t) +
sizeof(mca_btl_ud_header_t) + 2 * MCA_BTL_IB_FRAG_ALIGN;
length_payload = sizeof(mca_btl_ud_frag_t) +
sizeof(mca_btl_ud_header_t) + 2 * MCA_BTL_IB_FRAG_ALIGN-
sizeof(mca_btl_ud_user_frag_t);
ompi_free_list_init_new(&ud_btl->user_frags,
length,
opal_cache_line_size,
OBJ_CLASS(mca_btl_ud_user_frag_t),
length_payload,opal_cache_line_size,
mca_btl_ofud_component.sd_num >> 1,
-1,
mca_btl_ofud_component.sd_num << 2,
ud_btl->super.btl_mpool);
return OMPI_SUCCESS;
obj_destruct:
OBJ_DESTRUCT(&ud_btl->recv_frags);
qp_destroy:
for(i = 0; i < MCA_BTL_UD_NUM_QP; i++) {
ibv_destroy_qp(ud_btl->ib_qp[i]);
}
mpool_destroy:
mca_mpool_base_module_destroy(ud_btl->super.btl_mpool);
dealloc_pd:
ibv_dealloc_pd(ud_btl->ib_pd);
return OMPI_ERROR;
}
int mca_btl_ud_ft_event(int state) {
return OMPI_SUCCESS;
}
|