Ignore:
Timestamp:
10/04/17 11:45:14 (7 years ago)
Author:
yushan
Message:

EP updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_intercomm.cpp

    r1196 r1287  
    3232 
    3333 
    34  
    3534    if(ep_rank == local_leader) 
    3635    { 
    37       ::MPI_Comm_rank(MPI_COMM_WORLD_STD, &leader_ranks[0]); 
     36      MPI_Comm_rank(MPI_COMM_WORLD, &leader_ranks[0]); 
    3837 
    3938      leader_ranks[1] = mpi_size; 
    4039      MPI_Comm_rank(peer_comm, &leader_ranks[2]); 
    4140 
    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); 
    4949    } 
    5050 
    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     
    5355    MPI_Barrier(local_comm); 
     56     
    5457 
    5558    if(leader_ranks[0] == leader_ranks[3]) 
     
    6568      { 
    6669        // change leader 
    67         if(ep_rank == local_leader) Debug("calling MPI_Intercomm_create_from_world\n"); 
    68  
    6970        int new_local_leader; 
    7071 
     
    128129            new_tag_in_world = TAG++; 
    129130          } 
    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); 
    132133        } 
    133134        else 
     
    136137          { 
    137138            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); 
    141142        } 
    142143 
     
    144145        if(ep_rank == new_local_leader) 
    145146        { 
    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); 
    150151 
    151152 
    152153        if(ep_rank == local_leader) 
    153154        { 
    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        } 
    171163 
    172164        MPI_Bcast(&leader_in_world[1], 1, MPI_INT, local_leader, local_comm); 
    173165 
    174  
    175  
    176166        local_comm.ep_comm_ptr->comm_label = tag; 
    177167 
    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         
    179172      } 
    180173    } 
     
    194187      return 0; 
    195188    }  
    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)) 
    197190    { 
    198191      ::MPI_Comm mpi_comm = static_cast< ::MPI_Comm> (comm.mpi_comm); 
Note: See TracChangeset for help on using the changeset viewer.