1 /** 2 * Copyright 2020 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_MESSAGE_H_ 18 #define MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_MESSAGE_H_ 19 20 #include <string> 21 #include <memory> 22 23 namespace mindspore { 24 namespace ps { 25 namespace core { 26 enum class Protos : uint32_t { RAW = 0, PROTOBUF = 1, FLATBUFFERS = 2 }; 27 28 enum class Command { 29 TERMINATE = 0, 30 REGISTER = 1, 31 HEARTBEAT = 2, 32 SEND_DATA = 3, 33 FETCH_METADATA = 4, 34 FINISH = 5, 35 COLLECTIVE_SEND_DATA = 6 36 }; 37 38 enum class Role { SERVER = 0, WORKER = 1, SCHEDULER = 2 }; 39 40 struct MessageHeader { 41 Protos message_proto_ = Protos::RAW; 42 uint32_t message_meta_length_ = 0; 43 uint64_t message_length_ = 0; 44 }; 45 46 struct CommandMeta { 47 // the command of this message,for example: register,heartbeat,data 48 Command cmd; 49 // the request id of this message 50 uint64_t request_id; 51 // the role of the current node: worker,server,scheduler 52 Role role; 53 // the current Node rank id,the worker node range is:[0,numOfWorker-1], the server node range is:[0, numOfServer-1] 54 int32_t rank_id = 4; 55 }; 56 } // namespace core 57 } // namespace ps 58 } // namespace mindspore 59 #endif // MINDSPORE_CCSRC_PS_CORE_COMMUNICATOR_MESSAGE_H_ 60