Ignore:
Timestamp:
03/14/17 19:12:25 (7 years ago)
Author:
yushan
Message:

Using threads : modif for xios_initialize

Location:
XIOS/dev/branch_yushan/extern
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan/extern/remap/src/clipper.cpp

    r919 r1072  
    5252 
    5353static double const pi = 3.141592653589793238; 
     54#pragma omp threadprivate(pi) 
     55 
    5456static double const two_pi = pi *2; 
     57#pragma omp threadprivate(two_pi) 
     58 
    5559static double const def_arc_tolerance = 0.25; 
     60#pragma omp threadprivate(def_arc_tolerance) 
    5661 
    5762enum Direction { dRightToLeft, dLeftToRight }; 
    5863 
    5964static int const Unassigned = -1;  //edge not currently 'owning' a solution 
     65#pragma omp threadprivate(Unassigned) 
     66 
    6067static int const Skip = -2;        //edge that would otherwise close a path 
     68#pragma omp threadprivate(Skip) 
    6169 
    6270#define HORIZONTAL (-1.0E+40) 
  • XIOS/dev/branch_yushan/extern/remap/src/clipper.hpp

    r688 r1072  
    7373  typedef int cInt; 
    7474  static cInt const loRange = 0x7FFF; 
     75  #pragma omp threadprivate(loRange) 
     76 
    7577  static cInt const hiRange = 0x7FFF; 
     78  #pragma omp threadprivate(hiRange) 
     79 
    7680#else 
    7781  typedef signed long long cInt; 
    7882  static cInt const loRange = 0x3FFFFFFF; 
     83  #pragma omp threadprivate(loRange) 
     84 
    7985  static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL; 
     86  #pragma omp threadprivate(hiRange) 
     87   
    8088  typedef signed long long long64;     //used by Int128 class 
    8189  typedef unsigned long long ulong64; 
  • XIOS/dev/branch_yushan/extern/remap/src/inside.cpp

    r688 r1072  
    1111 
    1212static const double SNAP = 1e-11; 
     13#pragma omp threadprivate(SNAP) 
    1314 
    1415using namespace std; 
  • XIOS/dev/branch_yushan/extern/remap/src/parallel_tree.cpp

    r923 r1072  
    1616 
    1717static const int assignLevel = 2; 
     18#pragma omp threadprivate(assignLevel) 
    1819 
    1920// only the circle is packed, rest of node will be initialized on unpacking 
  • XIOS/dev/branch_yushan/extern/remap/src/timerRemap.hpp

    r694 r1072  
    2727    void print(void); 
    2828    static map<string,CTimer*> allTimer; 
     29    //#pragma omp threadprivate(allTimer) 
     30 
    2931    static double getTime(void); 
    3032    static CTimer& get(string name); 
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_fortran.cpp

    r1069 r1072  
    1919    fint = ::MPI_Comm_c2f(static_cast< ::MPI_Comm>(comm.mpi_comm)); 
    2020    #endif 
     21     
    2122    std::map<std::pair<int, int>, MPI_Comm > ::iterator it; 
    2223     
     
    5051    else 
    5152    {       
    52       MPI_Comm return_comm; 
    53       if(omp_get_thread_num() == 0) 
     53       
     54      #ifdef _openmpi 
     55      ::MPI_Comm base_comm = ::MPI_Comm_f2c(comm); 
     56      #elif _intelmpi 
     57      ::MPI_Comm base_comm = (::MPI_Comm)(comm); 
     58      #endif 
     59 
     60      if(base_comm != MPI_COMM_NULL_STD) 
    5461      { 
    55         #ifdef _openmpi 
    56         ::MPI_Comm base_comm = ::MPI_Comm_f2c(comm); 
    57         #elif _intelmpi 
    58         ::MPI_Comm base_comm = (::MPI_Comm)(comm); 
    59         #endif 
    60  
    61         if(base_comm != MPI_COMM_NULL_STD) 
     62        if(omp_get_thread_num() == 0) 
    6263        { 
    6364          int num_ep = omp_get_num_threads(); 
     
    6566          MPI_Info info; 
    6667          MPI_Comm_create_endpoints(base_comm, num_ep, info, new_comm); 
    67           return_comm = new_comm[omp_get_thread_num()]; 
     68          passage = new_comm; 
    6869        } 
    69         return MPI_COMM_NULL; 
     70        #pragma omp barrier 
     71 
     72        MPI_Comm return_comm = passage[omp_get_thread_num()]; 
     73        return return_comm; 
     74         
    7075      } 
     76      return MPI_COMM_NULL; 
    7177       
    72        
    73       return return_comm; 
    7478    } 
    7579  } 
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_kernel.cpp

    r1068 r1072  
    420420            *newintercomm =  iter->second[my_position]; 
    421421            found = true; 
    422             tag_list.erase(iter); 
    423422            break; 
    424423          } 
     
    428427 
    429428    MPI_Barrier_local(local_comm); 
    430     // if(is_proc_master) 
    431     // { 
    432     //   for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++) 
    433     //   { 
    434     //     if((*iter).first == make_pair(tag, min(leader_info[0], leader_info[1]))) 
    435     //     { 
    436     //       tag_list.erase(iter); 
    437     //       break; 
    438     //     } 
    439     //   } 
    440     // } 
     429    if(is_proc_master) 
     430    { 
     431      for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++) 
     432      { 
     433        if((*iter).first == make_pair(tag, min(leader_info[0], leader_info[1]))) 
     434        { 
     435          tag_list.erase(iter); 
     436          break; 
     437        } 
     438      } 
     439    } 
    441440 
    442441    int intercomm_ep_rank, intercomm_ep_rank_loc, intercomm_mpi_rank; 
     
    687686            *newintercomm =  iter->second[my_position]; 
    688687            found = true; 
     688            // tag_list.erase(iter); 
     689            break; 
     690          } 
     691        } 
     692      } 
     693    } 
     694 
     695    MPI_Barrier_local(local_comm); 
     696 
     697    if(leader_rank_in_peer[0] < leader_rank_in_peer[1]) 
     698    { 
     699      for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++) 
     700        { 
     701          if((*iter).first == make_pair(tag_label[0], tag_label[1])) 
     702          { 
    689703            tag_list.erase(iter); 
    690704            break; 
    691705          } 
    692706        } 
    693       } 
    694     } 
    695  
    696     // if(leader_rank_in_peer[0] < leader_rank_in_peer[1]) 
    697     // { 
    698     //   for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++) 
    699     //     { 
    700     //       if((*iter).first == make_pair(tag_label[0], tag_label[1])) 
    701     //       { 
    702     //         tag_list.erase(iter); 
    703     //       } 
    704     //     } 
    705     // } 
     707    } 
    706708 
    707709 
  • XIOS/dev/branch_yushan/extern/src_ep_dev/ep_intercomm_world.cpp

    r1067 r1072  
    417417 
    418418            found = true; 
    419             tag_list.erase(iter); 
     419            //tag_list.erase(iter); 
    420420            break; 
    421421          } 
     
    426426    MPI_Barrier_local(local_comm); 
    427427 
    428     // if(is_proc_master) 
    429     // { 
    430     //   for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++) 
    431     //   { 
    432     //     if((*iter).first == make_pair(tag, min(leader_info[0], leader_info[1]))) 
    433     //     { 
    434     //       tag_list.erase(iter); 
    435     //     } 
    436     //   } 
    437     // } 
     428    if(is_proc_master) 
     429    { 
     430      for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++) 
     431      { 
     432        if((*iter).first == make_pair(tag, min(leader_info[0], leader_info[1]))) 
     433        { 
     434          tag_list.erase(iter); 
     435          break; 
     436        } 
     437      } 
     438    } 
    438439 
    439440     
     
    934935 
    935936            found = true; 
    936             tag_list.erase(iter); 
     937            //tag_list.erase(iter); 
    937938            break; 
    938939          } 
     
    943944    MPI_Barrier_local(local_comm); 
    944945 
    945     // if(is_proc_master) 
    946     // { 
    947     //   for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++) 
    948     //   { 
    949     //     if((*iter).first == make_pair(tag, min(leader_info[0], leader_info[1]))) 
    950     //     { 
    951     //       tag_list.erase(iter); 
    952     //     } 
    953     //   } 
    954     // } 
     946    if(is_proc_master) 
     947    { 
     948      for(std::list<std::pair < std::pair<int,int>, MPI_Comm* > >::iterator iter = tag_list.begin(); iter!=tag_list.end(); iter++) 
     949      { 
     950        if((*iter).first == make_pair(tag, min(leader_info[0], leader_info[1]))) 
     951        { 
     952          tag_list.erase(iter); 
     953          break; 
     954        } 
     955      } 
     956    } 
    955957 
    956958    int intercomm_ep_rank, intercomm_ep_rank_loc, intercomm_mpi_rank; 
Note: See TracChangeset for help on using the changeset viewer.