- Timestamp:
- 10/04/17 11:45:14 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/extern/src_ep_dev/ep_intercomm.cpp
r1196 r1287 32 32 33 33 34 35 34 if(ep_rank == local_leader) 36 35 { 37 ::MPI_Comm_rank(MPI_COMM_WORLD_STD, &leader_ranks[0]);36 MPI_Comm_rank(MPI_COMM_WORLD, &leader_ranks[0]); 38 37 39 38 leader_ranks[1] = mpi_size; 40 39 MPI_Comm_rank(peer_comm, &leader_ranks[2]); 41 40 42 MPI_Request req_s, req_r; 43 MPI_Isend(&leader_ranks[0], 3, MPI_INT_STD, remote_leader, tag, peer_comm, &req_s); 44 MPI_Status status; 45 MPI_Wait(&req_s, &status); 46 47 MPI_Irecv(&leader_ranks[3], 3, MPI_INT_STD, remote_leader, tag, peer_comm, &req_r); 48 MPI_Wait(&req_r, &status); 41 //printf("leader_ranks = %d, %d, %d\n", leader_ranks[0], leader_ranks[1], leader_ranks[2]); 42 MPI_Request request[2]; 43 MPI_Status status[2]; 44 45 MPI_Isend(&leader_ranks[0], 3, static_cast< ::MPI_Datatype>(MPI_INT), remote_leader, tag, peer_comm, &request[0]); 46 MPI_Irecv(&leader_ranks[3], 3, static_cast< ::MPI_Datatype>(MPI_INT), remote_leader, tag, peer_comm, &request[1]); 47 48 MPI_Waitall(2, request, status); 49 49 } 50 50 51 MPI_Bcast(leader_ranks, 6, MPI_INT_STD, local_leader, local_comm); 52 51 52 MPI_Bcast(leader_ranks, 6, static_cast< ::MPI_Datatype>(MPI_INT), local_leader, local_comm); 53 54 53 55 MPI_Barrier(local_comm); 56 54 57 55 58 if(leader_ranks[0] == leader_ranks[3]) … … 65 68 { 66 69 // change leader 67 if(ep_rank == local_leader) Debug("calling MPI_Intercomm_create_from_world\n");68 69 70 int new_local_leader; 70 71 … … 128 129 new_tag_in_world = TAG++; 129 130 } 130 MPI_Bcast(&new_tag_in_world, 1, MPI_INT_STD, new_local_leader, local_comm);131 if(ep_rank == local_leader) MPI_Send(&new_tag_in_world, 1, MPI_INT_STD, remote_leader, tag, peer_comm);131 MPI_Bcast(&new_tag_in_world, 1, static_cast< ::MPI_Datatype> (MPI_INT), new_local_leader, local_comm); 132 if(ep_rank == local_leader) MPI_Send(&new_tag_in_world, 1, static_cast< ::MPI_Datatype> (MPI_INT), remote_leader, tag, peer_comm); 132 133 } 133 134 else … … 136 137 { 137 138 MPI_Status status; 138 MPI_Recv(&new_tag_in_world, 1, MPI_INT_STD, remote_leader, tag, peer_comm, &status);139 } 140 MPI_Bcast(&new_tag_in_world, 1, MPI_INT_STD, new_local_leader, local_comm);139 MPI_Recv(&new_tag_in_world, 1, static_cast< ::MPI_Datatype> (MPI_INT), remote_leader, tag, peer_comm, &status); 140 } 141 MPI_Bcast(&new_tag_in_world, 1, static_cast< ::MPI_Datatype> (MPI_INT), new_local_leader, local_comm); 141 142 } 142 143 … … 144 145 if(ep_rank == new_local_leader) 145 146 { 146 ::MPI_Comm_rank( MPI_COMM_WORLD_STD, &leader_in_world[0]);147 } 148 149 MPI_Bcast(&leader_in_world[0], 1, MPI_INT_STD, new_local_leader, local_comm);147 ::MPI_Comm_rank(static_cast< ::MPI_Comm >(MPI_COMM_WORLD.mpi_comm), &leader_in_world[0]); 148 } 149 150 MPI_Bcast(&leader_in_world[0], 1, static_cast< ::MPI_Datatype> (MPI_INT), new_local_leader, local_comm); 150 151 151 152 152 153 if(ep_rank == local_leader) 153 154 { 154 MPI_Request req_s, req_r; 155 156 MPI_Isend(&leader_in_world[0], 1, MPI_INT_STD, remote_leader, tag, peer_comm, &req_s); 157 MPI_Irecv(&leader_in_world[1], 1, MPI_INT_STD, remote_leader, tag, peer_comm, &req_r); 158 159 MPI_Status status; 160 MPI_Wait(&req_s, &status); 161 MPI_Wait(&req_r, &status); 162 163 /* 164 MPI_Send(&leader_in_world[0], 1, MPI_INT_STD, remote_leader, tag, peer_comm); 165 MPI_Status status; 166 MPI_Recv(&leader_in_world[1], 1, MPI_INT_STD, remote_leader, tag, peer_comm, &status); 167 */ 168 } 169 170 155 MPI_Request request[2]; 156 MPI_Status status[2]; 157 158 MPI_Isend(&leader_in_world[0], 1, static_cast< ::MPI_Datatype> (MPI_INT), remote_leader, tag, peer_comm, &request[0]); 159 MPI_Irecv(&leader_in_world[1], 1, static_cast< ::MPI_Datatype> (MPI_INT), remote_leader, tag, peer_comm, &request[1]); 160 161 MPI_Waitall(2, request, status); 162 } 171 163 172 164 MPI_Bcast(&leader_in_world[1], 1, MPI_INT, local_leader, local_comm); 173 165 174 175 176 166 local_comm.ep_comm_ptr->comm_label = tag; 177 167 178 return MPI_Intercomm_create_from_world(local_comm, new_local_leader, MPI_COMM_WORLD_STD, leader_in_world[1], new_tag_in_world, newintercomm); 168 if(ep_rank == local_leader) Debug("calling MPI_Intercomm_create_from_world\n"); 169 170 return MPI_Intercomm_create_from_world(local_comm, new_local_leader, static_cast< ::MPI_Comm >(MPI_COMM_WORLD.mpi_comm), leader_in_world[1], new_tag_in_world, newintercomm); 171 179 172 } 180 173 } … … 194 187 return 0; 195 188 } 196 else if(comm.mpi_comm != MPI_COMM_NULL_STD)189 else if(comm.mpi_comm != static_cast< ::MPI_Comm>(MPI_COMM_NULL.mpi_comm)) 197 190 { 198 191 ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.mpi_comm);
Note: See TracChangeset
for help on using the changeset viewer.