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