Changeset 1287 for XIOS/dev/branch_openmp/extern/src_ep_dev/ep_merge.cpp
- Timestamp:
- 10/04/17 11:45:14 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/extern/src_ep_dev/ep_merge.cpp
r1134 r1287 42 42 if(local_ep_rank == 0) 43 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); 44 MPI_Status status[2]; 45 MPI_Request request[2]; 46 MPI_Isend(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &request[0]); 47 MPI_Irecv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &request[1]); 48 49 MPI_Waitall(2, request, status); 51 50 } 52 51 … … 54 53 MPI_Bcast(&remote_high, 1, MPI_INT, 0, *(inter_comm.ep_comm_ptr->intercomm->local_comm)); 55 54 56 // printf("%d, %d, %d, %d\n", local_ep_size, remote_ep_size, local_high, remote_high);57 55 58 56 … … 86 84 if(intra_ep_rank_loc == 0) 87 85 { 88 ::MPI_Bcast(reorder, intra_ep_size, MPI_INT_STD, 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm));86 ::MPI_Bcast(reorder, intra_ep_size, static_cast< ::MPI_Datatype> (MPI_INT), 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm)); 89 87 90 88 vector< pair<int, int> > tmp_rank_map(intra_ep_size); … … 130 128 Debug("intercomm_merge kernel\n"); 131 129 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; 130 int ep_rank_loc; 131 int num_ep; 132 136 133 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 134 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; 135 136 153 137 154 138 int remote_ep_size = inter_comm.ep_comm_ptr->intercomm->remote_rank_map->size(); 155 139 156 int local_high = high;157 int remote_high;158 140 159 141 MPI_Barrier(inter_comm); 160 161 // if(local_ep_rank == 0 && high == false)162 // {163 // MPI_Status status;164 // MPI_Send(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm);165 // MPI_Recv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &status);166 // }167 //168 // if(local_ep_rank == 0 && high == true)169 // {170 // MPI_Status status;171 // MPI_Recv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &status);172 // MPI_Send(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm);173 // }174 175 if(local_ep_rank == 0)176 {177 MPI_Status status;178 MPI_Request req_s, req_r;179 MPI_Isend(&local_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_s);180 MPI_Irecv(&remote_high, 1, MPI_INT, 0, inter_comm.ep_comm_ptr->intercomm->intercomm_tag, inter_comm, &req_r);181 182 MPI_Wait(&req_s, &status);183 MPI_Wait(&req_r, &status);184 }185 186 MPI_Bcast(&remote_high, 1, MPI_INT, 0, *(inter_comm.ep_comm_ptr->intercomm->local_comm));187 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 142 194 143 … … 201 150 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm>(inter_comm.ep_comm_ptr->intercomm->mpi_inter_comm); 202 151 203 ::MPI_Intercomm_merge(mpi_comm, intercomm_high, &mpi_intracomm);152 ::MPI_Intercomm_merge(mpi_comm, high, &mpi_intracomm); 204 153 MPI_Info info; 205 154 MPI_Comm_create_endpoints(mpi_intracomm, num_ep, info, ep_intracomm); … … 209 158 } 210 159 211 212 213 160 MPI_Barrier_local(inter_comm); 214 161 215 *newintracomm = inter_comm.ep_comm_ptr->comm_list->mem_bridge[ep_rank_loc]; 216 217 int my_ep_rank = local_high<remote_high? local_ep_rank: local_ep_rank+remote_ep_size; 218 219 int intra_ep_rank, intra_ep_rank_loc, intra_mpi_rank; 220 int intra_ep_size, intra_num_ep, intra_mpi_size; 221 222 intra_ep_rank = newintracomm->ep_comm_ptr->size_rank_info[0].first; 223 intra_ep_rank_loc = newintracomm->ep_comm_ptr->size_rank_info[1].first; 224 intra_mpi_rank = newintracomm->ep_comm_ptr->size_rank_info[2].first; 225 intra_ep_size = newintracomm->ep_comm_ptr->size_rank_info[0].second; 226 intra_num_ep = newintracomm->ep_comm_ptr->size_rank_info[1].second; 227 intra_mpi_size = newintracomm->ep_comm_ptr->size_rank_info[2].second; 228 229 230 231 MPI_Barrier_local(*newintracomm); 232 233 234 int *reorder; 235 if(intra_ep_rank_loc == 0) 236 { 237 reorder = new int[intra_ep_size]; 238 } 239 240 241 242 MPI_Gather(&my_ep_rank, 1, MPI_INT, reorder, 1, MPI_INT, 0, *newintracomm); 243 if(intra_ep_rank_loc == 0) 244 { 245 246 ::MPI_Bcast(reorder, intra_ep_size, MPI_INT_STD, 0, static_cast< ::MPI_Comm>(newintracomm->mpi_comm)); 247 248 vector< pair<int, int> > tmp_rank_map(intra_ep_size); 249 250 251 for(int i=0; i<intra_ep_size; i++) 252 { 253 tmp_rank_map[reorder[i]] = newintracomm->rank_map->at(i) ; 254 } 255 256 newintracomm->rank_map->swap(tmp_rank_map); 257 258 tmp_rank_map.clear(); 259 } 260 261 MPI_Barrier_local(*newintracomm); 162 int inter_rank; 163 MPI_Comm_rank(inter_comm, &inter_rank); 164 165 int my_ep_rank = high? inter_rank+remote_ep_size : inter_rank; 166 int my_ep_rank_loc = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].first; 167 int my_num_ep_loc = inter_comm.ep_comm_ptr->intercomm->local_comm->ep_comm_ptr->size_rank_info[1].second; 168 int my_num_ep_total = inter_comm.ep_comm_ptr->comm_list->mem_bridge[0].ep_comm_ptr->size_rank_info[1].second; 169 int my_ep_size = inter_comm.ep_comm_ptr->comm_list->mem_bridge[0].ep_comm_ptr->size_rank_info[0].second; 170 171 int tmp_intra_ep_rank_loc = high?my_ep_rank_loc+my_num_ep_total-my_num_ep_loc: my_ep_rank_loc; 172 173 174 *newintracomm = inter_comm.ep_comm_ptr->comm_list->mem_bridge[tmp_intra_ep_rank_loc]; 175 176 int newintracomm_ep_rank = (*newintracomm).ep_comm_ptr->size_rank_info[0].first; 177 int newintracomm_ep_rank_loc = (*newintracomm).ep_comm_ptr->size_rank_info[1].first; 178 int newintracomm_mpi_rank = (*newintracomm).ep_comm_ptr->size_rank_info[2].first; 179 int newintracomm_ep_size = (*newintracomm).ep_comm_ptr->size_rank_info[0].second; 180 int newintracomm_num_ep = (*newintracomm).ep_comm_ptr->size_rank_info[1].second; 181 int newintracomm_mpi_size = (*newintracomm).ep_comm_ptr->size_rank_info[2].second; 182 183 184 int buf[3]; 185 buf[0] = my_ep_rank; 186 buf[1] = tmp_intra_ep_rank_loc; 187 buf[2] = newintracomm->ep_comm_ptr->size_rank_info[2].first; 188 189 // printf("my_ep_rank = %d, tmp_intra_ep_rank_loc = %d, mpi_rank = %d\n", my_ep_rank, tmp_intra_ep_rank_loc, newintracomm->ep_comm_ptr->size_rank_info[2].first); 190 191 int *rankmap_buf; 192 rankmap_buf = new int [3*my_ep_size]; 193 194 MPI_Allgather(buf, 3, MPI_INT, rankmap_buf, 3, MPI_INT, *newintracomm); 195 196 197 // printf(" ID = %d : rankmap_buf = (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d), (%d %d %d)\n", newintracomm_ep_rank, 198 // rankmap_buf[0], rankmap_buf[1], rankmap_buf[2], rankmap_buf[3], rankmap_buf[4], rankmap_buf[5], rankmap_buf[6], rankmap_buf[7], rankmap_buf[8], rankmap_buf[9], 199 // rankmap_buf[10], rankmap_buf[11], rankmap_buf[12], rankmap_buf[13], rankmap_buf[14], rankmap_buf[15], rankmap_buf[16], rankmap_buf[17], rankmap_buf[18], rankmap_buf[19], 200 // rankmap_buf[20], rankmap_buf[21], rankmap_buf[22], rankmap_buf[23], rankmap_buf[24], rankmap_buf[25], rankmap_buf[26], rankmap_buf[27], rankmap_buf[28], rankmap_buf[29], 201 // rankmap_buf[30], rankmap_buf[31], rankmap_buf[32], rankmap_buf[33], rankmap_buf[34], rankmap_buf[35], rankmap_buf[36], rankmap_buf[37], rankmap_buf[38], rankmap_buf[39], 202 // rankmap_buf[40], rankmap_buf[41], rankmap_buf[42], rankmap_buf[43], rankmap_buf[44], rankmap_buf[45], rankmap_buf[46], rankmap_buf[47]); 203 204 205 for(int i=0; i<newintracomm_ep_size; i++) 206 { 207 (*newintracomm).rank_map->at(rankmap_buf[3*i]).first = rankmap_buf[3*i+1]; 208 (*newintracomm).rank_map->at(rankmap_buf[3*i]).second = rankmap_buf[3*i+2]; 209 } 210 262 211 263 212 (*newintracomm).ep_comm_ptr->size_rank_info[0].first = my_ep_rank; 264 265 266 if(intra_ep_rank_loc == 0) 267 { 268 delete[] reorder; 269 270 } 271 272 /* 273 if(intra_ep_rank == 0) 274 { 275 for(int i=0; i<intra_ep_size; i++) 276 { 277 printf("intra rank_map[%d] = (%d, %d)\n", i, newintracomm->rank_map->at(i).first, newintracomm->rank_map->at(i).second); 278 } 279 } 280 */ 213 (*newintracomm).ep_comm_ptr->size_rank_info[1].first = tmp_intra_ep_rank_loc; 214 215 216 delete[] rankmap_buf; 217 218 281 219 return MPI_SUCCESS; 282 220
Note: See TracChangeset
for help on using the changeset viewer.