Ignore:
Timestamp:
06/04/18 19:25:08 (6 years ago)
Author:
yushan
Message:

save dev. TO DO : test with xios

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/src_ep_dev/ep_lib.cpp

    r1495 r1520  
    44#include <iostream> 
    55#include <fstream> 
     6#include "ep_mpi.hpp" 
    67 
    78using namespace std; 
     
    1415namespace ep_lib 
    1516{  
    16   bool MPI_Comm::is_null() 
    17   { 
    18     if(!this->is_intercomm) 
    19       return this->mpi_comm == MPI_COMM_NULL.mpi_comm; 
    20     else 
    21       return this->ep_comm_ptr->intercomm->mpi_inter_comm == MPI_COMM_NULL.mpi_comm; 
    22   } 
    2317 
    2418  int tag_combine(int real_tag, int src, int dest) 
     
    3327  int get_ep_rank(MPI_Comm comm, int ep_rank_loc, int mpi_rank) 
    3428  { 
    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); 
    4455  } 
    4556   
    46   int get_ep_rank_intercomm(MPI_Comm comm, int ep_rank_loc, int mpi_rank) 
    47   { 
    48     // intercomm 
    49     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  
    7357 
    7458  int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count) 
    7559  { 
    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); 
    8161  } 
    8262 
     
    8969  void check_sum_send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, int type) 
    9070  { 
     71 
    9172    int src_rank; 
    9273    int int_count; 
     
    121102  void check_sum_recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, int type) 
    122103  { 
     104 
    123105    int dest_rank; 
    124106    int int_count; 
     
    147129    } 
    148130    else printf("Unable to open file\n"); 
     131 
    149132 
    150133  } 
     
    251234{ 
    252235  return *(static_cast< MPI_Comm* >(comm)); 
     236}  
     237 
     238MPI_Comm* to_mpi_comm_ptr(void* comm) 
     239{ 
     240  return static_cast< MPI_Comm* >(comm); 
    253241 
    254242 
     
    258246} 
    259247 
    260 MPI_Info to_mpi_info(void* info) 
    261 { 
    262   return *(static_cast< MPI_Info* >(info)); 
    263 } 
    264  
    265  
    266  
    267  
    268  
     248MPI_Message* to_mpi_message_ptr(ep_lib::MPI_Message message) 
     249{ 
     250  return static_cast< MPI_Message* >(message->mpi_message); 
     251} 
     252 
     253MPI_Info to_mpi_info(ep_lib::MPI_Info info) 
     254{ 
     255  return *(static_cast< MPI_Info* >(info->mpi_info)); 
     256} 
     257 
     258MPI_Win to_mpi_win(void* win) 
     259{ 
     260  return *(static_cast< MPI_Win* >(win)); 
     261} 
     262 
     263MPI_Aint to_mpi_aint(ep_lib::MPI_Aint aint) 
     264{ 
     265  return *(static_cast< MPI_Aint* >(aint.mpi_aint)); 
     266} 
     267 
     268MPI_Status* to_mpi_status_ptr(ep_lib::MPI_Status status) 
     269{ 
     270  return static_cast< MPI_Status* >(status.mpi_status); 
     271} 
     272 
     273MPI_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.