| 275 | } |
| 276 | |
| 277 | void MPIRendezvousMgr::MPIBackgroundThread() { |
| 278 | std::list<std::unique_ptr<MPISendTensorCall>> active_sends; |
| 279 | |
| 280 | while (1) { |
| 281 | MPI_Status status; |
| 282 | |
| 283 | // Check for incoming Tensor requests |
| 284 | RecvTensorRequest request; |
| 285 | if (ProbeForData(TAG_REQTENSOR, &status, &request)) { |
| 286 | this->AddRequest(request, status.MPI_SOURCE); |
| 287 | } |
| 288 | |
| 289 | // Check for incoming Tensor reply |
| 290 | MPIRecvTensorResponse mRes; |
| 291 | if (ProbeForData(TAG_SENDTENSOR, &status, &mRes)) { |
| 292 | const int64 step_id = mRes.step_id(); |
| 293 | std::string key = mRes.key(); |
| 294 | |
| 295 | std::shared_ptr<MPIRequestTensorCall> call; |
| 296 | GetRecvCall(step_id, key, &call); |
| 297 | call->recv_call_(mRes); |
| 298 | RemoveRecvCall(step_id, key); |
| 299 | } |
| 300 | |
| 301 | // Remove sends that have been completed |
| 302 | active_sends.remove_if( |
| 303 | [](std::unique_ptr<MPISendTensorCall>& i) { return i->IsFinished(); }); |
| 304 | |
| 305 | // send a Tensor request |
| 306 | RequestQueueEntry req; |
| 307 | if (GetRequest(&req)) req.second(); |
| 308 | |
| 309 | // Send a Tensor response |
| 310 | SendQueueEntry send; |
| 311 | if (GetResponse(&send)) { |
| 312 | std::unique_ptr<MPISendTensorCall> p(send.second()); |
| 313 | active_sends.push_back(std::move(p)); |
| 314 | } |
| 315 | |
| 316 | // std::this_thread::sleep_for(std::chrono::microseconds(1)); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | } // namespace tensorflow |
| 321 | #endif // TENSORFLOW_USE_MPI |
nothing calls this directly
no test coverage detected