source: XIOS3/trunk/src/transport/context_client.hpp

Last change on this file was 2564, checked in by jderouillat, 10 months ago

Clean memory leaks

  • Property svn:executable set to *
File size: 4.4 KB
Line 
1#ifndef __CONTEXT_CLIENT_HPP__
2#define __CONTEXT_CLIENT_HPP__
3
4#include "xios_spl.hpp"
5#include "buffer_out.hpp"
6#include "buffer_in.hpp"
7#include "buffer_client.hpp"
8#include "event_client.hpp"
9#include "event_server.hpp"
10#include "mpi.hpp"
11#include "registry.hpp"
12
13namespace xios
14{
15  class CContext;
16  class CContextServer ;
17  /*!
18  \class CContextClient
19  A context can be both on client and on server side. In order to differenciate the role of
20  context on each side, e.x client sending events, server receiving and processing events, there is a need of
21  concrete "context" classes for both sides.
22  CContextClient processes and sends events from client to server where CContextServer receives these events
23  and processes them.
24  */
25  class COneSidedContextClient ;
26
27  class CContextClient
28  {
29    public:
30      enum ETransport { generic, legacy, oneSided, p2p, online}  ;
31     
32      template<ETransport transport=generic> 
33      static CContextClient* getNew(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0) ;
34
35            // Contructor
36      CContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0);
37      virtual ~CContextClient() {} 
38
39      bool isServerLeader(void) const;
40      bool isServerNotLeader(void) const;
41      const std::list<int>& getRanksServerLeader(void) const;
42      const std::list<int>& getRanksServerNotLeader(void) const;
43      static void computeLeader(int clientRank, int clientSize, int serverSize,
44                                std::list<int>& rankRecvLeader,
45                                std::list<int>& rankRecvNotLeader);
46      int getRemoteSize(void) {return serverSize;}
47      int getServerSize(void) {return serverSize;}
48      MPI_Comm getIntraComm(void)  {return intraComm ;} 
49      int getIntraCommSize(void) {return clientSize ;}
50      int getIntraCommRank(void) {return clientRank ;}
51      /*! set the associated server (dual chanel client/server) */     
52      void setAssociatedServer(CContextServer* associatedServer) { associatedServer=associatedServer_;}
53      /*! get the associated server (dual chanel client/server) */     
54      CContextServer* getAssociatedServer(void) { return associatedServer_;}
55     
56
57
58      virtual ETransport getType(void) = 0 ;
59      // Send event to server
60      virtual void sendEvent(CEventClient& event)=0;
61      virtual void eventLoop(void)=0 ;
62      virtual void releaseBuffers(void)=0;
63      virtual bool havePendingRequests(void)=0;
64
65
66      virtual bool isNotifiedFinalized(void)=0 ;
67      virtual void finalize(void)=0;
68
69      virtual void setBufferSize(const std::map<int,StdSize>& mapSize)=0;
70
71      public: 
72        static CContextClient* ONLINE(void) { return reinterpret_cast<CContextClient*>(0xdeaddead);}
73    protected:
74
75      CContext* context_; //!< Context for client
76
77      CContext* parentServer; //!< Context for server (Only used in attached mode)
78
79      int clientRank; //!< Rank of current client
80
81      int clientSize; //!< Size of client group
82
83      int serverSize; //!< Size of server group
84
85      MPI_Comm interComm; //!< Communicator of server group (interCommunicator)
86
87      MPI_Comm intraComm; //!< Communicator of client group
88     
89      std::list<int> ranksServerLeader; //!< List of server ranks for which the client is leader
90
91      std::list<int> ranksServerNotLeader; //!< List of server ranks for which the client is not leader
92
93      size_t hashId_ ; //!< hash id on the context client that will be used for context server to identify the remote calling context client.
94
95      CContextServer* associatedServer_ ; //!< The server associated to the pair client/server
96  };
97
98  template<>
99  CContextClient* CContextClient::getNew<CContextClient::generic>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
100 
101  template<>
102  CContextClient* CContextClient::getNew<CContextClient::oneSided>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
103
104  template<>
105  CContextClient* CContextClient::getNew<CContextClient::p2p>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
106
107  template<>
108  CContextClient* CContextClient::getNew<CContextClient::legacy>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
109
110  template<>
111  CContextClient* CContextClient::getNew<CContextClient::online>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
112
113
114}
115
116#endif // __CONTEXT_CLIENT_HPP__
Note: See TracBrowser for help on using the repository browser.