source: XIOS/dev/branch_openmp/extern/src_ep_dev/ep_send.cpp @ 2358

Last change on this file since 2358 was 1539, checked in by yushan, 6 years ago

update intercomm_merge and remove redundant files

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