[1604] | 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_Accumulate(const 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_Op op, 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_Accumulate(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_op(op), to_mpi_win(win->server_win[target_local_rank])); |
---|
| 20 | |
---|
| 21 | else |
---|
| 22 | return ::MPI_Accumulate(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_op(op), to_mpi_win(win->client_win)); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | int MPI_Raccumulate(const 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_Op op, 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 | ::MPI_Request mpi_request; |
---|
| 33 | |
---|
| 34 | if(num_ep==1) |
---|
| 35 | { |
---|
| 36 | int return_value = ::MPI_Raccumulate(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_op(op), to_mpi_win(win->server_win[target_local_rank]), &mpi_request); |
---|
| 38 | (*request)->mpi_request = new ::MPI_Request(mpi_request); |
---|
| 39 | |
---|
| 40 | (*request)->ep_datatype = origin_datatype; |
---|
| 41 | (*request)->type = 1; |
---|
| 42 | return return_value; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | else |
---|
| 46 | { |
---|
| 47 | int return_value = ::MPI_Raccumulate(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_op(op), to_mpi_win(win->client_win), &mpi_request); |
---|
| 49 | (*request)->mpi_request = new ::MPI_Request(mpi_request); |
---|
| 50 | |
---|
| 51 | (*request)->ep_datatype = origin_datatype; |
---|
| 52 | (*request)->type = 1; |
---|
| 53 | return return_value; |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | int MPI_Get_accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr, |
---|
| 59 | int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, |
---|
| 60 | int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win) |
---|
| 61 | { |
---|
| 62 | int target_mpi_rank = win->comm->ep_rank_map->at(target_rank).second; |
---|
| 63 | int target_local_rank = win->comm->ep_rank_map->at(target_rank).first; |
---|
| 64 | int num_ep = win->comm->ep_comm_ptr->size_rank_info[1].second; |
---|
| 65 | if(num_ep==1) |
---|
| 66 | return ::MPI_Get_accumulate(origin_addr, origin_count, to_mpi_type(origin_datatype), result_addr, result_count, to_mpi_type(result_datatype), target_mpi_rank, to_mpi_aint(target_disp), target_count, |
---|
| 67 | to_mpi_type(target_datatype), to_mpi_op(op), to_mpi_win(win->server_win[target_local_rank])); |
---|
| 68 | else |
---|
| 69 | return ::MPI_Get_accumulate(origin_addr, origin_count, to_mpi_type(origin_datatype), result_addr, result_count, to_mpi_type(result_datatype), target_mpi_rank, to_mpi_aint(target_disp), target_count, |
---|
| 70 | to_mpi_type(target_datatype), to_mpi_op(op), to_mpi_win(win->client_win)); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | int MPI_Rget_accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr, |
---|
| 74 | int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, |
---|
| 75 | int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win, MPI_Request *request) |
---|
| 76 | { |
---|
| 77 | int target_mpi_rank = win->comm->ep_rank_map->at(target_rank).second; |
---|
| 78 | int target_local_rank = win->comm->ep_rank_map->at(target_rank).first; |
---|
| 79 | int num_ep = win->comm->ep_comm_ptr->size_rank_info[1].second; |
---|
| 80 | ::MPI_Request mpi_request; |
---|
| 81 | if(num_ep==1) |
---|
| 82 | { |
---|
| 83 | int return_value = ::MPI_Rget_accumulate(origin_addr, origin_count, to_mpi_type(origin_datatype), result_addr, result_count, to_mpi_type(result_datatype), target_mpi_rank, to_mpi_aint(target_disp), target_count, |
---|
| 84 | to_mpi_type(target_datatype), to_mpi_op(op), to_mpi_win(win->server_win[target_local_rank]), &mpi_request); |
---|
| 85 | (*request)->mpi_request = new ::MPI_Request(mpi_request); |
---|
| 86 | |
---|
| 87 | (*request)->ep_datatype = origin_datatype; |
---|
| 88 | (*request)->type = 1; |
---|
| 89 | return return_value; |
---|
| 90 | } |
---|
| 91 | else |
---|
| 92 | { |
---|
| 93 | int return_value = ::MPI_Rget_accumulate(origin_addr, origin_count, to_mpi_type(origin_datatype), result_addr, result_count, to_mpi_type(result_datatype), target_mpi_rank, to_mpi_aint(target_disp), target_count, |
---|
| 94 | to_mpi_type(target_datatype), to_mpi_op(op), to_mpi_win(win->client_win), &mpi_request); |
---|
| 95 | (*request)->mpi_request = new ::MPI_Request(mpi_request); |
---|
| 96 | |
---|
| 97 | (*request)->ep_datatype = origin_datatype; |
---|
| 98 | (*request)->type = 1; |
---|
| 99 | return return_value; |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | } |
---|