Ignore:
Timestamp:
05/28/18 17:28:07 (3 years ago)
Author:
yushan
Message:

rank_map is passed from vector to map, in order to have more flexibility in comm_split

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/ep_dev/ep_intercomm_world.cpp

    r1500 r1503  
    4444 
    4545    if(ep_rank == local_leader) { is_proc_master = true; is_local_leader = true; is_final_master = true;} 
    46     if(ep_rank_loc == 0 && mpi_rank != local_comm->rank_map->at(local_leader).second) is_proc_master = true; 
     46    if(ep_rank_loc == 0 && mpi_rank != local_comm->ep_rank_map->at(local_leader).second) is_proc_master = true; 
    4747 
    4848 
     
    105105      } 
    106106 
    107       ::MPI_Bcast(recv_buf.data(), 4, to_mpi_type(MPI_INT), local_comm->rank_map->at(local_leader).second, local_mpi_comm); 
     107      ::MPI_Bcast(recv_buf.data(), 4, to_mpi_type(MPI_INT), local_comm->ep_rank_map->at(local_leader).second, local_mpi_comm); 
    108108 
    109109      size_info[1] = recv_buf[0]; 
     
    135135      } 
    136136 
    137       ::MPI_Bcast(recv_buf.data(), 3*size_info[1], to_mpi_type(MPI_INT), local_comm->rank_map->at(local_leader).second, local_mpi_comm); 
     137      ::MPI_Bcast(recv_buf.data(), 3*size_info[1], to_mpi_type(MPI_INT), local_comm->ep_rank_map->at(local_leader).second, local_mpi_comm); 
    138138 
    139139      std::copy ( recv_buf.data(), recv_buf.data() + size_info[1], rank_info[2].begin() ); 
     
    261261      } 
    262262 
    263       ::MPI_Bcast(&size_info[2], 2, to_mpi_type(MPI_INT), local_comm->rank_map->at(local_leader).second, local_mpi_comm); 
     263      ::MPI_Bcast(&size_info[2], 2, to_mpi_type(MPI_INT), local_comm->ep_rank_map->at(local_leader).second, local_mpi_comm); 
    264264 
    265265      new_rank_info[2].resize(size_info[3]); 
     
    283283      } 
    284284 
    285       ::MPI_Bcast(recv_buf.data(),   3*size_info[3], to_mpi_type(MPI_INT), local_comm->rank_map->at(local_leader).second, local_mpi_comm); 
     285      ::MPI_Bcast(recv_buf.data(),   3*size_info[3], to_mpi_type(MPI_INT), local_comm->ep_rank_map->at(local_leader).second, local_mpi_comm); 
    286286 
    287287      std::copy ( recv_buf.data(), recv_buf.data() + size_info[3], new_rank_info[2].begin() ); 
     
    315315      } 
    316316 
    317       ::MPI_Bcast(&leader_info[2], 1, to_mpi_type(MPI_INT), local_comm->rank_map->at(local_leader).second, local_mpi_comm); 
     317      ::MPI_Bcast(&leader_info[2], 1, to_mpi_type(MPI_INT), local_comm->ep_rank_map->at(local_leader).second, local_mpi_comm); 
    318318 
    319319      if(new_comm != static_cast< ::MPI_Comm* >(MPI_COMM_NULL->mpi_comm)) 
     
    512512    { 
    513513      ::MPI_Status status; 
    514  
    515       ::MPI_Send((*newintercomm)->rank_map->data(), 2*local_intercomm_size, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm); 
    516  
    517       ::MPI_Recv((*newintercomm)->ep_comm_ptr->intercomm->intercomm_rank_map->data(), 2*remote_intercomm_size, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &status); 
     514       
     515      std::vector<std::pair<int, std::pair<int, int> > > map2vec((*newintercomm)->ep_rank_map->size()); 
     516      std::vector<std::pair<int, std::pair<int, int> > > vec2map((*newintercomm)->ep_comm_ptr->intercomm->intercomm_rank_map->size()); 
     517       
     518      int ii=0; 
     519      for(std::map<int, std::pair<int, int> >::iterator it = (*newintercomm)->ep_rank_map->begin(); it != (*newintercomm)->ep_rank_map->end(); it++) 
     520      { 
     521        map2vec[ii++] = make_pair(it->first, make_pair(it->second.first, it->second.second)); 
     522      } 
     523       
     524       
     525      ::MPI_Send(map2vec.data(), 3*local_intercomm_size, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm); 
     526      ::MPI_Recv(vec2map.data(), 3*remote_intercomm_size, to_mpi_type(MPI_INT), mpi_remote_leader, tag, peer_comm, &status); 
     527       
     528      
     529      for(ii=0; ii<vec2map.size(); ii++) 
     530      { 
     531        (*newintercomm)->ep_comm_ptr->intercomm->intercomm_rank_map->at(vec2map[ii].first) = make_pair(vec2map[ii].second.first, vec2map[ii].second.second); 
     532      } 
    518533    } 
    519534 
Note: See TracChangeset for help on using the changeset viewer.