Ignore:
Timestamp:
01/23/19 10:31:44 (5 years ago)
Author:
yushan
Message:

dev on ADA. add flag switch _usingEP/_usingMPI

File:
1 edited

Legend:

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

    r1520 r1642  
    88 
    99 
    10 namespace ep_lib 
    11 { 
     10//namespace ep_lib 
     11//{ 
    1212 
    13   void* EP_Comm_c2f(MPI_Comm comm) 
     13  void* EP_Comm_c2f(ep_lib::MPI_Comm comm) 
    1414  { 
    1515    Debug("MPI_Comm_c2f"); 
    16     void* fint = new ::MPI_Fint; 
     16    void* fint = new MPI_Fint; 
    1717    #ifdef _intelmpi 
    18     *static_cast< ::MPI_Fint*>(fint) = (::MPI_Fint)(to_mpi_comm(comm->mpi_comm)); 
     18    //*static_cast< ::MPI_Fint*>(fint) = (::MPI_Fint)(to_mpi_comm(comm->mpi_comm)); 
     19    *static_cast< MPI_Fint*>(fint) = MPI_Comm_c2f(to_mpi_comm(comm->mpi_comm)); 
    1920    #elif _openmpi 
    20     *static_cast< ::MPI_Fint*>(fint) = MPI_Comm_c2f(to_mpi_comm(comm->mpi_comm)); 
     21    *static_cast< MPI_Fint*>(fint) = MPI_Comm_c2f(to_mpi_comm(comm->mpi_comm)); 
    2122    #endif 
    2223     
    23     std::map<std::pair< ::MPI_Fint, int>, MPI_Comm > ::iterator it; 
     24    std::map<std::pair< MPI_Fint, int>, ep_lib::MPI_Comm > ::iterator it; 
    2425     
    2526    #pragma omp critical (fc_comm_map) 
    2627    { 
    27       it = fc_comm_map.find(std::make_pair(*static_cast< ::MPI_Fint*>(fint), omp_get_thread_num())); 
    28       if(it == fc_comm_map.end()) 
     28      it = ep_lib::fc_comm_map.find(std::make_pair(*static_cast< MPI_Fint*>(fint), omp_get_thread_num())); 
     29      if(it == ep_lib::fc_comm_map.end()) 
    2930      { 
    30         fc_comm_map.insert(std::make_pair( std::make_pair( *static_cast< ::MPI_Fint*>(fint), omp_get_thread_num()) , comm)); 
    31         printf("EP_Comm_c2f : MAP %p insert: %d, %d, %p\n", &fc_comm_map, *static_cast< ::MPI_Fint*>(fint), omp_get_thread_num(), comm->ep_comm_ptr); 
     31        ep_lib::fc_comm_map.insert(std::make_pair( std::make_pair( *static_cast< MPI_Fint*>(fint), omp_get_thread_num()) , comm)); 
     32        printf("EP_Comm_c2f : MAP %p insert: %d, %d, %p\n", &(ep_lib::fc_comm_map), *static_cast< MPI_Fint*>(fint), omp_get_thread_num(), comm->ep_comm_ptr); 
    3233      } 
    3334    } 
     
    3839  } 
    3940 
    40   MPI_Comm EP_Comm_f2c(void* comm) 
     41  ep_lib::MPI_Comm EP_Comm_f2c(void* comm) 
    4142  { 
    4243    Debug("MPI_Comm_f2c"); 
    4344     
    4445     
    45     std::map<std::pair< ::MPI_Fint, int>, MPI_Comm > ::iterator it; 
     46    std::map<std::pair< MPI_Fint, int>, ep_lib::MPI_Comm > ::iterator it; 
    4647     
    4748    #pragma omp critical (fc_comm_map) 
    48     it = fc_comm_map.find(std::make_pair(*static_cast< ::MPI_Fint*>(comm), omp_get_thread_num())); 
     49    it = ep_lib::fc_comm_map.find(std::make_pair(*static_cast< MPI_Fint*>(comm), omp_get_thread_num())); 
    4950     
    50     if(it != fc_comm_map.end()) 
     51    if(it != ep_lib::fc_comm_map.end()) 
    5152    { 
    52       MPI_Comm comm_ptr; 
     53      ep_lib::MPI_Comm comm_ptr; 
    5354      comm_ptr = it->second; 
    54       printf("EP_Comm_f2c : MAP %p find: %d, %d, %p\n", &fc_comm_map, it->first.first, it->first.second, comm_ptr->ep_comm_ptr); 
     55      printf("EP_Comm_f2c : MAP %p find: %d, %d, %p\n", &(ep_lib::fc_comm_map), it->first.first, it->first.second, comm_ptr->ep_comm_ptr); 
    5556      return  comm_ptr; 
    5657    } 
     
    5859       
    5960     
     61    MPI_Comm *base_comm = new MPI_Comm; 
    6062    #ifdef _intelmpi 
    61     ::MPI_Comm *base_comm = new ::MPI_Comm; 
    62     *base_comm = (::MPI_Comm)(*static_cast< ::MPI_Fint*>(comm)); 
     63    *base_comm = (MPI_Comm)(*static_cast< MPI_Fint*>(comm)); 
    6364    #elif _openmpi 
    64     ::MPI_Comm *base_comm = ::MPI_Comm_f2c(*static_cast< ::MPI_Fint*>(comm)); 
     65    *base_comm = MPI_Comm_f2c(*static_cast< MPI_Fint*>(comm)); 
    6566    #endif 
    6667 
    67     if(*base_comm != to_mpi_comm(MPI_COMM_NULL->mpi_comm)) 
     68    if(*base_comm != to_mpi_comm(EP_COMM_NULL->mpi_comm)) 
    6869    { 
    6970      if(omp_get_thread_num() == 0) 
    7071      { 
    7172        int num_ep = omp_get_num_threads(); 
    72         MPI_Comm *new_comm; 
    73         MPI_Info info; 
    74         MPI_Comm_create_endpoints(base_comm, num_ep, info, new_comm); 
    75         passage = new_comm; 
     73        ep_lib::MPI_Comm *new_comm; 
     74        ep_lib::MPI_Info info; 
     75        ep_lib::MPI_Comm_create_endpoints(base_comm, num_ep, info, new_comm); 
     76        ep_lib::passage = new_comm; 
    7677      } 
    7778      #pragma omp barrier 
    7879 
    79       MPI_Comm return_comm = passage[omp_get_thread_num()]; 
     80      ep_lib::MPI_Comm return_comm = ep_lib::passage[omp_get_thread_num()]; 
    8081      return return_comm; 
    8182         
    8283    } 
    83     return MPI_COMM_NULL; 
     84    return EP_COMM_NULL; 
    8485 
    8586  } 
    8687 
    87 } 
     88//} 
    8889 
    8990 
Note: See TracChangeset for help on using the changeset viewer.