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

Method Init

tensorflow/contrib/gdr/gdr_memory_manager.cc:188–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186 next_key_(static_cast<uint32_t>(random::New64())) {}
187
188Status GdrMemoryManager::Init() {
189 rdma_addrinfo* addrinfo;
190 rdma_addrinfo hints = {};
191 hints.ai_port_space = RDMA_PS_TCP;
192 hints.ai_flags = RAI_PASSIVE;
193 if (rdma_getaddrinfo(const_cast<char*>(host_.c_str()),
194 const_cast<char*>(port_.c_str()), &hints, &addrinfo)) {
195 return errors::Unavailable(strerror(errno), ": ", "cannot resolve rdma://",
196 host_, ":", port_);
197 }
198
199 ibv_qp_init_attr init_attr = {};
200 init_attr.qp_type = IBV_QPT_RC;
201 init_attr.cap.max_recv_wr = 1024;
202 init_attr.cap.max_send_wr = 1;
203 init_attr.cap.max_recv_sge = 1;
204 init_attr.cap.max_send_sge = 1;
205
206 // Create listening endpoint
207 rdma_cm_id* id;
208 if (rdma_create_ep(&id, addrinfo, nullptr, &init_attr)) {
209 return errors::Unavailable(strerror(errno), ": ", "cannot bind to rdma://",
210 host_, ":", port_);
211 }
212 listening_.reset(id);
213 rdma_freeaddrinfo(addrinfo);
214
215 // Listen without backlog
216 if (rdma_listen(listening_.get(), 0)) {
217 return errors::Unavailable(strerror(errno), ": ",
218 "cannot listen on rdma://", host_, ":", port_);
219 }
220 LOG(INFO) << "RDMA server is listening on " << host_ << ":" << port_;
221
222 if (listening_->verbs == nullptr) {
223 return errors::Unimplemented(
224 "Unsupported address ", host_, ":", port_,
225 " as it does not bind to a particular RDMA device");
226 }
227
228 int flags = fcntl(listening_->channel->fd, F_GETFL, 0);
229 if (fcntl(listening_->channel->fd, F_SETFL, flags | O_NONBLOCK)) {
230 return errors::Unavailable(strerror(errno), ": ",
231 "cannot set server to non-blocking mode");
232 }
233
234 numa_node_ = TryToReadNumaNode(listening_->verbs->device);
235
236 SubAllocator::Visitor alloc_visitor = [this](void* ptr, int numa_node,
237 size_t num_bytes) {
238 VLOG(2) << "Registering RDMA capable memory region on numa_node "
239 << numa_node;
240 InsertMemoryRegion(ptr, num_bytes, strings::StrCat("CPU:", numa_node));
241 };
242 SubAllocator::Visitor free_visitor = [this](void* ptr, int numa_node,
243 size_t num_bytes) {
244 VLOG(2) << "De-registering RDMA capable memory region on numa_node "
245 << numa_node;

Callers

nothing calls this directly

Calls 14

UnavailableFunction · 0.85
UnimplementedFunction · 0.85
c_strMethod · 0.80
AddCPUAllocVisitorMethod · 0.80
AddCPUFreeVisitorMethod · 0.80
AddGpuHostFreeVisitorMethod · 0.80
AddGPUAllocVisitorMethod · 0.80
TryToReadNumaNodeFunction · 0.70
IsGDRAvailableFunction · 0.70
StrCatFunction · 0.50
NUMANumNodesFunction · 0.50

Tested by

no test coverage detected