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

Using threads : modif for xios_initialize

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan/src/cxios.cpp

    r1070 r1072  
    2222  bool CXios::isServer ; 
    2323  MPI_Comm CXios::globalComm ; 
     24  // #pragma omp threadprivate(CXios::globalComm) 
     25 
    2426  bool CXios::usingOasis ; 
    2527  bool CXios::usingServer = false; 
     
    3537  {     
    3638    set_new_handler(noMemory); 
    37     parseFile(rootFile); 
     39    //#pragma omp critical(_output) 
     40    #pragma omp master 
     41    { 
     42      parseFile(rootFile);   
     43    } 
    3844    parseXiosConfig(); 
    3945  } 
     
    4551  void CXios::parseXiosConfig() 
    4652  { 
     53 
    4754    usingOasis=getin<bool>("using_oasis",false) ; 
    4855    usingServer=getin<bool>("using_server",false) ; 
     
    6370    bufferSizeFactor = getin<double>("buffer_size_factor", defaultBufferSizeFactor); 
    6471    minBufferSize = getin<int>("min_buffer_size", 1024 * sizeof(double)); 
    65  
     72  
    6673    int num_ep; 
    67     if(isClient)  
     74    if(isClient)   
    6875    {  
    69       num_ep = 1; 
     76      num_ep = omp_get_num_threads(); 
     77      printf("Client %d: num_ep = %d\n", omp_get_thread_num(), num_ep); 
    7078    } 
    7179     
    7280    if(isServer)  
    7381    {  
    74       num_ep = 1;  
     82      num_ep = omp_get_num_threads(); 
     83      printf("Server %d: num_ep = %d\n", omp_get_thread_num(), num_ep);  
    7584    } 
    7685     
    7786    MPI_Info info; 
    78     MPI_Comm *ep_comm; 
    79     if(omp_get_thread_num()==0) 
    80     { 
     87    #pragma omp master 
     88    { 
     89      MPI_Comm *ep_comm; 
    8190      MPI_Comm_create_endpoints(MPI_COMM_WORLD, num_ep, info, ep_comm);  // servers should reach here too. 
    8291      passage = ep_comm;   
     
    8695       
    8796    globalComm = passage[omp_get_thread_num()]; 
     97 
     98    int tmp_rank; 
     99    MPI_Comm_rank(MPI_COMM_WORLD, &tmp_rank); 
     100    if(isClient) printf("client thread %d/%d, globalComm = %p\n", omp_get_thread_num(), tmp_rank, &passage[omp_get_thread_num()]); 
     101    if(isServer) printf("server thread %d/%d, globalComm = %p\n", omp_get_thread_num(), tmp_rank, &passage[omp_get_thread_num()]); 
    88102     
    89103  } 
Note: See TracChangeset for help on using the changeset viewer.