[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) ; |
---|
[2547] | 37 | void threadEventLoop(void) ; |
---|
[2523] | 38 | bool hasService(const std::string serviceId, int partitionId) {return services_.count(make_tuple(serviceId,partitionId))>0 ;} |
---|
[1761] | 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_; } |
---|
[2523] | 42 | const MPI_Comm& getCommunicator(void) { return poolComm_ ;} |
---|
[2404] | 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) ; |
---|
[2547] | 53 | void synchronize(void) ; |
---|
[1761] | 54 | |
---|
[2404] | 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) ; |
---|
[2523] | 60 | public: |
---|
[2404] | 61 | void createNewServiceOnto(const std::string& serviceId, int type, const string& onServiceId) ; |
---|
[2547] | 62 | |
---|
| 63 | private: |
---|
| 64 | bool finished_=false ; |
---|
| 65 | public: |
---|
| 66 | bool isFinished(void) { return finished_ ;} |
---|
| 67 | |
---|
| 68 | private: |
---|
[1761] | 69 | MPI_Comm poolComm_ ; |
---|
| 70 | |
---|
| 71 | std::multimap<int,int> occupancy_ ; |
---|
[2404] | 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 | |
---|
[1761] | 80 | std::map< std::tuple<std::string, int>, CService*> services_ ; |
---|
| 81 | std::string Id_ ; |
---|
| 82 | bool finalizeSignal_ ; |
---|
[2547] | 83 | |
---|
[2260] | 84 | const double eventLoopLatency_=0; |
---|
[2246] | 85 | double lastEventLoop_=0. ; |
---|
[2523] | 86 | |
---|
| 87 | private: |
---|
[2547] | 88 | size_t hashId_ ; |
---|
[2523] | 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 | |
---|
[1761] | 95 | }; |
---|
| 96 | |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | |
---|
[2458] | 101 | #endif |
---|