| 22 | namespace oneflow { |
| 23 | |
| 24 | void ActorMsgBus::SendMsg(const ActorMsg& msg) { |
| 25 | int64_t dst_machine_id = MachineId4ActorId(msg.dst_actor_id()); |
| 26 | if (dst_machine_id == GlobalProcessCtx::Rank()) { |
| 27 | SendMsgWithoutCommNet(msg); |
| 28 | } else { |
| 29 | if (msg.IsDataRegstMsgToConsumer()) { |
| 30 | int64_t comm_net_sequence; |
| 31 | { |
| 32 | std::unique_lock<std::mutex> lock( |
| 33 | regst_desc_id_dst_actor_id2comm_net_sequence_number_mutex_); |
| 34 | int64_t& comm_net_sequence_ref = |
| 35 | regst_desc_id_dst_actor_id2comm_net_sequence_number_[std::make_pair( |
| 36 | msg.regst_desc_id(), msg.dst_actor_id())]; |
| 37 | comm_net_sequence = comm_net_sequence_ref; |
| 38 | comm_net_sequence_ref += 1; |
| 39 | } |
| 40 | ActorMsg new_msg = msg; |
| 41 | new_msg.set_comm_net_sequence_number(comm_net_sequence); |
| 42 | Singleton<CommNet>::Get()->SendActorMsg(dst_machine_id, new_msg); |
| 43 | } else { |
| 44 | Singleton<CommNet>::Get()->SendActorMsg(dst_machine_id, msg); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | void ActorMsgBus::SendMsgWithoutCommNet(const ActorMsg& msg) { |
| 50 | CHECK_EQ(MachineId4ActorId(msg.dst_actor_id()), GlobalProcessCtx::Rank()); |
no test coverage detected