Changeset 1053 for XIOS/dev/branch_yushan/extern/src_ep_dev/ep_merge.cpp
- Timestamp:
- 02/17/17 17:55:37 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_yushan/extern/src_ep_dev/ep_merge.cpp
r1037 r1053 39 39 local_mpi_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].second; 40 40 41 42 if(local_ep_rank == 0) 43 { 44 MPI_Status status; 45 MPI_Request req_s, req_r; 46 MPI_Isend(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_s); 47 MPI_Irecv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_r); 48 49 MPI_Wait(&req_s, &status); 50 MPI_Wait(&req_r, &status); 51 } 52 53 54 MPI_Bcast(&remote_high, 1, MPI_INT, 0, *(inter_comm.ep_comm_ptr->intercomm->local_comm)); 55 56 // printf("%d, %d, %d, %d\n", local_ep_size, remote_ep_size, local_high, remote_high); 57 58 59 MPI_Comm_dup(inter_comm, newintracomm); 60 61 int my_ep_rank = local_high<remote_high? local_ep_rank: local_ep_rank+remote_ep_size; 62 63 64 int intra_ep_rank, intra_ep_rank_loc, intra_mpi_rank; 65 int intra_ep_size, intra_num_ep, intra_mpi_size; 66 67 intra_ep_rank = newintracomm->ep_comm_ptr->size_rank_info[0].first; 68 intra_ep_rank_loc = newintracomm->ep_comm_ptr->size_rank_info[1].first; 69 intra_mpi_rank = newintracomm->ep_comm_ptr->size_rank_info[2].first; 70 intra_ep_size = newintracomm->ep_comm_ptr->size_rank_info[0].second; 71 intra_num_ep = newintracomm->ep_comm_ptr->size_rank_info[1].second; 72 intra_mpi_size = newintracomm->ep_comm_ptr->size_rank_info[2].second; 73 74 75 MPI_Barrier_local(*newintracomm); 76 77 78 int *reorder; 79 if(intra_ep_rank_loc == 0) 80 { 81 reorder = new int[intra_ep_size]; 82 } 83 84 85 MPI_Gather(&my_ep_rank, 1, MPI_INT, reorder, 1, MPI_INT, 0, *newintracomm); 86 if(intra_ep_rank_loc == 0) 87 { 88 ::MPI_Bcast(reorder, intra_ep_size, MPI_INT_STD, 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm)); 89 90 vector< pair<int, int> > tmp_rank_map(intra_ep_size); 91 92 93 for(int i=0; i<intra_ep_size; i++) 94 { 95 tmp_rank_map[reorder[i]] = newintracomm->rank_map->at(i) ; 96 } 97 98 newintracomm->rank_map->swap(tmp_rank_map); 99 100 tmp_rank_map.clear(); 101 } 102 103 MPI_Barrier_local(*newintracomm); 104 105 (*newintracomm).ep_comm_ptr->size_rank_info[0].first = my_ep_rank; 106 107 if(intra_ep_rank_loc == 0) 108 { 109 delete[] reorder; 110 } 111 112 return MPI_SUCCESS; 113 } 114 115 116 117 118 119 int MPI_Intercomm_merge(MPI_Comm inter_comm, bool high, MPI_Comm *newintracomm) 120 { 121 122 assert(inter_comm.is_intercomm); 123 124 if(inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->comm_label == -99) 125 { 126 return MPI_Intercomm_merge_unique_leader(inter_comm, high, newintracomm); 127 } 128 129 130 Debug("intercomm_merge kernel\n"); 131 132 int ep_rank, ep_rank_loc, mpi_rank; 133 int ep_size, num_ep, mpi_size; 134 135 ep_rank = inter_comm.ep_comm_ptr->size_rank_info[0].first; 136 ep_rank_loc = inter_comm.ep_comm_ptr->size_rank_info[1].first; 137 mpi_rank = inter_comm.ep_comm_ptr->size_rank_info[2].first; 138 ep_size = inter_comm.ep_comm_ptr->size_rank_info[0].second; 139 num_ep = inter_comm.ep_comm_ptr->size_rank_info[1].second; 140 mpi_size = inter_comm.ep_comm_ptr->size_rank_info[2].second; 141 142 143 int local_ep_rank, local_ep_rank_loc, local_mpi_rank; 144 int local_ep_size, local_num_ep, local_mpi_size; 145 146 147 local_ep_rank = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[0].first; 148 local_ep_rank_loc = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].first; 149 local_mpi_rank = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].first; 150 local_ep_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[0].second; 151 local_num_ep = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].second; 152 local_mpi_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].second; 153 154 int remote_ep_size = inter_comm.ep_comm_ptr->intercomm->remote_rank_map->size(); 155 156 int local_high = high; 157 int remote_high; 158 159 MPI_Barrier(inter_comm); 41 160 42 161 // if(local_ep_rank == 0 && high == false) … … 65 184 } 66 185 67 68 186 MPI_Bcast(&remote_high, 1, MPI_INT, 0, *(inter_comm.ep_comm_ptr->intercomm->local_comm)); 69 187 70 // printf("%d, %d, %d, %d\n", local_ep_size, remote_ep_size, local_high, remote_high); 71 72 73 MPI_Comm_dup(inter_comm, newintracomm); 188 int intercomm_high; 189 if(ep_rank == 0) intercomm_high = local_high; 190 MPI_Bcast(&intercomm_high, 1, MPI_INT, 0, inter_comm); 191 192 //printf("remote_ep_size = %d, local_high = %d, remote_high = %d, intercomm_high = %d\n", remote_ep_size, local_high, remote_high, intercomm_high); 193 194 195 ::MPI_Comm mpi_intracomm; 196 MPI_Comm *ep_intracomm; 197 198 if(ep_rank_loc == 0) 199 { 200 201 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(inter_comm.ep_comm_ptr->intercomm->mpi_inter_comm); 202 203 ::MPI_Intercomm_merge(mpi_comm, intercomm_high, &mpi_intracomm); 204 MPI_Info info; 205 MPI_Comm_create_endpoints(mpi_intracomm, num_ep, info, ep_intracomm); 206 207 inter_comm.ep_comm_ptr->comm_list->mem_bridge = ep_intracomm; 208 209 } 210 211 212 213 MPI_Barrier_local(inter_comm); 214 215 *newintracomm = inter_comm.ep_comm_ptr->comm_list->mem_bridge[ep_rank_loc]; 74 216 75 217 int my_ep_rank = local_high<remote_high? local_ep_rank: local_ep_rank+remote_ep_size; 76 77 218 78 219 int intra_ep_rank, intra_ep_rank_loc, intra_mpi_rank; … … 87 228 88 229 230 89 231 MPI_Barrier_local(*newintracomm); 90 232 … … 97 239 98 240 241 99 242 MPI_Gather(&my_ep_rank, 1, MPI_INT, reorder, 1, MPI_INT, 0, *newintracomm); 100 243 if(intra_ep_rank_loc == 0) 101 244 { 102 #ifdef _serialized 103 #pragma omp critical (_mpi_call) 104 #endif // _serialized 245 105 246 ::MPI_Bcast(reorder, intra_ep_size, MPI_INT_STD, 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm)); 106 247 … … 122 263 (*newintracomm).ep_comm_ptr->size_rank_info[0].first = my_ep_rank; 123 264 124 if(intra_ep_rank_loc == 0)125 {126 delete[] reorder;127 }128 129 return MPI_SUCCESS;130 }131 132 133 134 135 136 int MPI_Intercomm_merge(MPI_Comm inter_comm, bool high, MPI_Comm *newintracomm)137 {138 139 assert(inter_comm.is_intercomm);140 141 if(inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->comm_label == -99)142 {143 return MPI_Intercomm_merge_unique_leader(inter_comm, high, newintracomm);144 }145 146 147 Debug("intercomm_merge kernel\n");148 149 int ep_rank, ep_rank_loc, mpi_rank;150 int ep_size, num_ep, mpi_size;151 152 ep_rank = inter_comm.ep_comm_ptr->size_rank_info[0].first;153 ep_rank_loc = inter_comm.ep_comm_ptr->size_rank_info[1].first;154 mpi_rank = inter_comm.ep_comm_ptr->size_rank_info[2].first;155 ep_size = inter_comm.ep_comm_ptr->size_rank_info[0].second;156 num_ep = inter_comm.ep_comm_ptr->size_rank_info[1].second;157 mpi_size = inter_comm.ep_comm_ptr->size_rank_info[2].second;158 159 160 int local_ep_rank, local_ep_rank_loc, local_mpi_rank;161 int local_ep_size, local_num_ep, local_mpi_size;162 163 164 local_ep_rank = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[0].first;165 local_ep_rank_loc = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].first;166 local_mpi_rank = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].first;167 local_ep_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[0].second;168 local_num_ep = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].second;169 local_mpi_size = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[2].second;170 171 int remote_ep_size = inter_comm.ep_comm_ptr->intercomm->remote_rank_map->size();172 173 int local_high = high;174 int remote_high;175 176 MPI_Barrier(inter_comm);177 178 // if(local_ep_rank == 0 && high == false)179 // {180 // MPI_Status status;181 // MPI_Send(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm);182 // MPI_Recv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &status);183 // }184 //185 // if(local_ep_rank == 0 && high == true)186 // {187 // MPI_Status status;188 // MPI_Recv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &status);189 // MPI_Send(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm);190 // }191 192 if(local_ep_rank == 0)193 {194 MPI_Status status;195 MPI_Request req_s, req_r;196 MPI_Isend(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_s);197 MPI_Irecv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_r);198 199 MPI_Wait(&req_s, &status);200 MPI_Wait(&req_r, &status);201 }202 203 MPI_Bcast(&remote_high, 1, MPI_INT, 0, *(inter_comm.ep_comm_ptr->intercomm->local_comm));204 205 int intercomm_high;206 if(ep_rank == 0) intercomm_high = local_high;207 MPI_Bcast(&intercomm_high, 1, MPI_INT, 0, inter_comm);208 209 //printf("remote_ep_size = %d, local_high = %d, remote_high = %d, intercomm_high = %d\n", remote_ep_size, local_high, remote_high, intercomm_high);210 211 212 ::MPI_Comm mpi_intracomm;213 MPI_Comm *ep_intracomm;214 215 if(ep_rank_loc == 0)216 {217 218 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(inter_comm.ep_comm_ptr->intercomm->mpi_inter_comm);219 #ifdef _serialized220 #pragma omp critical (_mpi_call)221 #endif // _serialized222 ::MPI_Intercomm_merge(mpi_comm, intercomm_high, &mpi_intracomm);223 MPI_Info info;224 MPI_Comm_create_endpoints(mpi_intracomm, num_ep, info, ep_intracomm);225 226 inter_comm.ep_comm_ptr->comm_list->mem_bridge = ep_intracomm;227 228 }229 230 231 232 MPI_Barrier_local(inter_comm);233 234 *newintracomm = inter_comm.ep_comm_ptr->comm_list->mem_bridge[ep_rank_loc];235 236 int my_ep_rank = local_high<remote_high? local_ep_rank: local_ep_rank+remote_ep_size;237 238 int intra_ep_rank, intra_ep_rank_loc, intra_mpi_rank;239 int intra_ep_size, intra_num_ep, intra_mpi_size;240 241 intra_ep_rank = newintracomm->ep_comm_ptr->size_rank_info[0].first;242 intra_ep_rank_loc = newintracomm->ep_comm_ptr->size_rank_info[1].first;243 intra_mpi_rank = newintracomm->ep_comm_ptr->size_rank_info[2].first;244 intra_ep_size = newintracomm->ep_comm_ptr->size_rank_info[0].second;245 intra_num_ep = newintracomm->ep_comm_ptr->size_rank_info[1].second;246 intra_mpi_size = newintracomm->ep_comm_ptr->size_rank_info[2].second;247 248 249 250 MPI_Barrier_local(*newintracomm);251 252 253 int *reorder;254 if(intra_ep_rank_loc == 0)255 {256 reorder = new int[intra_ep_size];257 }258 259 260 261 MPI_Gather(&my_ep_rank, 1, MPI_INT, reorder, 1, MPI_INT, 0, *newintracomm);262 if(intra_ep_rank_loc == 0)263 {264 #ifdef _serialized265 #pragma omp critical (_mpi_call)266 #endif // _serialized267 ::MPI_Bcast(reorder, intra_ep_size, MPI_INT_STD, 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm));268 269 vector< pair<int, int> > tmp_rank_map(intra_ep_size);270 271 272 for(int i=0; i<intra_ep_size; i++)273 {274 tmp_rank_map[reorder[i]] = newintracomm->rank_map->at(i) ;275 }276 277 newintracomm->rank_map->swap(tmp_rank_map);278 279 tmp_rank_map.clear();280 }281 282 MPI_Barrier_local(*newintracomm);283 284 (*newintracomm).ep_comm_ptr->size_rank_info[0].first = my_ep_rank;285 286 265 287 266 if(intra_ep_rank_loc == 0)
Note: See TracChangeset
for help on using the changeset viewer.