• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 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 #include "runtime/device/gpu/mpi/mpi_initializer.h"
18 #include <dlfcn.h>
19 #include <mpi.h>
20 #include <pybind11/operators.h>
21 #include <iostream>
22 #include <vector>
23 #include <string>
24 
25 namespace mindspore {
26 namespace device {
27 namespace gpu {
GetInstance()28 MPIInitializer &MPIInitializer::GetInstance() {
29   static MPIInitializer instance;
30   return instance;
31 }
32 
get_rank_id(const std::string & group)33 int MPIInitializer::get_rank_id(const std::string &group) { return GetRankIDByGroup(group); }
34 
get_rank_size(const std::string & group)35 int MPIInitializer::get_rank_size(const std::string &group) { return GetGroupSize(group); }
36 
PYBIND11_MODULE(_ms_mpi,mpi_initializer)37 PYBIND11_MODULE(_ms_mpi, mpi_initializer) {
38   mpi_initializer.doc() = "mindspore mpi python wrapper";
39   mpi_initializer.def("get_rank_id", &MPIInitializer::get_rank_id, "get rank id");
40   mpi_initializer.def("get_rank_size", &MPIInitializer::get_rank_size, "get rank size");
41 }
42 }  // namespace gpu
43 }  // namespace device
44 }  // namespace mindspore
45