source: XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/context_client.hpp @ 1547

Last change on this file since 1547 was 1547, checked in by ymipsl, 4 years ago

New communication protocol between clients and servers, using hybrid mode of p2p mixt with one_sided communication in order to avoid dead-locking. The constraint of the maximum number of event that can be bufferized on client side is released.

Dev branch is created to be tested before merging.

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: 3.7 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
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
35      // Functions to set/get buffers
36      bool getBuffers(const size_t timeLine, const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, bool nonBlocking = false);
37      void newBuffer(int rank);
38      bool checkBuffers(list<int>& ranks);
39      bool checkBuffers(void);
40      void releaseBuffers(void);
41      bool havePendingRequests(void);
42
43      bool isServerLeader(void) const;
44      bool isServerNotLeader(void) const;
45      const std::list<int>& getRanksServerLeader(void) const;
46      const std::list<int>& getRanksServerNotLeader(void) const;
47
48      bool isAttachedModeEnabled() const;
49
50      static void computeLeader(int clientRank, int clientSize, int serverSize,
51                                std::list<int>& rankRecvLeader,
52                                std::list<int>& rankRecvNotLeader);
53
54      // Close and finalize context client
55//      void closeContext(void);  Never been implemented.
56      void finalize(void);
57
58      void setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize);
59
60    public:
61      CContext* context; //!< Context for client
62
63      size_t timeLine; //!< Timeline of each event
64
65      int clientRank; //!< Rank of current client
66
67      int clientSize; //!< Size of client group
68
69      int serverSize; //!< Size of server group
70
71      MPI_Comm interComm; //!< Communicator of server group (interCommunicator)
72
73      MPI_Comm interCommMerged; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication.
74
75      MPI_Comm intraComm; //!< Communicator of client group
76
77      MPI_Comm commSelf; //!< Communicator of the client alone. Needed to create a new communicator between 1 proc client and 1 proc server for one sided communication
78
79      map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers
80
81      bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used.
82
83    private:
84      void lockBuffers(list<int>& ranks) ;
85      void unlockBuffers(list<int>& ranks) ;
86     
87      //! Mapping of server and buffer size for each connection to server
88      std::map<int,StdSize> mapBufferSize_;
89      //! Maximum event sizes estimated for each connection to server
90      std::map<int,StdSize> maxEventSizes;
91      //! Maximum number of events that can be buffered
92      StdSize maxBufferedEvents;
93
94      //! Context for server (Only used in attached mode)
95      CContext* parentServer;
96
97      //! List of server ranks for which the client is leader
98      std::list<int> ranksServerLeader;
99
100      //! List of server ranks for which the client is not leader
101      std::list<int> ranksServerNotLeader;
102
103  };
104}
105
106#endif // __CONTEXT_CLIENT_HPP__
Note: See TracBrowser for help on using the repository browser.