source: XIOS3/trunk/src/transport/context_client.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: 4.2 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, 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
38      bool isServerLeader(void) const;
39      bool isServerNotLeader(void) const;
40      const std::list<int>& getRanksServerLeader(void) const;
41      const std::list<int>& getRanksServerNotLeader(void) const;
42      static void computeLeader(int clientRank, int clientSize, int serverSize,
43                                std::list<int>& rankRecvLeader,
44                                std::list<int>& rankRecvNotLeader);
45      int getRemoteSize(void) {return serverSize;}
46      int getServerSize(void) {return serverSize;}
47      MPI_Comm getIntraComm(void)  {return intraComm ;} 
48      int getIntraCommSize(void) {return clientSize ;}
49      int getIntraCommRank(void) {return clientRank ;}
50      /*! set the associated server (dual chanel client/server) */     
51      void setAssociatedServer(CContextServer* associatedServer) { associatedServer=associatedServer_;}
52      /*! get the associated server (dual chanel client/server) */     
53      CContextServer* getAssociatedServer(void) { return associatedServer_;}
54     
55
56
57      virtual ETransport getType(void) = 0 ;
58      // Send event to server
59      virtual void sendEvent(CEventClient& event)=0;
60      virtual void eventLoop(void)=0 ;
61      virtual void releaseBuffers(void)=0;
62      virtual bool havePendingRequests(void)=0;
63
64
65      virtual bool isNotifiedFinalized(void)=0 ;
66      virtual void finalize(void)=0;
67
68      virtual void setBufferSize(const std::map<int,StdSize>& mapSize)=0;
69
70      public: 
71        static CContextClient* ONLINE(void) { return reinterpret_cast<CContextClient*>(0xdeaddead);}
72    protected:
73
74      CContext* context_; //!< Context for client
75
76      CContext* parentServer; //!< Context for server (Only used in attached mode)
77
78      int clientRank; //!< Rank of current client
79
80      int clientSize; //!< Size of client group
81
82      int serverSize; //!< Size of server group
83
84      MPI_Comm interComm; //!< Communicator of server group (interCommunicator)
85
86      MPI_Comm intraComm; //!< Communicator of client group
87     
88      std::list<int> ranksServerLeader; //!< List of server ranks for which the client is leader
89
90      std::list<int> ranksServerNotLeader; //!< List of server ranks for which the client is not leader
91
92      size_t hashId_ ; //!< hash id on the context client that will be used for context server to identify the remote calling context client.
93
94      CContextServer* associatedServer_ ; //!< The server associated to the pair client/server
95  };
96
97  template<>
98  CContextClient* CContextClient::getNew<CContextClient::generic>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
99 
100  template<>
101  CContextClient* CContextClient::getNew<CContextClient::oneSided>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
102
103  template<>
104  CContextClient* CContextClient::getNew<CContextClient::legacy>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
105
106  template<>
107  CContextClient* CContextClient::getNew<CContextClient::online>(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer) ;
108
109
110}
111
112#endif // __CONTEXT_CLIENT_HPP__
Note: See TracBrowser for help on using the repository browser.