MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RdmaChannel

Method RdmaChannel

tensorflow/contrib/verbs/rdma.cc:551–630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

549}
550
551RdmaChannel::RdmaChannel(const RdmaAdapter* adapter, const string local_name,
552 const string remote_name)
553 : adapter_(adapter),
554 local_name_(local_name),
555 remote_name_(remote_name),
556 request_serial_(0) {
557 struct ibv_sge list;
558
559 mr_ = ibv_reg_mr(adapter_->pd_, ping_buff_, kPingBuffSize,
560 IBV_ACCESS_LOCAL_WRITE);
561 CHECK(mr_) << "Failed to register memory region";
562
563 memset(&list, 0, sizeof(list));
564 list.addr = (uintptr_t)ping_buff_;
565 list.length = kPingBuffSize;
566 list.lkey = mr_->lkey;
567
568 ping_sge_list_ = list;
569 // Create queue pair
570 {
571 struct ibv_qp_init_attr attr;
572 memset(&attr, 0, sizeof(ibv_qp_init_attr));
573 attr.send_cq = adapter_->cq_;
574 attr.recv_cq = adapter_->cq_;
575 attr.cap.max_send_wr = adapter_->params_.queue_depth;
576 attr.cap.max_recv_wr = adapter_->params_.queue_depth;
577 attr.cap.max_send_sge = 1;
578 attr.cap.max_recv_sge = 1;
579 attr.qp_type = IBV_QPT_RC;
580
581 qp_ = ibv_create_qp(adapter_->pd_, &attr);
582 CHECK(qp_) << "Failed to create queue pair";
583 }
584
585 // Init queue pair
586 {
587 struct ibv_qp_attr attr;
588 memset(&attr, 0, sizeof(ibv_qp_attr));
589 attr.qp_state = IBV_QPS_INIT;
590 attr.pkey_index = adapter_->params_.pkey_index;
591 attr.port_num = adapter_->params_.port_num;
592 attr.qp_access_flags = IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE;
593
594 int mask =
595 IBV_QP_STATE | IBV_QP_PKEY_INDEX | IBV_QP_PORT | IBV_QP_ACCESS_FLAGS;
596 CHECK(!ibv_modify_qp(qp_, &attr, mask)) << "Failed to set QP to INIT";
597 }
598
599 // Local address
600 {
601 struct ibv_port_attr attr;
602 CHECK(
603 !ibv_query_port(adapter_->context_, adapter_->params_.port_num, &attr))
604 << "Query port";
605 self_.lid = attr.lid;
606 self_.qpn = qp_->qp_num;
607 self_.psn = static_cast<uint32_t>(random::New64()) & 0xffffff;
608 union ibv_gid gid;

Callers

nothing calls this directly

Calls 4

New64Function · 0.85
CreateCPUBufferMethod · 0.80
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected