[1134] | 1 | #include "ep_lib.hpp" |
---|
| 2 | #include <mpi.h> |
---|
| 3 | #include "ep_declaration.hpp" |
---|
[1354] | 4 | #include "ep_mpi.hpp" |
---|
[1134] | 5 | |
---|
| 6 | namespace ep_lib |
---|
| 7 | { |
---|
| 8 | |
---|
[1539] | 9 | |
---|
[1520] | 10 | int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm) |
---|
| 11 | { |
---|
| 12 | |
---|
| 13 | if(!comm->is_ep) |
---|
| 14 | { |
---|
| 15 | Debug("MPI_Comm_dup with MPI\n"); |
---|
| 16 | return MPI_Comm_dup_mpi(comm, newcomm); |
---|
[1134] | 17 | } |
---|
| 18 | |
---|
[1539] | 19 | return MPI_Comm_dup_endpoint(comm, newcomm); |
---|
[1520] | 20 | |
---|
[1134] | 21 | } |
---|
| 22 | |
---|
[1539] | 23 | |
---|
| 24 | |
---|
| 25 | int MPI_Comm_dup_endpoint(MPI_Comm comm, MPI_Comm *newcomm) |
---|
[1134] | 26 | { |
---|
[1539] | 27 | int ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; |
---|
| 28 | int num_ep = comm->ep_comm_ptr->size_rank_info[1].second; |
---|
[1134] | 29 | |
---|
| 30 | |
---|
[1539] | 31 | if(0 == ep_rank_loc) |
---|
[1520] | 32 | { |
---|
[1134] | 33 | MPI_Info info; |
---|
| 34 | MPI_Comm *out_comm; |
---|
| 35 | |
---|
[1539] | 36 | MPI_Comm_create_endpoints(comm->mpi_comm, num_ep, info, out_comm); |
---|
[1520] | 37 | comm->ep_comm_ptr->comm_list[0]->mem_bridge = out_comm; |
---|
| 38 | } |
---|
[1134] | 39 | |
---|
[1520] | 40 | MPI_Barrier_local(comm); |
---|
[1134] | 41 | |
---|
[1539] | 42 | *newcomm = (comm->ep_comm_ptr->comm_list[0]->mem_bridge[ep_rank_loc]); |
---|
[1134] | 43 | |
---|
[1539] | 44 | if(comm->is_intercomm) |
---|
[1520] | 45 | { |
---|
[1539] | 46 | (*newcomm)->is_intercomm = true; |
---|
| 47 | (*newcomm)->ep_comm_ptr->size_rank_info[0] = comm->ep_comm_ptr->size_rank_info[0]; |
---|
| 48 | (*newcomm)->inter_rank_map = new INTER_RANK_MAP; |
---|
[1468] | 49 | |
---|
[1539] | 50 | for(INTER_RANK_MAP::iterator it = comm->inter_rank_map->begin(); it !=comm->inter_rank_map->end(); it++) |
---|
| 51 | { |
---|
| 52 | (*newcomm)->inter_rank_map->insert(std::make_pair(it->first, it->second)); |
---|
| 53 | } |
---|
[1134] | 54 | |
---|
[1520] | 55 | } |
---|
| 56 | |
---|
[1539] | 57 | } |
---|
[1134] | 58 | |
---|
[1539] | 59 | int MPI_Comm_dup_mpi(MPI_Comm comm, MPI_Comm *newcomm) |
---|
| 60 | { |
---|
| 61 | newcomm = new MPI_Comm; |
---|
| 62 | (*newcomm)->is_ep = false; |
---|
[1520] | 63 | |
---|
[1539] | 64 | ::MPI_Comm *output = new ::MPI_Comm; |
---|
| 65 | |
---|
| 66 | ::MPI_Comm_dup(to_mpi_comm(comm->mpi_comm), output); |
---|
[1520] | 67 | |
---|
[1539] | 68 | (*newcomm)->mpi_comm = output; |
---|
[1134] | 69 | } |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | |
---|