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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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   { 
Note: See TracChangeset for help on using the changeset viewer.