Ignore:
Timestamp:
11/05/19 16:02:34 (5 years ago)
Author:
ymipsl
Message:

Some Update on XIOS services
Seems to work on Irène for :

  • first level of servers
  • fisrt + second level of servers
  • attached mode

YM

Location:
XIOS/dev/dev_ym/XIOS_SERVICES/src/manager
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/contexts_manager.cpp

    r1761 r1764  
    3636  } 
    3737 
     38 
     39  CContextsManager::~CContextsManager() 
     40  { 
     41    delete winNotify_ ; 
     42    delete winContexts_ ; 
     43  } 
     44 
    3845  bool CContextsManager::createServerContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, 
    3946                                             const string& contextId, bool wait) 
     
    4855      while (!ok)  
    4956      { 
    50         CXios::getDaemonsManager()->eventLoop() ; 
     57        CXios::getDaemonsManager()->servicesEventLoop() ; 
    5158        ok=servicesManager->getServiceLeader(poolId, serviceId, partitionId, serviceLeader) ; 
    5259      } 
     
    7986      while (!ok)  
    8087      { 
    81         CXios::getDaemonsManager()->eventLoop() ; 
     88        CXios::getDaemonsManager()->servicesEventLoop() ; 
    8289        ok=CXios::getServicesManager()->getServiceType(poolId,serviceId, 0, type) ; 
    8390        if (ok) ok=getContextLeader(getServerContextName(poolId, serviceId, partitionId, type, contextId), contextLeader) ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/contexts_manager.hpp

    r1761 r1764  
    2828  
    2929    CContextsManager(bool isXiosServer) ; 
     30    ~CContextsManager() ; 
     31     
    3032    bool createServerContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const string& contextId, bool wait=true) ; 
    3133/*    bool createServerContextIntercomm(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId, 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/daemons_manager.cpp

    r1761 r1764  
    2626  } 
    2727 
     28  CDaemonsManager::~CDaemonsManager() 
     29  { 
     30    CXios::finalizeContextsManager() ; 
     31    CXios::finalizeServicesManager() ; 
     32    CXios::finalizeRessourcesManager() ; 
     33  } 
     34 
    2835  bool CDaemonsManager::eventLoop(void) 
    2936  { 
     
    3138    CXios::getServicesManager()->eventLoop() ; 
    3239    CXios::getContextsManager()->eventLoop() ; 
    33     if (isServer_) return CServer::getServersRessource()->eventLoop() ; 
    34     else  return CXios::getPoolRessource()->eventLoop() ; 
     40    if (isServer_) return CServer::getServersRessource()->eventLoop(false) ; 
     41    else  return CXios::getPoolRessource()->eventLoop(false) ; 
    3542  } 
     43   
     44  bool CDaemonsManager::servicesEventLoop(void) 
     45  { 
     46    CXios::getRessourcesManager()->eventLoop() ; 
     47    CXios::getServicesManager()->eventLoop() ; 
     48    CXios::getContextsManager()->eventLoop() ; 
     49    if (isServer_) return CServer::getServersRessource()->eventLoop(true) ; 
     50    else  return CXios::getPoolRessource()->eventLoop(true) ; 
     51  }  
    3652 
    3753} 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/daemons_manager.hpp

    r1761 r1764  
    1111 
    1212    CDaemonsManager(bool isXiosServer) ; 
     13    ~CDaemonsManager() ; 
    1314 
    1415    bool eventLoop(void) ; 
     16    bool servicesEventLoop(void) ; 
    1517     
    1618    private: 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/pool_ressource.cpp

    r1761 r1764  
    100100  } 
    101101 
    102   bool CPoolRessource::eventLoop(void) 
     102  bool CPoolRessource::eventLoop(bool serviceOnly) 
    103103  { 
    104104    checkCreateServiceNotification() ; 
    105105    for (auto it=services_.begin(); it!=services_.end() ; ++it)  
    106106    { 
    107       if (it->second->eventLoop()) 
     107      if (it->second->eventLoop(serviceOnly)) 
    108108      { 
    109109        services_.erase(it) ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/pool_ressource.hpp

    r1761 r1764  
    3131    void checkCreateServiceNotification(void) ; 
    3232    void createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in) ; 
    33      bool eventLoop(void) ; 
     33     bool eventLoop(bool serviceOnly=false) ; 
    3434    CService* getService(const std::string serviceId, int partitionId) { return services_[make_tuple(serviceId,partitionId)]; } 
    3535    void finalizeSignal(void) ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/ressources_manager.cpp

    r1761 r1764  
    3434    MPI_Barrier(xiosComm_)  ;     
    3535  } 
    36  
     36   
     37  CRessourcesManager::~CRessourcesManager() 
     38  { 
     39    delete winNotify_ ; 
     40    delete winRessources_ ; 
     41  }  
    3742 
    3843  void CRessourcesManager::createPool(const string& poolId, int size) 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/ressources_manager.hpp

    r1761 r1764  
    2828     
    2929    CRessourcesManager(bool isXiosServer) ; 
     30    ~CRessourcesManager() ; 
    3031 
    3132    void eventLoop(void) ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/server_context.cpp

    r1761 r1764  
    1515 
    1616  CServerContext::CServerContext(CService* parentService, MPI_Comm contextComm, const std::string& poolId, const std::string& serviceId,  
    17                                  const int& partitionId, const std::string& contextId) : finalizeSignal_(false), parentService_(parentService) 
     17                                 const int& partitionId, const std::string& contextId) : finalizeSignal_(false), parentService_(parentService), 
     18                                 hasNotification_(false) 
    1819  { 
    1920   int localRank, globalRank, commSize ; 
     
    4849  } 
    4950 
    50    
     51  CServerContext::~CServerContext() 
     52  { 
     53 
     54  }  
     55 
    5156  bool CServerContext::createIntercomm(const string& poolId, const string& serviceId, const int& partitionId, const string& contextId,  
    5257                                       const MPI_Comm& intraComm, MPI_Comm& interCommClient, MPI_Comm& interCommServer, bool wait) 
     
    7580    } 
    7681     
    77     auto eventScheduler=parentService_->getEventScheduler() ; 
    78     std::hash<string> hashString ; 
    79     size_t hashId = hashString(name_) ; 
    80     size_t currentTimeLine=0 ; 
    81     eventScheduler->registerEvent(currentTimeLine,hashId);  
    82  
    83     while (!eventScheduler->queryEvent(currentTimeLine,hashId)) 
    84     { 
    85        CXios::getDaemonsManager()->eventLoop() ; 
    86     }   
     82    MPI_Request req ; 
     83    MPI_Status status ; 
     84    MPI_Ibarrier(intraComm,&req) ; 
     85     
     86    int flag=false ; 
     87    while(!flag)  
     88    { 
     89      CXios::getDaemonsManager()->servicesEventLoop() ; 
     90      MPI_Test(&req,&flag,&status) ; 
     91    } 
     92//    auto eventScheduler=parentService_->getEventScheduler() ; 
     93//    std::hash<string> hashString ; 
     94//    size_t hashId = hashString(name_) ; 
     95//    size_t currentTimeLine=0 ; 
     96//    eventScheduler->registerEvent(currentTimeLine,hashId);  
     97// 
     98//    while (!eventScheduler->queryEvent(currentTimeLine,hashId)) 
     99//    { 
     100//       CXios::getDaemonsManager()->servicesEventLoop() ; 
     101//       eventScheduler->checkEvent() ; 
     102//    }   
    87103     
    88104    MPI_Bcast(&ok, 1, MPI_INT, 0, intraComm) ; 
     
    90106    if (ok)   
    91107    { 
     108      int globalRank ; 
     109      MPI_Comm_rank(xiosComm_,&globalRank) ; 
     110      MPI_Bcast(&contextLeader, 1, MPI_INT, 0, intraComm) ; 
     111       
     112      int overlap, nOverlap ; 
     113      if (contextLeader==globalRank) overlap=1 ; 
     114      else overlap=0 ; 
     115      MPI_Allreduce(&overlap, &nOverlap, 1, MPI_INT, MPI_SUM, contextComm_) ; 
     116/* 
    92117      int overlap  ; 
    93118      if (get<0>(overlapedComm_[name_])) overlap=1 ; 
     
    98123      int commSize ; 
    99124      MPI_Comm_size(contextComm_,&commSize ) ; 
    100       if (nOverlap==commSize) 
    101       { 
     125*/ 
     126      if (nOverlap> 0 ) 
     127      { 
     128        while (get<0>(overlapedComm_[name_])==false) CXios::getDaemonsManager()->servicesEventLoop() ; 
     129        isAttachedMode_=true ; 
    102130        cout<<"CServerContext::createIntercomm : total overlap ==> context in attached mode"<<endl ; 
    103131        interCommClient=newInterCommClient ; 
     
    107135      {  
    108136        cout<<"CServerContext::createIntercomm : No overlap ==> context in server mode"<<endl ; 
     137        isAttachedMode_=false ; 
    109138        MPI_Intercomm_create(intraComm, 0, xiosComm_, contextLeader, 3141, &interCommClient) ; 
    110139        MPI_Comm_dup(interCommClient, &interCommServer) ; 
     
    128157     for(int rank=0; rank<commSize; rank++) 
    129158     { 
    130        notifyType_=NOTIFY_CREATE_INTERCOMM ; 
    131        notifyCreateIntercomm_ = make_tuple(remoteLeader, sourceContext) ; 
     159       notifyOutType_=NOTIFY_CREATE_INTERCOMM ; 
     160       notifyOutCreateIntercomm_ = make_tuple(remoteLeader, sourceContext) ; 
    132161       sendNotification(rank) ; 
    133162     } 
     
    147176    buffer.realloc(maxBufferSize_) ; 
    148177     
    149     if (notifyType_==NOTIFY_CREATE_INTERCOMM) 
    150     { 
    151       auto& arg=notifyCreateIntercomm_ ; 
    152       buffer << notifyType_ << std::get<0>(arg)<<std::get<1>(arg) ; 
     178    if (notifyOutType_==NOTIFY_CREATE_INTERCOMM) 
     179    { 
     180      auto& arg=notifyOutCreateIntercomm_ ; 
     181      buffer << notifyOutType_ << std::get<0>(arg)<<std::get<1>(arg) ; 
    153182    } 
    154183  } 
     
    156185  void CServerContext::notificationsDumpIn(CBufferIn& buffer) 
    157186  { 
    158     if (buffer.bufferSize() == 0) notifyType_= NOTIFY_NOTHING ; 
     187    if (buffer.bufferSize() == 0) notifyInType_= NOTIFY_NOTHING ; 
    159188    else 
    160189    { 
    161       buffer>>notifyType_; 
    162       if (notifyType_==NOTIFY_CREATE_INTERCOMM) 
    163       { 
    164         auto& arg=notifyCreateIntercomm_ ; 
     190      buffer>>notifyInType_; 
     191      if (notifyInType_==NOTIFY_CREATE_INTERCOMM) 
     192      { 
     193        auto& arg=notifyInCreateIntercomm_ ; 
    165194        buffer >> std::get<0>(arg)>> std::get<1>(arg) ; 
    166195      } 
     
    170199  void CServerContext::checkNotifications(void) 
    171200  { 
    172     int commRank ; 
    173     MPI_Comm_rank(contextComm_, &commRank) ; 
    174     winNotify_->lockWindow(commRank,0) ; 
    175     winNotify_->popFromWindow(commRank, this, &CServerContext::notificationsDumpIn) ; 
    176     winNotify_->unlockWindow(commRank,0) ; 
    177     if (notifyType_==NOTIFY_CREATE_INTERCOMM) createIntercomm() ; 
    178   } 
    179  
    180   bool CServerContext::eventLoop(void) 
     201    if (!hasNotification_) 
     202    { 
     203      int commRank ; 
     204      MPI_Comm_rank(contextComm_, &commRank) ; 
     205      winNotify_->lockWindow(commRank,0) ; 
     206      winNotify_->popFromWindow(commRank, this, &CServerContext::notificationsDumpIn) ; 
     207      winNotify_->unlockWindow(commRank,0) ; 
     208       
     209      if (notifyInType_!= NOTIFY_NOTHING) 
     210      { 
     211        hasNotification_=true ; 
     212        auto eventScheduler=parentService_->getEventScheduler() ; 
     213        std::hash<string> hashString ; 
     214        size_t hashId = hashString(name_) ; 
     215        size_t currentTimeLine=0 ; 
     216        eventScheduler->registerEvent(currentTimeLine,hashId);  
     217      } 
     218    } 
     219     
     220    if (hasNotification_) 
     221    { 
     222      auto eventScheduler=parentService_->getEventScheduler() ; 
     223      std::hash<string> hashString ; 
     224      size_t hashId = hashString(name_) ; 
     225      size_t currentTimeLine=0 ; 
     226      if (eventScheduler->queryEvent(currentTimeLine,hashId)) 
     227      { 
     228        if (notifyInType_==NOTIFY_CREATE_INTERCOMM) createIntercomm() ; 
     229        hasNotification_=false ; 
     230      } 
     231    } 
     232  } 
     233 
     234  bool CServerContext::eventLoop(bool serviceOnly) 
    181235  { 
    182236    bool finished=false ; 
    183     checkNotifications() ; 
    184     if (context_!=nullptr)   
     237    if (winNotify_!=nullptr) checkNotifications() ; 
     238    if (!serviceOnly && context_!=nullptr)   
    185239    { 
    186240      if (context_->eventLoop()) 
     
    198252  { 
    199253     MPI_Comm interCommServer, interCommClient ; 
    200      int remoteLeader=get<0>(notifyCreateIntercomm_) ; 
    201      string sourceContext=get<1>(notifyCreateIntercomm_) ; 
     254     auto& arg=notifyInCreateIntercomm_ ; 
     255     int remoteLeader=get<0>(arg) ; 
     256     string sourceContext=get<1>(arg) ; 
    202257 
    203258     auto it=overlapedComm_.find(sourceContext) ; 
     
    215270    if (nOverlap==commSize) 
    216271    { 
    217       cout<<"CServerContext::createIntercomm : total overlap ==> context in attached mode"<<endl ; 
     272      info(10)<<"CServerContext::createIntercomm : total overlap ==> context in attached mode"<<endl ; 
     273      isAttachedMode_=true ; 
    218274      interCommClient=get<2>(it->second) ; 
    219275      interCommServer=get<1>(it->second) ; 
     
    224280    else if (nOverlap==0) 
    225281    {  
    226       cout<<"CServerContext::createIntercomm : No overlap ==> context in server mode"<<endl ; 
     282      info(10)<<"CServerContext::createIntercomm : No overlap ==> context in server mode"<<endl ; 
     283      isAttachedMode_=false ; 
    227284      MPI_Intercomm_create(contextComm_, 0, xiosComm_, remoteLeader, 3141, &interCommServer) ; 
    228285      MPI_Comm_dup(interCommServer,&interCommClient) ; 
     
    233290    else 
    234291    { 
    235       cout<<"CServerContext::createIntercomm : partial overlap ==> not managed"<<endl ; 
     292      ERROR("void CServerContext::createIntercomm(void)",<<"CServerContext::createIntercomm : partial overlap ==> not managed") ; 
    236293    } 
    237294    
    238295  } 
    239296 
     297  void CServerContext::freeComm(void) 
     298  { 
     299    delete winNotify_ ; 
     300    winNotify_=nullptr ; 
     301    MPI_Comm_free(&contextComm_) ; 
     302    // don't forget intercomm -> later 
     303  } 
     304   
    240305  void CServerContext::finalizeSignal(void) 
    241306  { 
    242307    finalizeSignal_=true ; 
    243308  } 
    244     
    245309 
    246310} 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/server_context.hpp

    r1761 r1764  
    1818    CServerContext(CService* parentService, MPI_Comm contextComm, const std::string& poolId, const std::string& serviceId,  
    1919                  const int& partitionId, const std::string& contextId) ; 
     20    ~CServerContext() ; 
    2021 
    2122    bool createIntercomm(const string& poolId, const string& serviceId, const int& partitionId, const string& contextId,  
     
    2627    void checkNotifications(void) ; 
    2728 
    28     bool eventLoop(void) ; 
     29    bool eventLoop(bool serviceOnly=false) ; 
    2930    void notificationsDumpOut(CBufferOut& buffer) ; 
    3031    void notificationsDumpIn(CBufferIn& buffer) ; 
    3132    void finalizeSignal(void) ; 
     33    void freeComm(void) ; 
     34    bool isAttachedMode(void) { return isAttachedMode_ ;} 
    3235    private: 
    3336    void createIntercomm(void) ; 
     
    4750    const size_t maxBufferSize_=1024*1024 ; 
    4851    CWindowManager* winNotify_ ; 
    49     int notifyType_ ; 
    50     tuple<int, std::string> notifyCreateIntercomm_ ; 
     52    int notifyInType_, notifyOutType_ ; 
     53    tuple<int, std::string> notifyInCreateIntercomm_, notifyOutCreateIntercomm_ ; 
    5154 
    5255    const int localLeader_=0 ; 
    5356    int globalLeader_ ; 
    5457    bool finalizeSignal_ ; 
     58    bool hasNotification_ ; 
     59    bool isAttachedMode_ ; 
    5560 
    5661    friend class CWindowManager ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/servers_ressource.cpp

    r1761 r1764  
    5757       } 
    5858        
    59        notifyType_=NOTIFY_CREATE_POOL ; 
    60        notifyCreatePool_ = make_tuple(poolId, isPartOf) ; 
     59       notifyOutType_=NOTIFY_CREATE_POOL ; 
     60       notifyOutCreatePool_ = make_tuple(poolId, isPartOf) ; 
    6161       sendNotification(freeRessourcesRank_[i]) ; 
    6262    } 
     
    7171    for(int rank=0; rank<commSize;rank++) 
    7272    {  
    73       notifyType_=NOTIFY_FINALIZE ; 
     73      notifyOutType_=NOTIFY_FINALIZE ; 
    7474      sendNotification(rank) ; 
    7575    } 
     
    8989    buffer.realloc(maxBufferSize_) ; 
    9090     
    91     if (notifyType_==NOTIFY_CREATE_POOL) 
     91    if (notifyOutType_==NOTIFY_CREATE_POOL) 
    9292    { 
    93       auto& arg=notifyCreatePool_ ; 
    94       buffer << notifyType_ << std::get<0>(arg) << std::get<1>(arg) ; 
     93      auto& arg=notifyOutCreatePool_ ; 
     94      buffer << notifyOutType_ << std::get<0>(arg) << std::get<1>(arg) ; 
    9595    } 
    96     else if (notifyType_==NOTIFY_FINALIZE) buffer << notifyType_ ; 
     96    else if (notifyOutType_==NOTIFY_FINALIZE) buffer << notifyOutType_ ; 
    9797  } 
    9898 
    9999  void CServersRessource::notificationsDumpIn(CBufferIn& buffer) 
    100100  { 
    101     if (buffer.bufferSize() == 0) notifyType_= NOTIFY_NOTHING ; 
     101    if (buffer.bufferSize() == 0) notifyInType_= NOTIFY_NOTHING ; 
    102102    else 
    103103    { 
    104       buffer>>notifyType_; 
    105       if (notifyType_==NOTIFY_CREATE_POOL) 
     104      buffer>>notifyInType_; 
     105      if (notifyInType_==NOTIFY_CREATE_POOL) 
    106106      { 
    107         auto& arg=notifyCreatePool_ ; 
     107        auto& arg=notifyInCreatePool_ ; 
    108108        buffer >> std::get<0>(arg) >> std::get<1>(arg)  ; 
    109109      } 
    110       else if (notifyType_==NOTIFY_FINALIZE) { /*nothing to do*/} 
     110      else if (notifyInType_==NOTIFY_FINALIZE) { /*nothing to do*/} 
    111111    } 
    112112  } 
    113113 
    114   bool CServersRessource::eventLoop() 
     114  bool CServersRessource::eventLoop(bool serviceOnly) 
    115115  { 
    116116    checkNotifications() ; 
    117117    if (poolRessource_!=nullptr)  
    118118    { 
    119       if (poolRessource_->eventLoop()) 
     119      if (poolRessource_->eventLoop(serviceOnly)) 
    120120      { 
    121121        poolRessource_=nullptr ; 
     
    135135    winNotify_->popFromWindow(commRank, this, &CServersRessource::notificationsDumpIn) ; 
    136136    winNotify_->unlockWindow(commRank,0) ; 
    137     if (notifyType_==NOTIFY_CREATE_POOL) createPool() ; 
    138     else if (notifyType_==NOTIFY_FINALIZE) finalizeSignal() ; 
     137    if (notifyInType_==NOTIFY_CREATE_POOL) createPool() ; 
     138    else if (notifyInType_==NOTIFY_FINALIZE) finalizeSignal() ; 
    139139  } 
    140140 
    141141  void CServersRessource::createPool(void) 
    142142  { 
    143     auto& arg=notifyCreatePool_ ; 
     143    auto& arg=notifyInCreatePool_ ; 
    144144    string poolId=get<0>(arg) ; 
    145145    bool isPartOf=get<1>(arg) ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/servers_ressource.hpp

    r1761 r1764  
    2626    void createPool(const string& poolId, const int size) ; 
    2727    void createPool(void) ; 
    28     bool eventLoop(void) ; 
     28    bool eventLoop(bool serviceOnly=false) ; 
    2929    void sendNotification(int rank) ; 
    3030    void notificationsDumpOut(CBufferOut& buffer) ; 
     
    4444    const size_t maxBufferSize_=1024*1024 ; 
    4545    CWindowManager* winNotify_ ; 
    46     int notifyType_ ; 
    47     std::tuple<std::string, bool> notifyCreatePool_ ; 
     46     
     47    int notifyInType_,notifyOutType_ ; 
     48    std::tuple<std::string, bool> notifyInCreatePool_,notifyOutCreatePool_ ; 
    4849    CPoolRessource* poolRessource_ ; 
    4950    bool finalizeSignal_ ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/services.cpp

    r1761 r1764  
    1010  CService::CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId,  
    1111                     int type, int nbPartitions) : finalizeSignal_(false), eventScheduler_(nullptr), poolId_(poolId), serviceId_(serviceId), 
    12                                                    partitionId_(partitionId), type_(type), nbPartitions_(nbPartitions) 
     12                                                   partitionId_(partitionId), type_(type), nbPartitions_(nbPartitions), hasNotification_(false) 
    1313 
    1414 
     
    3434    } 
    3535    eventScheduler_ = new CEventScheduler(serviceComm_) ; 
     36 
     37    ostringstream oss; 
     38    oss<<partitionId; 
     39    name_= poolId+"::"+serviceId+"_"+oss.str(); 
    3640  } 
    3741 
     
    4145    MPI_Comm_size(serviceComm_, &commSize) ; 
    4246     
    43     for(int rank=0; rank<commSize; rank++) createContextNotify(rank, poolId, serviceId, partitionId, contextId) ; 
     47    for(int rank=0; rank<commSize; rank++)  
     48    { 
     49      notifyOutType_=NOTIFY_CREATE_CONTEXT ; 
     50      notifyOutCreateContext_ = make_tuple(poolId, serviceId, partitionId, contextId) ; 
     51      sendNotification(rank) ; 
     52    } 
    4453  } 
    4554/* 
     
    8796  } 
    8897 
    89   bool CService::eventLoop(void) 
    90   { 
    91     checkCreateContextNotification() ; 
     98  bool CService::eventLoop(bool serviceOnly) 
     99  { 
     100    //checkCreateContextNotification() ; 
     101    checkNotifications() ; 
     102 
    92103    eventScheduler_->checkEvent() ; 
    93104    for(auto it=contexts_.begin();it!=contexts_.end();++it)  
    94105    { 
    95       if (it->second->eventLoop()) 
     106      if (it->second->eventLoop(serviceOnly)) 
    96107      { 
    97108        contexts_.erase(it) ; 
     
    105116  } 
    106117 
     118  void CService::sendNotification(int rank) 
     119  { 
     120    winNotify_->lockWindow(rank,0) ; 
     121    winNotify_->pushToWindow(rank, this, &CService::notificationsDumpOut) ; 
     122    winNotify_->unlockWindow(rank,0) ; 
     123  } 
     124 
     125   
     126  void CService::notificationsDumpOut(CBufferOut& buffer) 
     127  { 
     128     
     129    buffer.realloc(maxBufferSize_) ; 
     130     
     131    if (notifyOutType_==NOTIFY_CREATE_CONTEXT) 
     132    { 
     133      auto& arg=notifyOutCreateContext_ ; 
     134      buffer << notifyOutType_ << std::get<0>(arg)<<std::get<1>(arg) << std::get<2>(arg)<<std::get<3>(arg) ; 
     135    } 
     136  } 
     137 
     138  void CService::notificationsDumpIn(CBufferIn& buffer) 
     139  { 
     140    if (buffer.bufferSize() == 0) notifyInType_= NOTIFY_NOTHING ; 
     141    else 
     142    { 
     143      buffer>>notifyInType_; 
     144      if (notifyInType_==NOTIFY_CREATE_CONTEXT) 
     145      { 
     146        info(10)<<"NotifyDumpOut"<<endl ; 
     147        auto& arg=notifyInCreateContext_ ; 
     148        buffer >> std::get<0>(arg)>> std::get<1>(arg) >> std::get<2>(arg)>> std::get<3>(arg); 
     149      } 
     150    } 
     151  } 
     152 
     153 
     154 
     155 
     156  void CService::checkNotifications(void) 
     157  { 
     158    if (!hasNotification_) 
     159    { 
     160      int commRank ; 
     161      MPI_Comm_rank(serviceComm_, &commRank) ; 
     162      winNotify_->lockWindow(commRank,0) ; 
     163      winNotify_->popFromWindow(commRank, this, &CService::notificationsDumpIn) ; 
     164      winNotify_->unlockWindow(commRank,0) ; 
     165       
     166      if (notifyInType_!= NOTIFY_NOTHING) 
     167      { 
     168        hasNotification_=true ; 
     169        std::hash<string> hashString ; 
     170        size_t hashId = hashString(name_) ; 
     171        size_t currentTimeLine=0 ; 
     172        eventScheduler_->registerEvent(currentTimeLine,hashId);  
     173      } 
     174    } 
     175     
     176    if (hasNotification_) 
     177    { 
     178      std::hash<string> hashString ; 
     179      size_t hashId = hashString(name_) ; 
     180      size_t currentTimeLine=0 ; 
     181      if (eventScheduler_->queryEvent(currentTimeLine,hashId)) 
     182      { 
     183        if (notifyInType_==NOTIFY_CREATE_CONTEXT) createContext() ; 
     184        hasNotification_=false ; 
     185      } 
     186    } 
     187  } 
     188 
     189 
     190 
     191 
    107192  void CService::checkCreateContextNotification(void) 
    108193  { 
     
    122207  } 
    123208 
     209  void CService::createContext(void) 
     210   { 
     211     auto& arg=notifyInCreateContext_ ; 
     212     string poolId = get<0>(arg) ; 
     213     string& serviceId = get<1>(arg) ; 
     214     int partitionId = get<2>(arg) ; 
     215     string contextId = get<3>(arg) ; 
     216     contexts_[contextId] = new CServerContext(this, serviceComm_, poolId, serviceId, partitionId, contextId) ;  
     217   } 
     218 
     219   //to remove 
    124220   void CService::createNewContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) 
    125221   { 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/services.hpp

    r1761 r1764  
    1616    public: 
    1717     
     18    const int NOTIFY_NOTHING=0 ; 
     19    const int NOTIFY_CREATE_CONTEXT=1 ; 
     20 
    1821    CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId,  
    1922             int type, int nbPartitions) ; 
    20     bool eventLoop(void) ; 
     23    bool eventLoop(bool serviceOnly=false) ; 
    2124    void createContext(const std::string& poolId, const std::string& serviceId, const int& partitionId, const std::string& contextId) ; 
    2225    void checkCreateContextNotification(void) ; 
     
    3639 
    3740    private: 
    38      
     41    void sendNotification(int rank) ; 
     42    void notificationsDumpOut(CBufferOut& buffer) ; 
     43    void notificationsDumpIn(CBufferIn& buffer) ; 
     44    void checkNotifications(void) ; 
     45    void createContext(void) ; 
     46 
    3947    MPI_Comm serviceComm_ ; 
    4048    MPI_Comm globalComm_ ; 
    41     
     49 
    4250    const size_t maxBufferSize_=1024*1024 ; 
    4351    const int localLeader_=0 ; 
    4452    int globalLeader_ ; 
    4553    CWindowManager* winNotify_ ; 
     54     
     55    std::string name_ ; 
     56 
    4657    std::list<std::tuple<std::string, std::string, int, std::string>> notifications_; 
     58     
     59    bool hasNotification_ ; 
     60    int notifyInType_,notifyOutType_ ; 
     61    std::tuple<std::string, std::string, int, std::string> notifyInCreateContext_, notifyOutCreateContext_ ; 
     62 
    4763    std::map<std::string, CServerContext*> contexts_ ; 
    4864    bool finalizeSignal_ ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/services_manager.cpp

    r1761 r1764  
    4242  } 
    4343 
     44  CServicesManager::~CServicesManager() 
     45  { 
     46    delete winNotify_ ; 
     47    delete winServices_ ; 
     48  } 
     49 
    4450  bool CServicesManager::createServices(const std::string& poolId, const std::string& serviceId,  
    4551                                        int type, int size, int nbPartitions, bool wait)  
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/services_manager.hpp

    r1761 r1764  
    2727     
    2828    CServicesManager(bool isXiosServer) ; 
     29    ~CServicesManager() ; 
     30     
    2931    bool createServices(const std::string& poolId, const std::string& serviceId, int type, int size, int nbPartition, bool wait=true) ; 
    3032    void createServicesNotify(int rank, const string& serviceId, int type, int size, int nbPartitions) ; 
  • XIOS/dev/dev_ym/XIOS_SERVICES/src/manager/window_manager.hpp

    r1761 r1764  
    126126    } 
    127127 
     128    ~CWindowManager() 
     129    { 
     130      MPI_Win_free(&window_) ; 
     131    } 
    128132  } ; 
    129133} 
Note: See TracChangeset for help on using the changeset viewer.