• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CLUSTER_DUMMY_CLUSTER_CONTEXT_H_
18 #define MINDSPORE_CCSRC_DISTRIBUTED_CLUSTER_DUMMY_CLUSTER_CONTEXT_H_
19 
20 #include <map>
21 #include <set>
22 #include <string>
23 #include <memory>
24 #include <atomic>
25 #include <vector>
26 #include "include/backend/distributed/constants.h"
27 #include "utils/log_adapter.h"
28 #include "utils/ms_utils.h"
29 #include "include/backend/visible.h"
30 
31 namespace mindspore {
32 namespace distributed {
33 namespace cluster {
34 // The dummy cluster context interface. This class is for ut test and windows compiling.
35 class BACKEND_EXPORT ClusterContext {
36  public:
37   ~ClusterContext() = default;
38   DISABLE_COPY_AND_ASSIGN(ClusterContext)
39   static std::shared_ptr<ClusterContext> instance();
40 
41   bool Initialize() const;
42   bool Finalize(uint32_t timeout = kDefaultFinishTimeout) const;
43   std::string node_role() const;
44   uint32_t node_num(const std::string &node_role);
45   bool initialized() const;
46   void set_cluster_exit_with_exception();
47   bool cluster_exit_with_exception() const;
48 
49  private:
50   ClusterContext() = default;
51 };
52 }  // namespace cluster
53 }  // namespace distributed
54 }  // namespace mindspore
55 #endif  // MINDSPORE_CCSRC_DISTRIBUTED_CLUSTER_DUMMY_CLUSTER_CONTEXT_H_
56