#ifdef _usingEP /*! \file ep_send.hpp \since 2 may 2016 \brief Definitions of MPI send functions: MPI_Send, MPI_Ssend, MPI_Isend, MPI_Issend */ #include "ep_lib.hpp" #include #include "ep_declaration.hpp" #include "ep_mpi.hpp" namespace ep_lib { int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) { if(comm->is_intercomm) dest = comm->inter_rank_map->at(dest); Debug("\nMPI_Send with EP\n"); int ep_src_loc = comm->ep_comm_ptr->size_rank_info[1].first; int ep_dest_loc = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).first; int mpi_tag = tag_combine(tag, ep_src_loc, ep_dest_loc); int mpi_dest = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).second; //printf("proc %d send to proc %d\n", comm->ep_comm_ptr->size_rank_info[0].first, dest); return ::MPI_Send(buf, count, to_mpi_type(datatype), mpi_dest, mpi_tag, to_mpi_comm(comm->mpi_comm)); } int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) { if(comm->is_intercomm) dest = comm->inter_rank_map->at(dest); Debug("\nMPI_Isend with EP\n"); int src_rank; MPI_Comm_rank(comm, &src_rank); *request = new ep_request; //printf("MPI_Isend : *request = new ep_request => *request = %p\n", *request); (*request)->mpi_request = new ::MPI_Request; //printf("MPI_Isend : (*request)->mpi_request = new ::MPI_Request => (*request)->mpi_request = %p\n", (*request)->mpi_request); int ep_src_loc = comm->ep_comm_ptr->size_rank_info[1].first; int ep_dest_loc = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).first; int mpi_tag = tag_combine(tag, ep_src_loc, ep_dest_loc); int mpi_dest = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).second; //printf("proc %d send to proc %d\n", comm->ep_comm_ptr->size_rank_info[0].first, dest); return ::MPI_Isend(buf, count, to_mpi_type(datatype), mpi_dest, mpi_tag, to_mpi_comm(comm->mpi_comm), to_mpi_request_ptr(*request)); } int MPI_Issend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) { if(comm->is_intercomm) dest = comm->inter_rank_map->at(dest); Debug("\nMPI_Isend with EP\n"); int src_rank; MPI_Comm_rank(comm, &src_rank); *request = new ep_request; //printf("MPI_Issend : *request = new ep_request => *request = %p\n", *request); (*request)->mpi_request = new ::MPI_Request; //printf("MPI_Issend : (*request)->mpi_request = new ::MPI_Request => (*request)->mpi_request = %p\n", (*request)->mpi_request); int ep_src_loc = comm->ep_comm_ptr->size_rank_info[1].first; int ep_dest_loc = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).first; int mpi_tag = tag_combine(tag, ep_src_loc, ep_dest_loc); int mpi_dest = comm->ep_comm_ptr->comm_list[0]->ep_rank_map->at(dest).second; //printf("proc %d send to proc %d\n", comm->ep_comm_ptr->size_rank_info[0].first, dest); return ::MPI_Issend(buf, count, to_mpi_type(datatype), mpi_dest, mpi_tag, to_mpi_comm(comm->mpi_comm), to_mpi_request_ptr(*request)); } int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status) { int mpi_dest = comm->ep_rank_map->at(dest).second; int mpi_src = comm->ep_rank_map->at(source).second; int rank_loc = comm->ep_comm_ptr->size_rank_info[1].first; int mpi_sendtag = tag_combine(sendtag, rank_loc, comm->ep_rank_map->at(dest).first); int mpi_recvtag = tag_combine(sendtag, comm->ep_rank_map->at(source).first, rank_loc); status->mpi_status = new ::MPI_Status; //printf("MPI_Sendrecv : status->mpi_status = new ::MPI_Status => status->mpi_status = %p\n", status->mpi_status); return ::MPI_Sendrecv(sendbuf, sendcount, to_mpi_type(sendtype), mpi_dest, mpi_sendtag, recvbuf, recvcount, to_mpi_type(recvtype), mpi_src, mpi_recvtag, to_mpi_comm(comm->mpi_comm), to_mpi_status_ptr(*status)); } int MPI_Send_mpi(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) { Debug("\nMPI_Send with MPI\n"); return ::MPI_Send(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm->mpi_comm)); } int MPI_Ssend_mpi(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) { Debug("\nMPI_Ssend with MPI\n"); return ::MPI_Ssend(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm->mpi_comm)); } int MPI_Isend_mpi(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) { Debug("\nMPI_Isend with MPI\n"); int src_rank; MPI_Comm_rank(comm, &src_rank); *request = new ep_request; memcheck("new "<< *request <<" : in ep_lib::MPI_Isend_mpi, *request = new ep_request"); (*request)->mpi_request = new ::MPI_Request; memcheck("new "<< (*request)->mpi_request <<" : in ep_lib::MPI_Isend_mpi, (*request)->mpi_request = new ::MPI_Request"); (*request)->ep_src = src_rank; (*request)->ep_tag = tag; (*request)->ep_datatype = datatype; (*request)->type = 1; (*request)->comm = comm; return ::MPI_Isend(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm->mpi_comm), to_mpi_request_ptr(*request)); } int MPI_Issend_mpi(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) { Debug("\nMPI_Issend with MPI\n"); int src_rank; MPI_Comm_rank(comm, &src_rank); *request = new ep_request; memcheck("new "<< *request <<" : in ep_lib::MPI_Issend_mpi, *request = new ep_request"); (*request)->mpi_request = new ::MPI_Request; memcheck("new "<< (*request)->mpi_request <<" : in ep_lib::MPI_Issend_mpi, (*request)->mpi_request = new ::MPI_Request"); (*request)->ep_src = src_rank; (*request)->ep_tag = tag; (*request)->ep_datatype = datatype; (*request)->type = 1; (*request)->comm = comm; return ::MPI_Issend(buf, count, to_mpi_type(datatype), dest, tag, to_mpi_comm(comm->mpi_comm), to_mpi_request_ptr(*request)); } } #endif