Ignore:
Timestamp:
06/04/18 19:25:08 (6 years ago)
Author:
yushan
Message:

save dev. TO DO : test with xios

File:
1 edited

Legend:

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

    r1354 r1520  
    1717{ 
    1818 
     19  int MPI_Allgather_local(const void *sendbuf, int count, MPI_Datatype datatype, void *recvbuf, MPI_Comm comm) 
     20  { 
     21    assert(valid_type(datatype)); 
     22 
     23    ::MPI_Aint datasize, lb; 
     24    ::MPI_Type_get_extent(to_mpi_type(datatype), &lb, &datasize); 
     25 
     26    int ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 
     27    int num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 
     28 
     29    #pragma omp critical (write_buffer) 
     30    comm->my_buffer->void_buffer[ep_rank_loc] = const_cast< void* >(sendbuf); 
     31 
     32    MPI_Barrier_local(comm); 
     33 
     34    #pragma omp critical (read_buffer) 
     35    { 
     36      for(int i=0; i<num_ep; i++) 
     37        memcpy(recvbuf + datasize * i * count, comm->my_buffer->void_buffer[i], datasize * count); 
     38    } 
     39    MPI_Barrier_local(comm); 
     40  } 
     41 
    1942  int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) 
    2043  { 
    2144 
    22     if(!comm.is_ep && comm.mpi_comm) 
     45    if(!comm->is_ep && comm->mpi_comm) 
    2346    { 
    24       return ::MPI_Allgather(const_cast<void*>(sendbuf), sendcount, to_mpi_type(sendtype), recvbuf, recvcount, to_mpi_type(recvtype), to_mpi_comm(comm.mpi_comm)); 
     47      return ::MPI_Allgather(const_cast<void*>(sendbuf), sendcount, to_mpi_type(sendtype), recvbuf, recvcount, to_mpi_type(recvtype), to_mpi_comm(comm->mpi_comm)); 
    2548    } 
    2649 
     
    3760 
    3861 
    39     int ep_rank = comm.ep_comm_ptr->size_rank_info[0].first; 
    40     int ep_rank_loc = comm.ep_comm_ptr->size_rank_info[1].first; 
    41     int mpi_rank = comm.ep_comm_ptr->size_rank_info[2].first; 
    42     int ep_size = comm.ep_comm_ptr->size_rank_info[0].second; 
    43     int num_ep = comm.ep_comm_ptr->size_rank_info[1].second; 
    44     int mpi_size = comm.ep_comm_ptr->size_rank_info[2].second; 
     62    int ep_rank = comm->ep_comm_ptr->size_rank_info[0].first; 
     63    int ep_rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; 
     64    int mpi_rank = comm->ep_comm_ptr->size_rank_info[2].first; 
     65    int ep_size = comm->ep_comm_ptr->size_rank_info[0].second; 
     66    int num_ep = comm->ep_comm_ptr->size_rank_info[1].second; 
     67    int mpi_size = comm->ep_comm_ptr->size_rank_info[2].second; 
    4568 
    4669    bool is_master = ep_rank_loc==0; 
     
    7093      int local_sendcount = num_ep * count; 
    7194 
    72       ::MPI_Allgather(&local_sendcount, 1, to_mpi_type(MPI_INT), mpi_recvcounts, 1, to_mpi_type(MPI_INT), to_mpi_comm(comm.mpi_comm)); 
     95      ::MPI_Allgather(&local_sendcount, 1, to_mpi_type(MPI_INT), mpi_recvcounts, 1, to_mpi_type(MPI_INT), to_mpi_comm(comm->mpi_comm)); 
    7396 
    7497      mpi_displs[0] = 0; 
     
    79102 
    80103     
    81       ::MPI_Allgatherv(local_recvbuf, num_ep * count, to_mpi_type(datatype), tmp_recvbuf, mpi_recvcounts, mpi_displs, to_mpi_type(datatype), to_mpi_comm(comm.mpi_comm)); 
     104      ::MPI_Allgatherv(local_recvbuf, num_ep * count, to_mpi_type(datatype), tmp_recvbuf, mpi_recvcounts, mpi_displs, to_mpi_type(datatype), to_mpi_comm(comm->mpi_comm)); 
    82105 
    83106 
     
    86109      for(int i=0; i<ep_size; i++) 
    87110      { 
    88         offset = mpi_displs[comm.rank_map->at(i).second] + comm.rank_map->at(i).first * sendcount;  
     111        offset = mpi_displs[comm->ep_rank_map->at(i).second] + comm->ep_rank_map->at(i).first * sendcount;  
    89112        memcpy(recvbuf + i*sendcount*datasize, tmp_recvbuf+offset*datasize, sendcount*datasize); 
    90113      } 
Note: See TracChangeset for help on using the changeset viewer.