Ignore:
Timestamp:
06/23/23 14:46:51 (13 months ago)
Author:
ymipsl
Message:

Adaptation to new hyper event scheduler.
YM

Location:
XIOS3/trunk/src/manager
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/src/manager/contexts_manager.hpp

    r2260 r2523  
    7575    MPI_Comm xiosComm_ ; 
    7676 
    77     int notifyType_ ; 
     77    int notifyType_ = NOTIFY_NOTHING ; 
    7878    tuple<std::string, std::string, int, std::string> notifyCreateContext_ ; 
    7979    tuple<std::string, std::string, int, std::string, int, std::string> notifyCreateIntercomm_ ; 
  • XIOS3/trunk/src/manager/pool_ressource.cpp

    r2517 r2523  
    77#include "cxios.hpp" 
    88#include "timer.hpp" 
     9#include "event_scheduler.hpp" 
    910 
    1011namespace xios 
    1112{ 
    12   CPoolRessource::CPoolRessource(MPI_Comm poolComm, const std::string& Id, bool isServer) : Id_(Id), finalizeSignal_(false) 
     13  CPoolRessource::CPoolRessource(MPI_Comm poolComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& Id, bool isServer) : Id_(Id), finalizeSignal_(false) 
    1314  { 
    1415    int commRank, commSize ; 
     
    2930    winNotify_->updateToExclusiveWindow(commRank, this, &CPoolRessource::notificationsDumpOut) ; 
    3031    MPI_Barrier(poolComm_) ; 
     32    if (eventScheduler) eventScheduler_=eventScheduler ; 
     33    else eventScheduler_= make_shared<CEventScheduler>(poolComm) ; 
     34    freeRessourceEventScheduler_ = eventScheduler_ ; 
    3135  } 
    3236 
     
    3640     
    3741    auto it=occupancy_.begin() ; 
     42 
     43    // ym obsolete, service cannot overlap, only created on separate ressource or matching excatly existing service 
     44    // occupancy management must not be used anymore => simplification 
     45    // for now raise a message error when no ressources are availables 
     46     
    3847    int commSize ; 
    3948    MPI_Comm_size(poolComm_, &commSize) ; 
     
    4352    for(int i=0; i<size; i++)  
    4453    { 
     54      if (it->first != 0) ERROR("void CPoolRessource::createService(const std::string& serviceId, int type, int size, int nbPartitions)", 
     55                                 << "No enough free ressources on pool id="<<getId()<<" to launch service id="<<serviceId); 
    4556      procs_in[it->second]=true ; 
    4657      procs_update.push_back(std::pair<int,int>(it->first+1,it->second)) ; 
    4758      ++it ; 
    4859    } 
    49      
     60 
     61 
    5062    occupancy_.erase(occupancy_.begin(),it) ; 
    5163    occupancy_.insert(procs_update.begin(),procs_update.end()) ; 
     
    247259  { 
    248260      
    249      info(40)<<"CPoolRessource::createNewService  : receive createService notification ; serviceId : "<<serviceId<<endl ; 
    250      MPI_Comm serviceComm, newServiceComm ; 
    251      int commRank ; 
    252      MPI_Comm_rank(poolComm_,&commRank) ; 
    253      MPI_Comm_split(poolComm_, in, commRank, &serviceComm) ; 
    254      if (in) 
    255      { 
    256        int serviceCommSize ; 
    257        int serviceCommRank ; 
    258        MPI_Comm_size(serviceComm,&serviceCommSize) ; 
    259        MPI_Comm_rank(serviceComm,&serviceCommRank) ; 
    260  
    261        info(10)<<"Service  "<<serviceId<<" created "<<"  service size : "<<serviceCommSize<< "   service rank : "<<serviceCommRank  
    262                             <<" on rank pool "<<commRank<<endl ; 
     261    info(40)<<"CPoolRessource::createNewService  : receive createService notification ; serviceId : "<<serviceId<<endl ; 
     262    MPI_Comm serviceComm, newServiceComm, freeComm ; 
     263    int commRank ; 
     264      
     265    int color; 
     266    if (!services_.empty()) color = 0 ; 
     267    else color=1 ;  
     268    MPI_Comm_rank(poolComm_,&commRank) ; 
     269    MPI_Comm_split(poolComm_, color, commRank, &freeComm) ;  // workaround 
     270     
     271    if (services_.empty())  
     272    { 
     273      MPI_Comm_rank(freeComm,&commRank) ; 
     274      MPI_Comm_split(freeComm, in, commRank, &serviceComm) ; 
     275 
     276      // temporary for event scheduler, we must using hierarchical split of free ressources communicator. 
     277      // we hope for now that spliting using occupancy make this match 
     278 
     279      if (in) 
     280      { 
     281        int serviceCommSize ; 
     282        int serviceCommRank ; 
     283        MPI_Comm_size(serviceComm,&serviceCommSize) ; 
     284        MPI_Comm_rank(serviceComm,&serviceCommRank) ; 
     285 
     286        info(10)<<"Service  "<<serviceId<<" created "<<"  service size : "<<serviceCommSize<< "   service rank : "<<serviceCommRank  
     287                              <<" on rank pool "<<commRank<<endl ; 
    263288        
    264        int partitionId ;  
    265        if ( serviceCommRank >= (serviceCommSize/nbPartitions+1)*(serviceCommSize%nbPartitions) ) 
    266        { 
    267          int rank =  serviceCommRank - (serviceCommSize/nbPartitions+1)*(serviceCommSize%nbPartitions) ; 
    268          partitionId = serviceCommSize%nbPartitions +  rank / (serviceCommSize/nbPartitions) ; 
    269        } 
    270        else  partitionId = serviceCommRank / (serviceCommSize/nbPartitions + 1) ; 
    271  
    272        MPI_Comm_split(serviceComm, partitionId, commRank, &newServiceComm) ; 
     289        int partitionId ;  
     290        if ( serviceCommRank >= (serviceCommSize/nbPartitions+1)*(serviceCommSize%nbPartitions) ) 
     291        { 
     292          int rank =  serviceCommRank - (serviceCommSize/nbPartitions+1)*(serviceCommSize%nbPartitions) ; 
     293          partitionId = serviceCommSize%nbPartitions +  rank / (serviceCommSize/nbPartitions) ; 
     294        } 
     295        else  partitionId = serviceCommRank / (serviceCommSize/nbPartitions + 1) ; 
     296 
     297        MPI_Comm_split(serviceComm, partitionId, commRank, &newServiceComm) ; 
     298 
     299        MPI_Comm_size(newServiceComm,&serviceCommSize) ; 
     300        MPI_Comm_rank(newServiceComm,&serviceCommRank) ; 
     301        info(10)<<"Service  "<<serviceId<<" created "<<"  partition : " <<partitionId<<" service size : "<<serviceCommSize 
     302                << " service rank : "<<serviceCommRank <<" on rank pool "<<commRank<<endl ; 
     303       
     304        shared_ptr<CEventScheduler> parentScheduler, childScheduler ; 
     305        freeRessourceEventScheduler_->splitScheduler(newServiceComm, parentScheduler, childScheduler) ; 
     306        if (isFirstSplit_) eventScheduler_ = parentScheduler ; 
     307        isFirstSplit_=false ; 
     308 
     309        services_[std::make_tuple(serviceId,partitionId)] = new CService(newServiceComm, childScheduler, Id_, serviceId, partitionId, type, nbPartitions) ; 
    273310        
    274        MPI_Comm_size(newServiceComm,&serviceCommSize) ; 
    275        MPI_Comm_rank(newServiceComm,&serviceCommRank) ; 
    276        info(10)<<"Service  "<<serviceId<<" created "<<"  partition : " <<partitionId<<" service size : "<<serviceCommSize 
    277                << " service rank : "<<serviceCommRank <<" on rank pool "<<commRank<<endl ; 
    278        
    279        services_[std::make_tuple(serviceId,partitionId)] = new CService(newServiceComm, Id_, serviceId, partitionId, type, nbPartitions) ; 
    280         
    281        MPI_Comm_free(&newServiceComm) ; 
    282      } 
    283      MPI_Comm_free(&serviceComm) ; 
     311        MPI_Comm_free(&newServiceComm) ; 
     312      } 
     313      else 
     314      { 
     315        shared_ptr<CEventScheduler> parentScheduler, childScheduler ; 
     316        freeRessourceEventScheduler_->splitScheduler(serviceComm, parentScheduler, childScheduler) ; 
     317        if (isFirstSplit_) eventScheduler_ = parentScheduler ; 
     318        freeRessourceEventScheduler_ = childScheduler ; 
     319        isFirstSplit_=false ; 
     320      } 
     321      MPI_Comm_free(&serviceComm) ; 
     322    } 
     323    MPI_Comm_free(&freeComm) ; 
    284324  } 
    285325   
     
    300340        shared_ptr<CEventScheduler>  eventScheduler = service.second->getEventScheduler() ; 
    301341        info(40)<<"CPoolRessource::createNewServiceOnto ; found onServiceId : "<<onServiceId<<endl  ; 
    302         services_[std::make_tuple(serviceId,partitionId)] = new CService(newServiceComm, Id_, serviceId, partitionId, type, 
    303                                                                          nbPartitions, eventScheduler) ;        
    304       } 
    305     } 
    306      
    307   } 
    308  
    309   void CPoolRessource::createService(MPI_Comm serviceComm, const std::string& serviceId, int partitionId, int type, int nbPartitions) // for clients & attached 
    310   { 
    311     services_[std::make_tuple(serviceId,partitionId)] = new CService(serviceComm, Id_, serviceId, partitionId, type, nbPartitions) ; 
     342        services_[std::make_tuple(serviceId,partitionId)] = new CService(newServiceComm, eventScheduler, Id_, serviceId, partitionId, type, 
     343                                                                         nbPartitions) ;        
     344      } 
     345    } 
     346     
     347  } 
     348 
     349  void CPoolRessource::createService(MPI_Comm serviceComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& serviceId, int partitionId, int type, int nbPartitions) // for clients & attached 
     350  { 
     351    services_[std::make_tuple(serviceId,partitionId)] = new CService(serviceComm, eventScheduler, Id_, serviceId, partitionId, type, nbPartitions) ; 
    312352  } 
    313353 
  • XIOS3/trunk/src/manager/pool_ressource.hpp

    r2458 r2523  
    55#include "window_manager.hpp" 
    66#include "services_manager.hpp" 
     7#include "event_scheduler.hpp" 
    78 
    89 
     
    2728 
    2829    public: 
    29     CPoolRessource(MPI_Comm poolComm, const std::string& Id, bool isServer) ; 
     30    CPoolRessource(MPI_Comm poolComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& Id, bool isServer) ; 
    3031    ~CPoolRessource() ; 
    3132     
    3233    void createService(const std::string& serviceId, int type, int size, int nbPartition) ; 
    33     void createService(MPI_Comm serviceComm, const std::string& serviceId, int partitionId, int type, int nbPartitions) ;  
     34    void createService(MPI_Comm serviceComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& serviceId, int partitionId, int type, int nbPartitions) ;  
    3435    void createServiceOnto(const std::string& serviceId, int type, const std::string& OnServiceId) ; 
    3536    bool eventLoop(bool serviceOnly=false) ; 
     37    bool hasService(const std::string serviceId, int partitionId) {return services_.count(make_tuple(serviceId,partitionId))>0 ;} 
    3638    CService* getService(const std::string serviceId, int partitionId) { return services_[make_tuple(serviceId,partitionId)]; } 
    3739    void finalizeSignal(void) ; 
    3840    string getId(void) { return Id_; } 
     41    const MPI_Comm& getCommunicator(void) { return poolComm_ ;} 
    3942 
    4043  private: 
     
    5356//    void checkCreateServiceNotification(void) ; 
    5457    void createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in) ; 
     58  public: 
    5559    void createNewServiceOnto(const std::string& serviceId, int type, const string& onServiceId) ; 
    5660     
     
    7377    const double eventLoopLatency_=0;  
    7478    double lastEventLoop_=0. ; 
     79 
     80    private: 
     81      shared_ptr<CEventScheduler> eventScheduler_ ; 
     82      shared_ptr<CEventScheduler> freeRessourceEventScheduler_ ; 
     83      bool isFirstSplit_=true ; 
     84    public: 
     85      shared_ptr<CEventScheduler> getEventScheduler(void) { return eventScheduler_ ;} 
     86 
    7587  }; 
    7688 
  • XIOS3/trunk/src/manager/ressources_manager.hpp

    r2458 r2523  
    7272    MPI_Comm xiosComm_ ; 
    7373 
    74     int notifyType_ ; 
     74    int notifyType_ = NOTIFY_NOTHING; 
    7575    tuple<std::string, int> notifyCreatePool_ ; 
    7676 
  • XIOS3/trunk/src/manager/servers_ressource.cpp

    r2517 r2523  
    33#include "ressources_manager.hpp" 
    44#include "pool_ressource.hpp" 
     5#include "event_scheduler.hpp" 
    56#include "cxios.hpp" 
    67#include "mpi.hpp" 
     
    89#include <vector> 
    910#include <string> 
     11 
    1012 
    1113 
     
    3941 
    4042    MPI_Comm_dup(serverComm_, &freeRessourcesComm_) ;  
    41  
     43    eventScheduler_ = make_shared<CEventScheduler>(freeRessourcesComm_) ; 
     44    freeRessourceEventScheduler_ = eventScheduler_ ; 
    4245  } 
    4346 
     
    160163    MPI_Comm_split(freeRessourcesComm_, isPartOf, commRank, &poolComm) ; 
    161164     
     165    shared_ptr<CEventScheduler> parentScheduler, childScheduler ; 
     166    freeRessourceEventScheduler_->splitScheduler(poolComm, parentScheduler, childScheduler) ; 
     167     
     168    if (isFirstSplit_) eventScheduler_ = parentScheduler ;  
     169    isFirstSplit_ = false ; 
     170 
    162171    if (isPartOf) 
    163172    {   
    164       poolRessource_ = new CPoolRessource(poolComm, poolId, true) ; 
     173      poolRessource_ = new CPoolRessource(poolComm, childScheduler, poolId, true) ; 
    165174      MPI_Comm_free(&poolComm) ; 
    166175    } 
    167176    else  
    168177    { 
     178      freeRessourceEventScheduler_ = childScheduler ; 
    169179      MPI_Comm_free(&freeRessourcesComm_) ; 
    170180      freeRessourcesComm_=poolComm ; 
  • XIOS3/trunk/src/manager/servers_ressource.hpp

    r2274 r2523  
    33 
    44#include "window_manager.hpp" 
     5#include "event_scheduler.hpp" 
    56#include "mpi.hpp" 
    67#include <vector> 
     
    3334    void checkNotifications(void) ; 
    3435    CPoolRessource* getPoolRessource(void) { return poolRessource_; }  
     36    const MPI_Comm& getCommunicator(void) { return serverComm_ ;} 
    3537    bool isServerLeader(void) ; 
    3638    void finalize(void) ; 
     
    5456    double lastEventLoop_=0. ; 
    5557 
     58    private: 
     59      shared_ptr<CEventScheduler> eventScheduler_ ; 
     60      shared_ptr<CEventScheduler> freeRessourceEventScheduler_ ; 
     61      bool isFirstSplit_=true ; 
     62    public: 
     63      shared_ptr<CEventScheduler> getEventScheduler(void) { return eventScheduler_ ;} 
    5664    friend class CWindowManager ; 
    5765  } ; 
  • XIOS3/trunk/src/manager/services.cpp

    r2517 r2523  
    99namespace xios 
    1010{ 
    11   CService::CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId,  
    12                      int type, int nbPartitions, shared_ptr<CEventScheduler> eventScheduler)  
     11  CService::CService(MPI_Comm serviceComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& poolId, const std::string& serviceId, const int& partitionId,  
     12                     int type, int nbPartitions)  
    1313                         : finalizeSignal_(false), eventScheduler_(nullptr), poolId_(poolId), serviceId_(serviceId), 
    1414                           partitionId_(partitionId), type_(type), nbPartitions_(nbPartitions), hasNotification_(false) 
     
    191191          size_t hashId = hashString(name_) ; 
    192192          size_t currentTimeLine=0 ; 
    193           info(40)<<"CService::checkNotifications(void) : receive notification => event scheduler"<<endl ; 
     193          info(40)<<"CService::checkNotifications(void) : receive notification => event scheduler : timeLine : "<<currentTimeLine<<"  hashId : "<<hashId<<endl ; 
    194194          eventScheduler_->registerEvent(currentTimeLine,hashId);  
    195195        } 
     
    203203      size_t hashId = hashString(name_) ; 
    204204      size_t currentTimeLine=0 ; 
    205       info(40)<<"CService::checkNotifications(void) : receive notification => event scheduler : eventIsReceived ?"<<endl ; 
     205//      info(40)<<"CService::checkNotifications(void) : receive notification => event scheduler : eventIsReceived ?"<<endl ; 
    206206      if (eventScheduler_->queryEvent(currentTimeLine,hashId)) 
    207207      { 
  • XIOS3/trunk/src/manager/services.hpp

    r2404 r2523  
    1919    const int NOTIFY_CREATE_CONTEXT=1 ; 
    2020 
    21     CService(MPI_Comm serviceComm, const std::string& poolId, const std::string& serviceId, const int& partitionId,  
    22              int type, int nbPartitions, shared_ptr<CEventScheduler> = nullptr) ; 
     21    CService(MPI_Comm serviceComm, shared_ptr<CEventScheduler>, const std::string& poolId, const std::string& serviceId, const int& partitionId,  
     22             int type, int nbPartitions) ; 
    2323    ~CService() ; 
    2424 
  • XIOS3/trunk/src/manager/services_manager.cpp

    r2517 r2523  
    304304  } 
    305305 
     306  void CServicesManager::waitServiceRegistration(const std::string& poolId, const std::string& serviceId) 
     307  { 
     308    int nbPartition ; 
     309    getServiceNbPartitions(poolId,serviceId,0,nbPartition, true) ; 
     310    for(int n=1;n<nbPartition;n++) waitServiceRegistration(poolId, serviceId, n) ; 
     311 
     312  } 
    306313} 
  • XIOS3/trunk/src/manager/services_manager.hpp

    r2458 r2523  
    4949    bool hasService(const std::string& poolId, const std::string& serviceId, const int& partitionId) ; 
    5050    void waitServiceRegistration(const std::string& poolId, const std::string& serviceId, const int& partitionId); 
     51    void waitServiceRegistration(const std::string& poolId, const std::string& serviceId); 
    5152    void servicesDumpOut(CBufferOut& buffer) ; 
    5253    void servicesDumpIn(CBufferIn& buffer) ; 
     
    7475    MPI_Comm xiosComm_ ; 
    7576 
    76     int notifyType_ ; 
     77    int notifyType_ = NOTIFY_NOTHING ; 
    7778    tuple<std::string, int, int, int> notifyCreateService_ ; 
    7879    tuple<std::string, int, std::string> notifyCreateServiceOnto_ ; 
Note: See TracChangeset for help on using the changeset viewer.