- Timestamp:
- 06/04/18 19:25:08 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/extern/src_ep_dev/ep_allgather.cpp
r1354 r1520 17 17 { 18 18 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 19 42 int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) 20 43 { 21 44 22 if(!comm .is_ep && comm.mpi_comm)45 if(!comm->is_ep && comm->mpi_comm) 23 46 { 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)); 25 48 } 26 49 … … 37 60 38 61 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; 45 68 46 69 bool is_master = ep_rank_loc==0; … … 70 93 int local_sendcount = num_ep * count; 71 94 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)); 73 96 74 97 mpi_displs[0] = 0; … … 79 102 80 103 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)); 82 105 83 106 … … 86 109 for(int i=0; i<ep_size; i++) 87 110 { 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; 89 112 memcpy(recvbuf + i*sendcount*datasize, tmp_recvbuf+offset*datasize, sendcount*datasize); 90 113 }
Note: See TracChangeset
for help on using the changeset viewer.