Changeset 1520 for XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.cpp
- Timestamp:
- 06/04/18 19:25:08 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.cpp
r1495 r1520 4 4 #include <iostream> 5 5 #include <fstream> 6 #include "ep_mpi.hpp" 6 7 7 8 using namespace std; … … 14 15 namespace ep_lib 15 16 { 16 bool MPI_Comm::is_null()17 {18 if(!this->is_intercomm)19 return this->mpi_comm == MPI_COMM_NULL.mpi_comm;20 else21 return this->ep_comm_ptr->intercomm->mpi_inter_comm == MPI_COMM_NULL.mpi_comm;22 }23 17 24 18 int tag_combine(int real_tag, int src, int dest) … … 33 27 int get_ep_rank(MPI_Comm comm, int ep_rank_loc, int mpi_rank) 34 28 { 35 for(int i=0; i<comm.rank_map->size(); i++) 36 { 37 if( ( comm.rank_map->at(i).first == ep_rank_loc ) 38 && ( comm.rank_map->at(i).second == mpi_rank ) ) 39 { 40 return i; 41 } 42 } 43 printf("rank not find\n"); 29 if(comm->is_intercomm) 30 { 31 for(std::map<int, std::pair< int, std::pair<int, int> > >::iterator it = comm->ep_comm_ptr->intercomm->intercomm_rank_map->begin(); it != comm->ep_comm_ptr->intercomm->intercomm_rank_map->end(); it++) 32 { 33 if( ( it->second.first == ep_rank_loc ) 34 && ( it->second.second.first == mpi_rank ) ) 35 { 36 return it->first; 37 } 38 } 39 printf("rank not find for EP_intercomm\n"); 40 int err; 41 return MPI_Abort(comm, err); 42 } 43 44 for(std::map<int, std::pair<int, int> >::iterator it = comm->ep_rank_map->begin(); it != comm->ep_rank_map->end(); it++) 45 { 46 if( ( it->second.first == ep_rank_loc ) 47 && ( it->second.second == mpi_rank ) ) 48 { 49 return it->first; 50 } 51 } 52 printf("rank not find for EP_intracomm\n"); 53 int err; 54 return MPI_Abort(comm, err); 44 55 } 45 56 46 int get_ep_rank_intercomm(MPI_Comm comm, int ep_rank_loc, int mpi_rank)47 {48 // intercomm49 int inter_rank;50 for(int i=0; i<comm.ep_comm_ptr->intercomm->intercomm_rank_map->size(); i++)51 {52 if( ( comm.ep_comm_ptr->intercomm->intercomm_rank_map->at(i).first == ep_rank_loc )53 && ( comm.ep_comm_ptr->intercomm->intercomm_rank_map->at(i).second == mpi_rank ) )54 {55 inter_rank = i;56 break;57 }58 }59 60 for(int i=0; i<comm.ep_comm_ptr->intercomm->remote_rank_map->size(); i++)61 {62 if( comm.ep_comm_ptr->intercomm->remote_rank_map->at(i).first == inter_rank )63 {64 //printf("get_ep_rank for intercomm, ep_rank_loc = %d, mpi_rank = %d => ep_src = %d\n", ep_rank_loc, mpi_rank, i);65 return i;66 }67 }68 69 printf("rank not find\n");70 71 }72 73 57 74 58 int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count) 75 59 { 76 77 ::MPI_Status *mpi_status = static_cast< ::MPI_Status* >(status->mpi_status); 78 ::MPI_Datatype *mpi_datatype = static_cast< ::MPI_Datatype*>(datatype); 79 80 ::MPI_Get_count(mpi_status, *mpi_datatype, count); 60 return ::MPI_Get_count(to_mpi_status_ptr(*status), to_mpi_type(datatype), count); 81 61 } 82 62 … … 89 69 void check_sum_send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, int type) 90 70 { 71 91 72 int src_rank; 92 73 int int_count; … … 121 102 void check_sum_recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, int type) 122 103 { 104 123 105 int dest_rank; 124 106 int int_count; … … 147 129 } 148 130 else printf("Unable to open file\n"); 131 149 132 150 133 } … … 251 234 { 252 235 return *(static_cast< MPI_Comm* >(comm)); 236 } 237 238 MPI_Comm* to_mpi_comm_ptr(void* comm) 239 { 240 return static_cast< MPI_Comm* >(comm); 253 241 } 254 242 … … 258 246 } 259 247 260 MPI_Info to_mpi_info(void* info) 261 { 262 return *(static_cast< MPI_Info* >(info)); 263 } 264 265 266 267 268 248 MPI_Message* to_mpi_message_ptr(ep_lib::MPI_Message message) 249 { 250 return static_cast< MPI_Message* >(message->mpi_message); 251 } 252 253 MPI_Info to_mpi_info(ep_lib::MPI_Info info) 254 { 255 return *(static_cast< MPI_Info* >(info->mpi_info)); 256 } 257 258 MPI_Win to_mpi_win(void* win) 259 { 260 return *(static_cast< MPI_Win* >(win)); 261 } 262 263 MPI_Aint to_mpi_aint(ep_lib::MPI_Aint aint) 264 { 265 return *(static_cast< MPI_Aint* >(aint.mpi_aint)); 266 } 267 268 MPI_Status* to_mpi_status_ptr(ep_lib::MPI_Status status) 269 { 270 return static_cast< MPI_Status* >(status.mpi_status); 271 } 272 273 MPI_Request* to_mpi_request_ptr(ep_lib::MPI_Request request) 274 { 275 return static_cast< MPI_Request* >(request->mpi_request); 276 } 277 278 279
Note: See TracChangeset
for help on using the changeset viewer.