[1761] | 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" |
---|
[2523] | 7 | #include "event_scheduler.hpp" |
---|
[1761] | 8 | |
---|
| 9 | |
---|
| 10 | namespace 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 | |
---|
[2404] | 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: |
---|
[2523] | 30 | CPoolRessource(MPI_Comm poolComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& Id, bool isServer) ; |
---|
[2274] | 31 | ~CPoolRessource() ; |
---|
[1761] | 32 | |
---|
| 33 | void createService(const std::string& serviceId, int type, int size, int nbPartition) ; |
---|
[2523] | 34 | void createService(MPI_Comm serviceComm, shared_ptr<CEventScheduler> eventScheduler, const std::string& serviceId, int partitionId, int type, int nbPartitions) ; |
---|
[2404] | 35 | void createServiceOnto(const std::string& serviceId, int type, const std::string& OnServiceId) ; |
---|
| 36 | bool eventLoop(bool serviceOnly=false) ; |
---|
[2523] | 37 | bool hasService(const std::string serviceId, int partitionId) {return services_.count(make_tuple(serviceId,partitionId))>0 ;} |
---|
[1761] | 38 | CService* getService(const std::string serviceId, int partitionId) { return services_[make_tuple(serviceId,partitionId)]; } |
---|
| 39 | void finalizeSignal(void) ; |
---|
| 40 | string getId(void) { return Id_; } |
---|
[2523] | 41 | const MPI_Comm& getCommunicator(void) { return poolComm_ ;} |
---|
[2404] | 42 | |
---|
| 43 | private: |
---|
| 44 | void createServiceNotify(int rank, const string& serviceId, int type, int size, int nbPartitions, bool in) ; |
---|
| 45 | void createServiceOntoNotify(int rank, const string& serviceId, int type, const string& onServiceId) ; |
---|
| 46 | void sendNotification(int rank) ; |
---|
| 47 | void checkNotifications(void) ; |
---|
| 48 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
| 49 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
| 50 | void createService(void) ; |
---|
| 51 | void createServiceOnto(void) ; |
---|
[1761] | 52 | |
---|
[2404] | 53 | // void createServiceNotify(int rank, const std::string& serviceId, int type, int size, int nbPartitions, bool in) ; |
---|
| 54 | // void createServiceDumpOut(CBufferOut& buffer) ; |
---|
| 55 | // void createServiceDumpIn(CBufferIn& buffer) ; |
---|
| 56 | // void checkCreateServiceNotification(void) ; |
---|
| 57 | void createNewService(const std::string& serviceId, int type, int size, int nbPartitions, bool in) ; |
---|
[2523] | 58 | public: |
---|
[2404] | 59 | void createNewServiceOnto(const std::string& serviceId, int type, const string& onServiceId) ; |
---|
| 60 | |
---|
| 61 | private: |
---|
[1761] | 62 | MPI_Comm poolComm_ ; |
---|
| 63 | |
---|
| 64 | std::multimap<int,int> occupancy_ ; |
---|
[2404] | 65 | |
---|
| 66 | // std::list<std::tuple<std::string, int, int, int, bool> > notifications_; |
---|
| 67 | |
---|
| 68 | int notifyType_ ; |
---|
| 69 | tuple<std::string, int, int, int, bool> notifyCreateService_ ; |
---|
| 70 | tuple<std::string, int, std::string> notifyCreateServiceOnto_ ; |
---|
| 71 | |
---|
| 72 | |
---|
[1761] | 73 | std::map< std::tuple<std::string, int>, CService*> services_ ; |
---|
| 74 | std::string Id_ ; |
---|
| 75 | bool finalizeSignal_ ; |
---|
[2246] | 76 | |
---|
[2260] | 77 | const double eventLoopLatency_=0; |
---|
[2246] | 78 | double lastEventLoop_=0. ; |
---|
[2523] | 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 | |
---|
[1761] | 87 | }; |
---|
| 88 | |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | |
---|
[2458] | 93 | #endif |
---|