#include "ep_lib.hpp" #include #include "ep_declaration.hpp" #include #include using namespace std; std::list< ep_lib::MPI_Request* > * EP_PendingRequests = 0; #pragma omp threadprivate(EP_PendingRequests) namespace ep_lib { bool ep_comm::is_null() { if(!this->is_intercomm) return this->mpi_comm == MPI_COMM_NULL->mpi_comm; else return this->ep_comm_ptr->intercomm->mpi_inter_comm == MPI_COMM_NULL->mpi_comm; } int tag_combine(int real_tag, int src, int dest) { int a = real_tag << 16; int b = src << 8; int c = dest; return a+b+c; } int get_ep_rank(MPI_Comm comm, int ep_rank_loc, int mpi_rank) { for(std::map >::iterator it = comm->ep_rank_map->begin(); it != comm->ep_rank_map->end(); it++) { if( ( it->second.first == ep_rank_loc ) && ( it->second.second == mpi_rank ) ) { return it->first; } } printf("rank not find\n"); } int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count) { ::MPI_Status *mpi_status = static_cast< ::MPI_Status* >(status->mpi_status); ::MPI_Datatype *mpi_datatype = static_cast< ::MPI_Datatype*>(datatype); ::MPI_Get_count(mpi_status, *mpi_datatype, count); } double MPI_Wtime() { return ::MPI_Wtime(); } void check_sum_send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, int type) { int src_rank; int int_count; ::MPI_Aint datasize, intsize, charsize, lb; ::MPI_Type_get_extent(*(static_cast< ::MPI_Datatype*>(datatype)), &lb, &datasize); ::MPI_Type_get_extent(*(static_cast< ::MPI_Datatype*>(MPI_CHAR)), &lb, &intsize); int_count = count * datasize / intsize ; char *buffer = static_cast< char* >(const_cast< void*> (buf)); unsigned long sum = 0; for(int i = 0; i(datatype)), &lb, &datasize); ::MPI_Type_get_extent(*(static_cast< ::MPI_Datatype*>(MPI_CHAR)), &lb, &intsize); int_count = count * datasize / intsize ; char *buffer = static_cast< char* >(buf); unsigned long sum = 0; for(int i = 0; i(type); } MPI_Op to_mpi_op(ep_lib::MPI_Op op) { return *static_cast< MPI_Op* >(op); } MPI_Comm to_mpi_comm(void* comm) { return *(static_cast< MPI_Comm* >(comm)); } MPI_Message to_mpi_message(void* message) { return *(static_cast< MPI_Message* >(message)); } MPI_Message* to_mpi_message_ptr(ep_lib::MPI_Message message) { return static_cast< MPI_Message* >(message->mpi_message); } MPI_Info to_mpi_info(ep_lib::MPI_Info info) { return *(static_cast< MPI_Info* >(info->mpi_info)); } MPI_Win to_mpi_win(void* win) { return *(static_cast< MPI_Win* >(win)); } MPI_Aint to_mpi_aint(ep_lib::MPI_Aint aint) { return *(static_cast< MPI_Aint* >(aint.mpi_aint)); } MPI_Status* to_mpi_status_ptr(ep_lib::MPI_Status status) { return static_cast< MPI_Status* >(status.mpi_status); } MPI_Request* to_mpi_request_ptr(ep_lib::MPI_Request request) { return static_cast< MPI_Request* >(request->mpi_request); }