source: XIOS/dev/dev_ym/XIOS_COUPLING/src/context_client.hpp @ 2291

Last change on this file since 2291 was 2260, checked in by ymipsl, 3 years ago

Improvment of one sided protocol

  • removed latency
  • solve dead-lock

YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 5.1 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 CContextClient
26  {
27    public:
28      // Contructor
29      CContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0);
30
31      // Send event to server
32      void sendEvent(CEventClient& event);
33      void waitEvent(list<int>& ranks);
34      void waitEvent_old(list<int>& ranks);
35
36      // Functions to set/get buffers
37      bool getBuffers(const size_t timeLine, const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, bool nonBlocking = false);
38      void newBuffer(int rank);
39      bool checkBuffers(list<int>& ranks);
40      bool checkBuffers(void);
41      void releaseBuffers(void);
42      bool havePendingRequests(void);
43      bool havePendingRequests(list<int>& ranks) ;
44
45      bool isServerLeader(void) const;
46      bool isServerNotLeader(void) const;
47      const std::list<int>& getRanksServerLeader(void) const;
48      const std::list<int>& getRanksServerNotLeader(void) const;
49
50  /*!
51   * Check if the attached mode is used.
52   *
53   * \return true if and only if attached mode is used
54   */
55      bool isAttachedModeEnabled() const { return isAttached_ ; } 
56
57      static void computeLeader(int clientRank, int clientSize, int serverSize,
58                                std::list<int>& rankRecvLeader,
59                                std::list<int>& rankRecvNotLeader);
60
61      // Close and finalize context client
62//      void closeContext(void);  Never been implemented.
63      bool isNotifiedFinalized(void) ;
64      void finalize(void);
65
66      void setBufferSize(const std::map<int,StdSize>& mapSize);
67
68      int getRemoteSize(void) {return serverSize;}
69      int getServerSize(void) {return serverSize;}
70      MPI_Comm getIntraComm(void)  {return intraComm ;} 
71      int getIntraCommSize(void) {return clientSize ;}
72      int getIntraCommRank(void) {return clientRank ;}
73
74      /*! set the associated server (dual chanel client/server) */     
75      void setAssociatedServer(CContextServer* associatedServer) { associatedServer=associatedServer_;}
76      /*! get the associated server (dual chanel client/server) */     
77      CContextServer* getAssociatedServer(void) { return associatedServer_;}
78      void setGrowableBuffer(void) { isGrowableBuffer_=true;}
79      void setFixedBuffer(void) { isGrowableBuffer_=false;}
80    public:
81      CContext* context_; //!< Context for client
82
83      size_t timeLine; //!< Timeline of each event
84
85      int clientRank; //!< Rank of current client
86
87      int clientSize; //!< Size of client group
88
89      int serverSize; //!< Size of server group
90
91      MPI_Comm interComm; //!< Communicator of server group (interCommunicator)
92
93      MPI_Comm interCommMerged_; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication.
94      MPI_Comm commSelf_ ; //!< Communicator for proc alone from interCommMerged
95
96      MPI_Comm intraComm; //!< Communicator of client group
97
98      map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers
99
100      bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used.
101
102      size_t hashId_ ; //!< hash id on the context client that will be used for context server to identify the remote calling context client.
103
104    private:
105      void lockBuffers(list<int>& ranks) ;
106      void unlockBuffers(list<int>& ranks) ;
107     
108      //! Mapping of server and buffer size for each connection to server
109      std::map<int,StdSize> mapBufferSize_;
110      //! Maximum event sizes estimated for each connection to server
111      std::map<int,StdSize> maxEventSizes;
112      //! Maximum number of events that can be buffered
113      StdSize maxBufferedEvents;
114
115      //! Context for server (Only used in attached mode)
116      CContext* parentServer;
117
118      //! List of server ranks for which the client is leader
119      std::list<int> ranksServerLeader;
120
121      //! List of server ranks for which the client is not leader
122      std::list<int> ranksServerNotLeader;
123
124      std::map<int, MPI_Comm> winComm_ ; //! Window communicators
125      std::map<int, std::vector<MPI_Win> >windows_ ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2]
126      bool isAttached_ ;
127      CContextServer* associatedServer_ ; //!< The server associated to the pair client/server
128      bool isGrowableBuffer_ = true ;
129
130      double latency_=0e-2 ;
131  };
132}
133
134#endif // __CONTEXT_CLIENT_HPP__
Note: See TracBrowser for help on using the repository browser.