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

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

Big update on on going work related to data distribution and transfer between clients and servers.

  • move all related file into distribution directorie
  • implement the concept of data "View"
  • implement the concept of "connector" which make the data transfer between 2 differents "Views"

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: 4.8 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;
[1853]16  class CContextServer ;
[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
[1639]29      CContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0);
[300]30
[595]31      // Send event to server
32      void sendEvent(CEventClient& event);
33      void waitEvent(list<int>& ranks);
[1761]34      void waitEvent_old(list<int>& ranks);
[300]35
[1054]36      // Functions to set/get buffers
[1757]37      bool getBuffers(const size_t timeLine, 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);
[1130]42      bool havePendingRequests(void);
[512]43
[595]44      bool isServerLeader(void) const;
[1021]45      bool isServerNotLeader(void) const;
[595]46      const std::list<int>& getRanksServerLeader(void) const;
[1021]47      const std::list<int>& getRanksServerNotLeader(void) const;
[512]48
[1761]49  /*!
50   * Check if the attached mode is used.
51   *
52   * \return true if and only if attached mode is used
53   */
54      bool isAttachedModeEnabled() const { return isAttached_ ; } 
[704]55
[1232]56      static void computeLeader(int clientRank, int clientSize, int serverSize,
57                                std::list<int>& rankRecvLeader,
58                                std::list<int>& rankRecvNotLeader);
59
[595]60      // Close and finalize context client
[1054]61//      void closeContext(void);  Never been implemented.
[1757]62      bool isNotifiedFinalized(void) ;
[595]63      void finalize(void);
[300]64
[917]65      void setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize);
[726]66
[1784]67      int getRemoteSize(void) {return serverSize;}
68      int getServerSize(void) {return serverSize;}
[1918]69      MPI_Comm getIntraComm(void)  {return intraComm ;} 
70      int getIntraCommSize(void) {return clientSize ;}
71      int getIntraCommRank(void) {return clientRank ;}
[1853]72
73      /*! set the associated server (dual chanel client/server) */     
74      void setAssociatedServer(CContextServer* associatedServer) { associatedServer=associatedServer_;}
75      /*! get the associated server (dual chanel client/server) */     
76      CContextServer* getAssociatedServer(void) { return associatedServer_;}
77
[512]78    public:
[595]79      CContext* context; //!< Context for client
[509]80
[595]81      size_t timeLine; //!< Timeline of each event
[509]82
[595]83      int clientRank; //!< Rank of current client
[300]84
[595]85      int clientSize; //!< Size of client group
[300]86
[595]87      int serverSize; //!< Size of server group
[300]88
[1757]89      MPI_Comm interComm; //!< Communicator of server group (interCommunicator)
[300]90
[1757]91      MPI_Comm interCommMerged; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication.
92
[1639]93      MPI_Comm intraComm; //!< Communicator of client group
[300]94
[1757]95      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
96
[1158]97      map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers
[300]98
[1757]99      bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used.
100
[512]101    private:
[1757]102      void lockBuffers(list<int>& ranks) ;
103      void unlockBuffers(list<int>& ranks) ;
104     
[512]105      //! Mapping of server and buffer size for each connection to server
[595]106      std::map<int,StdSize> mapBufferSize_;
[1201]107      //! Maximum event sizes estimated for each connection to server
108      std::map<int,StdSize> maxEventSizes;
[917]109      //! Maximum number of events that can be buffered
110      StdSize maxBufferedEvents;
[300]111
[512]112      //! Context for server (Only used in attached mode)
113      CContext* parentServer;
114
[595]115      //! List of server ranks for which the client is leader
116      std::list<int> ranksServerLeader;
117
[1021]118      //! List of server ranks for which the client is not leader
119      std::list<int> ranksServerNotLeader;
120
[1757]121      std::vector<std::vector<MPI_Win> >windows ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2]
[1761]122      bool isAttached_ ;
[1853]123      CContextServer* associatedServer_ ; //!< The server associated to the pair client/server
[1757]124
[595]125  };
[512]126}
127
128#endif // __CONTEXT_CLIENT_HPP__
Note: See TracBrowser for help on using the repository browser.