source: XIOS3/trunk/src/transport/legacy_context_client.hpp @ 2547

Last change on this file since 2547 was 2547, checked in by ymipsl, 9 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: 3.4 KB
Line 
1#ifndef __LEGACY_CONTEXT_CLIENT_HPP__
2#define __LEGACY_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#include "context_client.hpp"
13#include "window_dynamic.hpp"
14
15namespace xios
16{
17  class CContext;
18  class CContextServer ;
19  /*!
20  \class CLegacyContextClient
21  A context can be both on client and on server side. In order to differenciate the role of
22  context on each side, e.x client sending events, server receiving and processing events, there is a need of
23  concrete "context" classes for both sides.
24  CLegacyContextClient processes and sends events from client to server where CContextServer receives these events
25  and processes them.
26  */
27  class CLegacyContextClient : public CContextClient
28  {
29    public:
30      // Contructor
31      CLegacyContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0);
32
33      // Send event to server
34      ETransport getType(void) {return legacy ;}
35      void sendEvent(CEventClient& event);
36      void eventLoop(void) ;
37      void releaseBuffers(void);
38      bool havePendingRequests(void);
39
40      bool isNotifiedFinalized(void) ;
41      void finalize(void);
42
43      void setBufferSize(const std::map<int,StdSize>& mapSize);
44
45
46    private:
47
48      // Functions to set/get buffers
49      void getBuffers(const size_t timeLine, const list<int>& serverList, const list<int>& sizeList, list<CBufferOut*>& retBuffers);
50      void newBuffer(int rank);
51      bool checkAttachWindows(CClientBuffer* buffer , int rank, map<int,MPI_Request>& attachList) ;
52      bool checkBuffers(list<int>& ranks);
53      bool checkBuffers(void);
54      void callGlobalEventLoop() ;
55      void yield(void) ;
56      void synchronize(void) ;
57      bool havePendingRequests(list<int>& ranks) ;
58      void setGrowableBuffer(void) { isGrowableBuffer_=true;}
59      void setFixedBuffer(void) { isGrowableBuffer_=false;}
60      void lockBuffers(list<int>& ranks) ;
61      void unlockBuffers(list<int>& ranks) ;
62
63
64      size_t timeLine; //!< Timeline of each event
65
66      MPI_Comm interCommMerged_; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication.
67      MPI_Comm commSelf_ ; //!< Communicator for proc alone from interCommMerged
68
69      map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers
70
71      bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used.
72     
73      //! Mapping of server and buffer size for each connection to server
74      std::map<int,StdSize> mapBufferSize_;
75      //! Maximum event sizes estimated for each connection to server
76      std::map<int,StdSize> maxEventSizes;
77      //! Maximum number of events that can be buffered
78      StdSize maxBufferedEvents;
79
80      std::map<int, MPI_Comm> winComm_ ; //! Window communicators
81      std::map<int, std::vector<CWindowDynamic*> >windows_ ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2]
82      bool isGrowableBuffer_ = true ;
83
84      double latency_=0e-2 ;
85
86      bool locked_ = false ; //!< The context client is locked to avoid recursive checkBuffer
87      shared_ptr<CEventScheduler> eventScheduler_ ;
88  };
89}
90
91#endif // __LEGACY_CONTEXT_CLIENT_HPP__
Note: See TracBrowser for help on using the repository browser.