#include "ep_lib.hpp" #include #include "ep_declaration.hpp" #include #include using namespace std; namespace ep_lib { 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(int i=0; isize(); i++) { if( ( comm.rank_map->at(i).first == ep_rank_loc ) && ( comm.rank_map->at(i).second == mpi_rank ) ) { return i; } } printf("rank not find\n"); } int get_ep_rank_intercomm(MPI_Comm comm, int ep_rank_loc, int mpi_rank) { // intercomm int inter_rank; for(int i=0; iintercomm->intercomm_rank_map->size(); i++) { if( ( comm.ep_comm_ptr->intercomm->intercomm_rank_map->at(i).first == ep_rank_loc ) && ( comm.ep_comm_ptr->intercomm->intercomm_rank_map->at(i).second == mpi_rank ) ) { inter_rank = i; break; } } for(int i=0; iintercomm->remote_rank_map->size(); i++) { if( comm.ep_comm_ptr->intercomm->remote_rank_map->at(i).first == inter_rank ) { //printf("get_ep_rank for intercomm, ep_rank_loc = %d, mpi_rank = %d => ep_src = %d\n", ep_rank_loc, mpi_rank, i); return i; } } printf("rank not find\n"); } int innode_memcpy(int sender, const void* sendbuf, int receiver, void* recvbuf, int count, MPI_Datatype datatype, MPI_Comm comm) { int ep_rank, ep_rank_loc, mpi_rank; int ep_size, num_ep, mpi_size; ep_rank = comm.ep_comm_ptr->size_rank_info[0].first; ep_rank_loc = comm.ep_comm_ptr->size_rank_info[1].first; mpi_rank = comm.ep_comm_ptr->size_rank_info[2].first; ep_size = comm.ep_comm_ptr->size_rank_info[0].second; num_ep = comm.ep_comm_ptr->size_rank_info[1].second; mpi_size = comm.ep_comm_ptr->size_rank_info[2].second; if(datatype == MPI_INT) { int* send_buf = static_cast(const_cast(sendbuf)); int* recv_buf = static_cast(recvbuf); int* buffer = comm.my_buffer->buf_int; for(int j=0; j(const_cast(sendbuf)); float* recv_buf = static_cast(recvbuf); float* buffer = comm.my_buffer->buf_float; for(int j=0; j(const_cast(sendbuf)); double* recv_buf = static_cast(recvbuf); double* buffer = comm.my_buffer->buf_double; for(int j=0; j(const_cast(sendbuf)); long* recv_buf = static_cast(recvbuf); long* buffer = comm.my_buffer->buf_long; for(int j=0; j(const_cast(sendbuf)); unsigned long* recv_buf = static_cast(recvbuf); unsigned long* buffer = comm.my_buffer->buf_ulong; for(int j=0; j(const_cast(sendbuf)); char* recv_buf = static_cast(recvbuf); char* buffer = comm.my_buffer->buf_char; for(int j=0; j(datatype), &lb, &datasize); ::MPI_Type_get_extent(MPI_CHAR, &lb, &char_size); *count = status->char_count / ( datasize/ char_size); //printf("MPI_Get_count, status_count = %d\n", *count); return 0; */ ::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(MPI_CHAR_STD, &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(MPI_CHAR_STD, &lb, &intsize); int_count = count * datasize / intsize ; char *buffer = static_cast< char* >(buf); unsigned long sum = 0; for(int i = 0; i