[1603] | 1 | #include "ep_lib.hpp" |
---|
| 2 | #include <mpi.h> |
---|
| 3 | #include "ep_declaration.hpp" |
---|
| 4 | #include "ep_mpi.hpp" |
---|
| 5 | |
---|
| 6 | using namespace std; |
---|
| 7 | |
---|
| 8 | namespace ep_lib |
---|
| 9 | { |
---|
| 10 | |
---|
| 11 | int MPI_Get(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, |
---|
| 12 | int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win) |
---|
| 13 | { |
---|
| 14 | int target_mpi_rank = win->comm->ep_rank_map->at(target_rank).second; |
---|
| 15 | int target_local_rank = win->comm->ep_rank_map->at(target_rank).first; |
---|
| 16 | int num_ep = win->comm->ep_comm_ptr->size_rank_info[1].second; |
---|
| 17 | if(num_ep==1) |
---|
| 18 | return ::MPI_Get(origin_addr, origin_count, to_mpi_type(origin_datatype), target_mpi_rank, to_mpi_aint(target_disp), target_count, to_mpi_type(target_datatype), |
---|
| 19 | to_mpi_win(win->server_win[target_local_rank])); |
---|
| 20 | |
---|
| 21 | else |
---|
| 22 | return ::MPI_Get(origin_addr, origin_count, to_mpi_type(origin_datatype), target_mpi_rank, to_mpi_aint(target_disp), target_count, to_mpi_type(target_datatype), |
---|
| 23 | to_mpi_win(win->client_win)); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | int MPI_Rget(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, |
---|
| 27 | int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win, MPI_Request *request) |
---|
| 28 | { |
---|
| 29 | int target_mpi_rank = win->comm->ep_rank_map->at(target_rank).second; |
---|
| 30 | int target_local_rank = win->comm->ep_rank_map->at(target_rank).first; |
---|
| 31 | int num_ep = win->comm->ep_comm_ptr->size_rank_info[1].second; |
---|
| 32 | |
---|
| 33 | ::MPI_Request mpi_request; |
---|
| 34 | if(num_ep==1) |
---|
| 35 | { |
---|
| 36 | int return_value = ::MPI_Rget(origin_addr, origin_count, to_mpi_type(origin_datatype), target_mpi_rank, to_mpi_aint(target_disp), target_count, to_mpi_type(target_datatype), |
---|
| 37 | to_mpi_win(win->server_win[target_local_rank]), &mpi_request); |
---|
| 38 | |
---|
| 39 | (*request)->mpi_request = new ::MPI_Request(mpi_request); |
---|
| 40 | |
---|
| 41 | (*request)->ep_datatype = origin_datatype; |
---|
| 42 | (*request)->type = 1; |
---|
| 43 | return return_value; |
---|
| 44 | } |
---|
| 45 | else |
---|
| 46 | { |
---|
| 47 | int return_value = ::MPI_Rget(origin_addr, origin_count, to_mpi_type(origin_datatype), target_mpi_rank, to_mpi_aint(target_disp), target_count, to_mpi_type(target_datatype), |
---|
| 48 | to_mpi_win(win->client_win), &mpi_request); |
---|
| 49 | |
---|
| 50 | (*request)->mpi_request = new ::MPI_Request(mpi_request); |
---|
| 51 | |
---|
| 52 | (*request)->ep_datatype = origin_datatype; |
---|
| 53 | (*request)->type = 1; |
---|
| 54 | return return_value; |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | } |
---|