1 | #ifdef _usingEP |
---|
2 | /*! |
---|
3 | \file ep_send.hpp |
---|
4 | \since 2 may 2016 |
---|
5 | |
---|
6 | \brief Definitions of MPI send functions: MPI_Send, MPI_Ssend, MPI_Isend, MPI_Issend |
---|
7 | */ |
---|
8 | |
---|
9 | #include "ep_lib.hpp" |
---|
10 | #include <mpi.h> |
---|
11 | #include "ep_declaration.hpp" |
---|
12 | #include "ep_mpi.hpp" |
---|
13 | |
---|
14 | |
---|
15 | namespace ep_lib |
---|
16 | { |
---|
17 | |
---|
18 | int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) |
---|
19 | { |
---|
20 | if(!comm->is_ep) return MPI_Send_mpi(buf, count, datatype, dest, tag, comm); |
---|
21 | if(comm->is_intercomm) dest = comm->inter_rank_map->at(dest); |
---|
22 | |
---|
23 | Debug("\nMPI_Send with EP\n"); |
---|
24 | |
---|
25 | int ep_src_loc = comm->ep_comm_ptr->size_rank_info[1].first; |
---|
26 | int ep_dest_loc = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).first; |
---|
27 | int mpi_tag = tag_combine(tag, ep_src_loc, ep_dest_loc); |
---|
28 | int mpi_dest = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).second; |
---|
29 | |
---|
30 | #ifdef _check_sum |
---|
31 | check_sum_send(buf, count, datatype, dest, tag, comm); |
---|
32 | #endif |
---|
33 | |
---|
34 | return ::MPI_Send(buf, count, to_mpi_type(datatype), mpi_dest, mpi_tag, to_mpi_comm(comm->mpi_comm)); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | int MPI_Ssend(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) |
---|
39 | { |
---|
40 | if(!comm->is_ep) return MPI_Ssend_mpi(buf, count, datatype, dest, tag, comm); |
---|
41 | if(comm->is_intercomm) dest = comm->inter_rank_map->at(dest); |
---|
42 | |
---|
43 | Debug("\nMPI_Ssend with EP\n"); |
---|
44 | |
---|
45 | int ep_src_loc = comm->ep_comm_ptr->size_rank_info[1].first; |
---|
46 | int ep_dest_loc = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).first; |
---|
47 | int mpi_tag = tag_combine(tag, ep_src_loc, ep_dest_loc); |
---|
48 | int mpi_dest = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).second; |
---|
49 | |
---|
50 | #ifdef _check_sum |
---|
51 | check_sum_send(buf, count, datatype, dest, tag, comm); |
---|
52 | #endif |
---|
53 | |
---|
54 | return ::MPI_Ssend(buf, count, to_mpi_type(datatype), mpi_dest, mpi_tag, to_mpi_comm(comm->mpi_comm)); |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) |
---|
62 | { |
---|
63 | if(!comm->is_ep) return MPI_Isend_mpi(buf, count, datatype, dest, tag, comm, request); |
---|
64 | if(comm->is_intercomm) dest = comm->inter_rank_map->at(dest); |
---|
65 | |
---|
66 | Debug("\nMPI_Isend with EP\n"); |
---|
67 | |
---|
68 | int src_rank; |
---|
69 | MPI_Comm_rank(comm, &src_rank); |
---|
70 | |
---|
71 | |
---|
72 | #ifdef _check_sum |
---|
73 | check_sum_send(buf, count, datatype, dest, tag, comm); |
---|
74 | #endif |
---|
75 | |
---|
76 | *request = new ep_request; |
---|
77 | memcheck("new "<< *request <<" : in ep_lib::MPI_Isend, *request = new ep_request"); |
---|
78 | |
---|
79 | (*request)->mpi_request = new ::MPI_Request; |
---|
80 | memcheck("new "<< (*request)->mpi_request <<" : in ep_lib::MPI_Isend, (*request)->mpi_request = new ::MPI_Request"); |
---|
81 | |
---|
82 | |
---|
83 | int ep_src_loc = comm->ep_comm_ptr->size_rank_info[1].first; |
---|
84 | int ep_dest_loc = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).first; |
---|
85 | int mpi_tag = tag_combine(tag, ep_src_loc, ep_dest_loc); |
---|
86 | int mpi_dest = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).second; |
---|
87 | |
---|
88 | (*request)->ep_src = src_rank; |
---|
89 | (*request)->ep_tag = tag; |
---|
90 | (*request)->ep_datatype = datatype; |
---|
91 | |
---|
92 | (*request)->type = 1; // used in wait |
---|
93 | (*request)->comm = comm; |
---|
94 | (*request)->buf = const_cast<void*>(buf); |
---|
95 | |
---|
96 | |
---|
97 | return ::MPI_Isend(buf, count, to_mpi_type(datatype), mpi_dest, mpi_tag, to_mpi_comm(comm->mpi_comm), to_mpi_request_ptr(*request)); |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | int MPI_Issend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) |
---|
104 | { |
---|
105 | |
---|
106 | if(!comm->is_ep) return MPI_Issend_mpi(buf, count, datatype, dest, tag, comm, request); |
---|
107 | if(comm->is_intercomm) dest = comm->inter_rank_map->at(dest); |
---|
108 | |
---|
109 | Debug("\nMPI_Issend with EP\n"); |
---|
110 | |
---|
111 | int src_rank; |
---|
112 | MPI_Comm_rank(comm, &src_rank); |
---|
113 | |
---|
114 | |
---|
115 | #ifdef _check_sum |
---|
116 | check_sum_send(buf, count, datatype, dest, tag, comm); |
---|
117 | #endif |
---|
118 | |
---|
119 | *request = new ep_request; |
---|
120 | memcheck("new "<< *request <<" : in ep_lib::MPI_Issend, *request = new ep_request"); |
---|
121 | |
---|
122 | (*request)->mpi_request = new ::MPI_Request; |
---|
123 | memcheck("new "<< (*request)->mpi_request <<" : in ep_lib::MPI_Issend, (*request)->mpi_request = new ::MPI_Request"); |
---|
124 | |
---|
125 | |
---|
126 | int ep_src_loc = comm->ep_comm_ptr->size_rank_info[1].first; |
---|
127 | int ep_dest_loc = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).first; |
---|
128 | int mpi_tag = tag_combine(tag, ep_src_loc, ep_dest_loc); |
---|
129 | int mpi_dest = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).second; |
---|
130 | |
---|
131 | (*request)->ep_src = src_rank; |
---|
132 | (*request)->ep_tag = tag; |
---|
133 | (*request)->ep_datatype = datatype; |
---|
134 | |
---|
135 | (*request)->type = 1; // used in wait |
---|
136 | (*request)->comm = comm; |
---|
137 | (*request)->buf = const_cast<void*>(buf); |
---|
138 | |
---|
139 | return ::MPI_Issend(buf, count, to_mpi_type(datatype), mpi_dest, mpi_tag, to_mpi_comm(comm->mpi_comm), to_mpi_request_ptr(*request)); |
---|
140 | } |
---|
141 | |
---|
142 | int MPI_Send_mpi(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) |
---|
143 | { |
---|
144 | Debug("\nMPI_Send with MPI\n"); |
---|
145 | return ::MPI_Send(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm->mpi_comm)); |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | int MPI_Ssend_mpi(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) |
---|
150 | { |
---|
151 | Debug("\nMPI_Ssend with MPI\n"); |
---|
152 | return ::MPI_Ssend(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm->mpi_comm)); |
---|
153 | } |
---|
154 | |
---|
155 | |
---|
156 | int MPI_Isend_mpi(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) |
---|
157 | { |
---|
158 | Debug("\nMPI_Isend with MPI\n"); |
---|
159 | |
---|
160 | int src_rank; |
---|
161 | MPI_Comm_rank(comm, &src_rank); |
---|
162 | |
---|
163 | *request = new ep_request; |
---|
164 | memcheck("new "<< *request <<" : in ep_lib::MPI_Isend_mpi, *request = new ep_request"); |
---|
165 | |
---|
166 | (*request)->mpi_request = new ::MPI_Request; |
---|
167 | memcheck("new "<< (*request)->mpi_request <<" : in ep_lib::MPI_Isend_mpi, (*request)->mpi_request = new ::MPI_Request"); |
---|
168 | |
---|
169 | (*request)->ep_src = src_rank; |
---|
170 | (*request)->ep_tag = tag; |
---|
171 | (*request)->ep_datatype = datatype; |
---|
172 | (*request)->type = 1; |
---|
173 | (*request)->comm = comm; |
---|
174 | |
---|
175 | return ::MPI_Isend(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm->mpi_comm), to_mpi_request_ptr(*request)); |
---|
176 | } |
---|
177 | |
---|
178 | |
---|
179 | |
---|
180 | |
---|
181 | int MPI_Issend_mpi(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) |
---|
182 | { |
---|
183 | Debug("\nMPI_Issend with MPI\n"); |
---|
184 | |
---|
185 | int src_rank; |
---|
186 | MPI_Comm_rank(comm, &src_rank); |
---|
187 | |
---|
188 | *request = new ep_request; |
---|
189 | memcheck("new "<< *request <<" : in ep_lib::MPI_Issend_mpi, *request = new ep_request"); |
---|
190 | |
---|
191 | (*request)->mpi_request = new ::MPI_Request; |
---|
192 | memcheck("new "<< (*request)->mpi_request <<" : in ep_lib::MPI_Issend_mpi, (*request)->mpi_request = new ::MPI_Request"); |
---|
193 | |
---|
194 | (*request)->ep_src = src_rank; |
---|
195 | (*request)->ep_tag = tag; |
---|
196 | (*request)->ep_datatype = datatype; |
---|
197 | (*request)->type = 1; |
---|
198 | (*request)->comm = comm; |
---|
199 | |
---|
200 | return ::MPI_Issend(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm->mpi_comm), to_mpi_request_ptr(*request)); |
---|
201 | } |
---|
202 | |
---|
203 | |
---|
204 | } |
---|
205 | #endif |
---|
206 | |
---|
207 | |
---|
208 | |
---|
209 | |
---|
210 | |
---|