Ignore:
Timestamp:
08/29/23 17:24:04 (10 months ago)
Author:
ymipsl
Message:

Major update :

  • New method to lock and unlock one-sided windows (window_dynamic) to avoid network overhead
  • Introducing multithreading on server sided to manage more efficiently dead-lock occuring (similar to co-routine which will be available and implemented in futur c++ standard), based on c++ threads
  • Suprression of old "attached mode" which is replaced by online writer and reder filters

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/src/manager/server_context.cpp

    r2517 r2547  
    66#include "register_context_info.hpp" 
    77#include "services.hpp" 
     8#include "thread_manager.hpp" 
    89#include "timer.hpp" 
    910 
     
    5051    info(10)<<"Context "<< CXios::getContextsManager()->getServerContextName(poolId, serviceId, partitionId, type, contextId)<<" created, on local rank "<<localRank 
    5152                        <<" and global rank "<<globalRank<<endl  ; 
     53    
     54    if (CThreadManager::isUsingThreads()) CThreadManager::spawnThread(&CServerContext::threadEventLoop, this) ; 
    5255  } 
    5356 
     
    8487    } 
    8588     
    86     MPI_Request req ; 
    87     MPI_Status status ; 
    88     MPI_Ibarrier(intraComm,&req) ; 
    89      
    90     int flag=false ; 
    91     while(!flag)  
    92     { 
    93       CXios::getDaemonsManager()->servicesEventLoop() ; 
    94       MPI_Test(&req,&flag,&status) ; 
    95     } 
    96  
     89    if (wait) 
     90    { 
     91      MPI_Request req ; 
     92      MPI_Status status ; 
     93      MPI_Ibarrier(intraComm,&req) ; 
     94     
     95      int flag=false ; 
     96      while(!flag)  
     97      { 
     98        CXios::getDaemonsManager()->servicesEventLoop() ; 
     99        MPI_Test(&req,&flag,&status) ; 
     100      } 
     101    } 
     102     
    97103    MPI_Bcast(&ok, 1, MPI_INT, 0, intraComm) ; 
    98104 
     
    117123      MPI_Comm_size(contextComm_,&commSize ) ; 
    118124*/ 
    119       if (nOverlap> 0 ) 
    120       { 
    121         while (get<0>(overlapedComm_[name_])==false) CXios::getDaemonsManager()->servicesEventLoop() ; 
    122         isAttachedMode_=true ; 
    123         cout<<"CServerContext::createIntercomm : total overlap ==> context in attached mode"<<endl ; 
    124         interCommClient=newInterCommClient ; 
    125         interCommServer=newInterCommServer ; 
    126       } 
    127       else if (nOverlap==0) 
     125      if (nOverlap==0) 
    128126      {  
    129         cout<<"CServerContext::createIntercomm : No overlap ==> context in server mode"<<endl ; 
    130         isAttachedMode_=false ; 
    131127        MPI_Intercomm_create(intraComm, 0, xiosComm_, contextLeader, 3141, &interCommClient) ; 
    132128        MPI_Comm_dup(interCommClient, &interCommServer) ; 
     
    136132      else 
    137133      { 
    138         cout<<"CServerContext::createIntercomm : partial overlap ==> not managed"<<endl ; 
     134        ERROR("void CServerContext::createIntercomm(void)",<<"CServerContext::createIntercomm : overlap ==> not managed") ; 
    139135      } 
    140136    } 
     
    259255  } 
    260256 
     257  void CServerContext::threadEventLoop(void) 
     258  { 
     259     
     260    info(100)<<"Launch Thread for CServerContext::threadEventLoop, context id = "<<context_->getId()<<endl ; 
     261    CThreadManager::threadInitialize() ;  
     262    do 
     263    { 
     264      CTimer::get("CServerContext::eventLoop").resume(); 
     265      int flag ; 
     266      MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, MPI_STATUS_IGNORE); 
     267 
     268      if (winNotify_!=nullptr) checkNotifications() ; 
     269 
     270 
     271      if (context_!=nullptr)   
     272      { 
     273        if (context_->eventLoop()) 
     274        { 
     275          info(100)<<"Remove context server with id "<<context_->getId()<<endl ; 
     276          CContext::removeContext(context_->getId()) ; 
     277          context_=nullptr ; 
     278          // destroy context ??? --> later 
     279        } 
     280      } 
     281      CTimer::get("CServerContext::eventLoop").suspend(); 
     282      if (context_==nullptr && finalizeSignal_) finished_=true ; 
     283  
     284      if (!finished_) CThreadManager::yield() ; 
     285    } 
     286    while (!finished_) ; 
     287     
     288    CThreadManager::threadFinalize() ; 
     289    info(100)<<"Close thread for CServerContext::threadEventLoop"<<endl ; 
     290  } 
     291 
    261292  void CServerContext::createIntercomm(void) 
    262293  { 
     
    280311     MPI_Comm_size(contextComm_,&commSize ) ; 
    281312 
    282     if (nOverlap==commSize) 
    283     { 
    284       info(10)<<"CServerContext::createIntercomm : total overlap ==> context in attached mode"<<endl ; 
    285       isAttachedMode_=true ; 
    286       interCommClient=get<2>(it->second) ; 
    287       interCommServer=get<1>(it->second) ; 
    288       context_ -> createClientInterComm(interCommClient, interCommServer ) ; 
    289       clientsInterComm_.push_back(interCommClient) ; 
    290       clientsInterComm_.push_back(interCommServer) ; 
    291     } 
    292     else if (nOverlap==0) 
     313    if (nOverlap==0) 
    293314    {  
    294315      info(10)<<"CServerContext::createIntercomm : No overlap ==> context in server mode"<<endl ; 
    295       isAttachedMode_=false ; 
    296316      MPI_Intercomm_create(contextComm_, 0, xiosComm_, remoteLeader, 3141, &interCommServer) ; 
    297317      MPI_Comm_dup(interCommServer,&interCommClient) ; 
     
    302322    else 
    303323    { 
    304       ERROR("void CServerContext::createIntercomm(void)",<<"CServerContext::createIntercomm : partial overlap ==> not managed") ; 
     324      ERROR("void CServerContext::createIntercomm(void)",<<"CServerContext::createIntercomm : overlap ==> not managed") ; 
    305325    } 
    306326    
Note: See TracChangeset for help on using the changeset viewer.