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_INIT_H_ 18 #define MINDSPORE_CCSRC_DISTRIBUTED_INIT_H_ 19 20 #include "include/backend/distributed/collective/collective_manager.h" 21 #if defined(__linux__) && defined(WITH_BACKEND) 22 #include "include/backend/distributed/cluster/cluster_context.h" 23 #else 24 #include "include/backend/distributed/cluster/dummy_cluster_context.h" 25 #endif 26 #include "include/backend/visible.h" 27 28 namespace mindspore { 29 namespace distributed { 30 // The static methods of MindSpore distributed execution. They can be exported by Pybind. 31 32 // Initialize and finalize distributed execution. 33 BACKEND_EXPORT bool Initialize(); 34 BACKEND_EXPORT bool Finalize(); 35 36 // Initialize and finalize the cluster based on MindSpore communication framework. 37 BACKEND_EXPORT bool InitializeCluster(); 38 BACKEND_EXPORT bool FinalizeCluster(); 39 40 // Initialize and finalize collective communication for distributed execution. 41 BACKEND_EXPORT bool InitializeCollective(); 42 BACKEND_EXPORT bool FinalizeCollective(); 43 44 // Set and get whether this process in cluster exits with exception. 45 BACKEND_EXPORT void set_cluster_exit_with_exception(); 46 BACKEND_EXPORT bool cluster_exit_with_exception(); 47 } // namespace distributed 48 } // namespace mindspore 49 #endif // MINDSPORE_CCSRC_DISTRIBUTED_INIT_H_ 50