source: XIOS/dev/branch_yushan_merged/src/context_client.hpp @ 1205

Last change on this file since 1205 was 1205, checked in by yushan, 3 years ago

branch merged with trunk @1200

  • 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
RevLine 
[300]1#ifndef __CONTEXT_CLIENT_HPP__
2#define __CONTEXT_CLIENT_HPP__
3
[591]4#include "xios_spl.hpp"
[300]5#include "buffer_out.hpp"
[697]6#include "buffer_in.hpp"
[300]7#include "buffer_client.hpp"
8#include "event_client.hpp"
[697]9#include "event_server.hpp"
[382]10#include "mpi.hpp"
[697]11#include "registry.hpp"
[300]12
[335]13namespace xios
[300]14{
[595]15  class CContext;
[509]16
[512]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  */
[300]25  class CContextClient
26  {
27    public:
[595]28      // Contructor
[1134]29      CContextClient(CContext* parent, ep_lib::MPI_Comm intraComm, ep_lib::MPI_Comm interComm, CContext* parentServer = 0);
[300]30
[595]31      // Send event to server
32      void sendEvent(CEventClient& event);
[1033]33      bool sendTemporarilyBufferedEvent();
[595]34      void waitEvent(list<int>& ranks);
[300]35
[1033]36      // Functions to set/get buffers
37      bool getBuffers(const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers, bool nonBlocking = false);
[595]38      void newBuffer(int rank);
39      bool checkBuffers(list<int>& ranks);
40      bool checkBuffers(void);
41      void releaseBuffers(void);
[512]42
[595]43      bool isServerLeader(void) const;
[988]44      bool isServerNotLeader(void) const;
[595]45      const std::list<int>& getRanksServerLeader(void) const;
[988]46      const std::list<int>& getRanksServerNotLeader(void) const;
[512]47
[704]48      bool isAttachedModeEnabled() const;
49
[1033]50      bool hasTemporarilyBufferedEvent() const { return !tmpBufferedEvent.isEmpty(); };
51
[595]52      // Close and finalize context client
53      void closeContext(void);
54      void finalize(void);
[300]55
[917]56      void setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize);
[726]57
[512]58    public:
[595]59      CContext* context; //!< Context for client
[509]60
[595]61      size_t timeLine; //!< Timeline of each event
[509]62
[595]63      int clientRank; //!< Rank of current client
[300]64
[595]65      int clientSize; //!< Size of client group
[300]66
[595]67      int serverSize; //!< Size of server group
[300]68
[1134]69      ep_lib::MPI_Comm interComm; //!< Communicator of server group
[300]70
[1134]71      ep_lib::MPI_Comm intraComm; //!< Communicator of client group
[300]72
[595]73      map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers
[300]74
[512]75    private:
76      //! Mapping of server and buffer size for each connection to server
[595]77      std::map<int,StdSize> mapBufferSize_;
[1205]78      //! Maximum event sizes estimated for each connection to server
79      std::map<int,StdSize> maxEventSizes;
[917]80      //! Maximum number of events that can be buffered
81      StdSize maxBufferedEvents;
[300]82
[1033]83      struct {
84        std::list<int> ranks, sizes;
85        std::list<CBufferOut*> buffers;
86
87        bool isEmpty() const { return ranks.empty(); };
88        void clear() {
89          ranks.clear();
90          sizes.clear();
91
92          for (std::list<CBufferOut*>::iterator it = buffers.begin(); it != buffers.end(); it++)
93            delete *it;
94
95          buffers.clear();
96        };
97      } tmpBufferedEvent; //! Event temporarily buffered (used only on the server)
98
[512]99      //! Context for server (Only used in attached mode)
100      CContext* parentServer;
101
[595]102      //! List of server ranks for which the client is leader
103      std::list<int> ranksServerLeader;
104
[988]105      //! List of server ranks for which the client is not leader
106      std::list<int> ranksServerNotLeader;
107
[512]108    public: // Some function should be removed in the future
[595]109      //    void registerEvent(CEventClient& event);
110//    list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes);
111//    bool locked;
112//    set<int> connectedServer;
[512]113
[595]114  };
[512]115}
116
117#endif // __CONTEXT_CLIENT_HPP__
Note: See TracBrowser for help on using the repository browser.