source: XIOS3/trunk/src/manager/pool_ressource.hpp @ 2547

Last change on this file since 2547 was 2547, checked in by ymipsl, 10 months ago

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

  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#ifndef __POOL_RESSOURCE_HPP__
2#define __POOL_RESSOURCE_HPP__
3
4#include "mpi.hpp"
5#include "window_manager.hpp"
6#include "services_manager.hpp"
7#include "event_scheduler.hpp"
8
9
10namespace xios
11{
12 
13  class CService ;
14
15  class CPoolRessource 
16  {
17    private:
18     
19    const size_t maxBufferSize_=1024*1024 ;
20    const int localLeader_ = 0 ;
21
22    CWindowManager* winNotify_ ;
23   
24    private:
25    const int NOTIFY_NOTHING=0 ;
26    const int NOTIFY_CREATE_SERVICE=1 ;
27    const int NOTIFY_CREATE_SERVICE_ONTO=2 ;
28
29    public:
30    CPoolRessource(MPI_Comm poolComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& Id, bool isServer) ;
31    ~CPoolRessource() ;
32   
33    void createService(const std::string& serviceId, int type, int size, int nbPartition) ;
34    void createService(MPI_Comm serviceComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& serviceId, int partitionId, int type, int nbPartitions) ; 
35    void createServiceOnto(const std::string& serviceId, int type, const std::string& OnServiceId) ;
36    bool eventLoop(bool serviceOnly=false) ;
37    void threadEventLoop(void) ;
38    bool hasService(const std::string serviceId, int partitionId) {return services_.count(make_tuple(serviceId,partitionId))>0 ;}
39    CService* getService(const std::string serviceId, int partitionId) { return services_[make_tuple(serviceId,partitionId)]; }
40    void finalizeSignal(void) ;
41    string getId(void) { return Id_; }
42    const MPI_Comm& getCommunicator(void) { return poolComm_ ;}
43
44  private:
45    void createServiceNotify(int rank, const string& serviceId, int type, int size, int nbPartitions, bool in) ;
46    void createServiceOntoNotify(int rank, const string& serviceId, int type, const string& onServiceId) ;
47    void sendNotification(int rank) ;
48    void checkNotifications(void) ;
49    void notificationsDumpOut(CBufferOut& buffer) ;
50    void notificationsDumpIn(CBufferIn& buffer) ;
51    void createService(void) ;
52    void createServiceOnto(void) ;
53    void synchronize(void) ;
54   
55//    void createServiceNotify(int rank, const std::string& serviceId, int type, int size, int nbPartitions, bool in) ;
56//    void createServiceDumpOut(CBufferOut& buffer) ;
57//    void createServiceDumpIn(CBufferIn& buffer) ;
58//    void checkCreateServiceNotification(void) ;
59    void createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in) ;
60  public:
61    void createNewServiceOnto(const std::string& serviceId, int type, const string& onServiceId) ;
62 
63  private:
64    bool finished_=false ;
65  public:
66    bool isFinished(void) { return finished_ ;}
67
68  private:
69    MPI_Comm poolComm_ ;
70   
71    std::multimap<int,int> occupancy_ ;
72
73//    std::list<std::tuple<std::string, int, int, int, bool> > notifications_;
74   
75    int notifyType_ ;
76    tuple<std::string, int, int, int, bool> notifyCreateService_ ;
77    tuple<std::string, int, std::string> notifyCreateServiceOnto_ ;
78
79
80    std::map< std::tuple<std::string, int>, CService*> services_ ;
81    std::string Id_ ;
82    bool finalizeSignal_ ;
83       
84    const double eventLoopLatency_=0; 
85    double lastEventLoop_=0. ;
86
87    private:
88      size_t hashId_ ;
89      shared_ptr<CEventScheduler> eventScheduler_ ;
90      shared_ptr<CEventScheduler> freeRessourceEventScheduler_ ;
91      bool isFirstSplit_=true ;
92    public:
93      shared_ptr<CEventScheduler> getEventScheduler(void) { return eventScheduler_ ;}
94
95  };
96
97}
98
99
100
101#endif
Note: See TracBrowser for help on using the repository browser.