1 /** 2 * Copyright 2021 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_DISTRIBUTED_COLLECTIVE_MS_COMMUNICATION_GROUP_H_ 18 #define MINDSPORE_CCSRC_DISTRIBUTED_COLLECTIVE_MS_COMMUNICATION_GROUP_H_ 19 20 #include <string> 21 #include <vector> 22 #include <memory> 23 #include "runtime/collective/communication_group.h" 24 25 namespace mindspore { 26 namespace device { 27 namespace cpu { 28 constexpr char kMSRootInfo[] = "MS_CLUSTER_ROOT"; 29 30 class MsCommunicationGroup : public CommunicationGroup { 31 public: MsCommunicationGroup(const std::string & name,const std::vector<uint32_t> & group_ranks,uint32_t global_rank,uint32_t local_group_rank,uint32_t local_group_size)32 explicit MsCommunicationGroup(const std::string &name, const std::vector<uint32_t> &group_ranks, uint32_t global_rank, 33 uint32_t local_group_rank, uint32_t local_group_size) 34 : CommunicationGroup(name, group_ranks, global_rank, local_group_rank, local_group_size), 35 root_info_(kMSRootInfo + name_) {} 36 37 ~MsCommunicationGroup() override = default; 38 Initialize(void * root_info)39 bool Initialize(void *root_info) override { return true; } Finalize()40 bool Finalize() override { return true; } 41 void *GenerateRootInfo(size_t *root_info_size) override; 42 43 private: 44 std::string root_info_; 45 }; 46 using MsCommunicationGroupPtr = std::shared_ptr<MsCommunicationGroup>; 47 } // namespace cpu 48 } // namespace device 49 } // namespace mindspore 50 #endif // MINDSPORE_CCSRC_DISTRIBUTED_COLLECTIVE_MS_COMMUNICATION_GROUP_H_ 51