Ignore:
Timestamp:
04/12/17 11:55:38 (7 years ago)
Author:
yushan
Message:

save modif from local. context_init/finalize OK

Location:
XIOS/dev/branch_yushan/extern/src_ep_dev
Files:
2 edited

Legend:

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

    r1085 r1087  
    2525    std::map<std::pair<int, int>, MPI_Comm > ::iterator it; 
    2626     
    27     it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num())); 
    28     if(it == fc_comm_map.end()) 
     27    #pragma omp critical (fc_comm_map) 
    2928    { 
    30       fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm)); 
    31       printf("EP_Comm_c2f : MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), comm.ep_comm_ptr); 
     29      it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num())); 
     30      if(it == fc_comm_map.end()) 
     31      { 
     32        fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm)); 
     33        printf("EP_Comm_c2f : MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), comm.ep_comm_ptr); 
     34      } 
    3235    } 
    3336     
     
    4447    std::map<std::pair<int, int>, MPI_Comm > ::iterator it; 
    4548     
     49    #pragma omp critical (fc_comm_map) 
    4650    it = fc_comm_map.find(std::make_pair(comm, omp_get_thread_num())); 
     51     
    4752    if(it != fc_comm_map.end()) 
    4853    { 
     
    5257      return  comm_ptr; 
    5358    } 
    54     else 
    55     {       
     59        
    5660       
    57       #ifdef _openmpi 
    58       ::MPI_Comm base_comm = ::MPI_Comm_f2c(comm); 
    59       #elif _intelmpi 
    60       ::MPI_Comm base_comm = (::MPI_Comm)(comm); 
    61       #endif 
     61    #ifdef _openmpi 
     62    ::MPI_Comm base_comm = ::MPI_Comm_f2c(comm); 
     63    #elif _intelmpi 
     64    ::MPI_Comm base_comm = (::MPI_Comm)(comm); 
     65    #endif 
    6266 
    63       if(base_comm != MPI_COMM_NULL_STD) 
     67    if(base_comm != MPI_COMM_NULL_STD) 
     68    { 
     69      if(omp_get_thread_num() == 0) 
    6470      { 
    65         if(omp_get_thread_num() == 0) 
    66         { 
    67           int num_ep = omp_get_num_threads(); 
    68           MPI_Comm *new_comm; 
    69           MPI_Info info; 
    70           MPI_Comm_create_endpoints(base_comm, num_ep, info, new_comm); 
    71           passage = new_comm; 
    72         } 
    73         #pragma omp barrier 
     71        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; 
     76      } 
     77      #pragma omp barrier 
    7478 
    75         MPI_Comm return_comm = passage[omp_get_thread_num()]; 
    76         return return_comm; 
     79      MPI_Comm return_comm = passage[omp_get_thread_num()]; 
     80      return return_comm; 
    7781         
    78       } 
    79       return MPI_COMM_NULL; 
    80        
    8182    } 
     83    return MPI_COMM_NULL; 
     84 
    8285  } 
    83  
    84   // #ifdef _intelmpi 
    85  
    86   // MPI_Fint MPI_Comm_c2f(MPI_Comm comm) 
    87   // { 
    88   //   Debug("MPI_Comm_c2f"); 
    89   //   int fint; 
    90   //   fint = (::MPI_Fint)(comm.mpi_comm); 
    91      
    92   //   std::map<std::pair<int, int>, MPI_Comm  > ::iterator it; 
    93      
    94   //   it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num())); 
    95   //   if(it == fc_comm_map.end()) 
    96   //   { 
    97   //     fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm)); 
    98   //     printf("MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), &comm); 
    99   //   } 
    100      
    101   //   MPI_Fint Fint; 
    102   //   Fint.mpi_fint = fint; 
    103   //   return Fint; 
    104      
    105   // } 
    106  
    107    
    108  
    109  
    110   // MPI_Comm MPI_Comm_f2c(MPI_Fint comm) 
    111   // { 
    112   //   Debug("MPI_Comm_f2c"); 
    113      
    114      
    115   //   std::map<std::pair<int, int>, MPI_Comm  > ::iterator it; 
    116      
    117   //   it = fc_comm_map.find(std::make_pair(comm.mpi_fint, omp_get_thread_num())); 
    118   //   if(it != fc_comm_map.end()) 
    119   //   { 
    120   //     MPI_Comm comm_ptr; 
    121   //     comm_ptr =  it->second; 
    122   //     printf("MAP find: %d, %d, %p\n", it->first.first, it->first.second, &comm_ptr); 
    123   //     return  comm_ptr; 
    124   //   } 
    125   //   else 
    126   //   {       
    127   //     MPI_Comm return_comm; 
    128   //     return_comm.mpi_comm = (::MPI_Comm)(comm.mpi_fint); 
    129   //     return return_comm; 
    130   //   } 
    131   // } 
    132  
    133    
    134  
    135   // #elif _openmpi 
    136    
    137   // int MPI_Comm_c2f(MPI_Comm comm) 
    138   // { 
    139   //   Debug("MPI_Comm_c2f"); 
    140   //   int fint; 
    141   //   fint = ::MPI_Comm_c2f(static_cast< ::MPI_Comm>(comm.mpi_comm)); 
    142      
    143   //   std::map<std::pair<int, int>, MPI_Comm > ::iterator it; 
    144      
    145   //   it = fc_comm_map.find(std::make_pair(fint, omp_get_thread_num())); 
    146   //   if(it == fc_comm_map.end()) 
    147   //   { 
    148   //     fc_comm_map.insert(std::make_pair( std::make_pair( fint, omp_get_thread_num()) , comm)); 
    149   //     printf("MAP insert: %d, %d, %p\n", fint, omp_get_thread_num(), &comm); 
    150   //   } 
    151      
    152   //   return fint; 
    153      
    154   // } 
    155  
    156   // ep_lib::MPI_Comm MPI_Comm_f2c(MPI_Fint comm) 
    157   // { 
    158   //   Debug("MPI_Comm_f2c"); 
    159      
    160      
    161   //   std::map<std::pair<int, int>, MPI_Comm > ::iterator it; 
    162      
    163   //   it = fc_comm_map.find(std::make_pair(comm, omp_get_thread_num())); 
    164   //   if(it != fc_comm_map.end()) 
    165   //   { 
    166   //     MPI_Comm comm_ptr; 
    167   //     comm_ptr =  it->second; 
    168   //     printf("MAP find: %d, %d, %p\n", it->first.first, it->first.second, &comm_ptr); 
    169   //     return  comm_ptr; 
    170   //   } 
    171   //   else 
    172   //   {       
    173   //     MPI_Comm return_comm; 
    174   //     return_comm.mpi_comm = (::MPI_Comm)(comm); 
    175   //     return return_comm; 
    176   //   } 
    177   // } 
    178   // #endif 
    17986 
    18087} 
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_type.hpp

    r1081 r1087  
    485485 
    486486  static std::map<std::pair<int, int>, MPI_Comm >  fc_comm_map; 
     487 
     488  static std::map<std::pair<int, int>, MPI_Comm >  *fc_comm_map_ptr; 
     489  #pragma omp threadprivate(fc_comm_map_ptr) 
    487490            //    <MPI_Fint,thread_num>   EP_Comm 
    488491 
Note: See TracChangeset for help on using the changeset viewer.