#ifndef __LEGACY_CONTEXT_CLIENT_HPP__ #define __LEGACY_CONTEXT_CLIENT_HPP__ #include "xios_spl.hpp" #include "buffer_out.hpp" #include "buffer_in.hpp" #include "buffer_client.hpp" #include "event_client.hpp" #include "event_server.hpp" #include "mpi.hpp" #include "registry.hpp" #include "context_client.hpp" namespace xios { class CContext; class CContextServer ; /*! \class CLegacyContextClient A context can be both on client and on server side. In order to differenciate the role of context on each side, e.x client sending events, server receiving and processing events, there is a need of concrete "context" classes for both sides. CLegacyContextClient processes and sends events from client to server where CContextServer receives these events and processes them. */ class CLegacyContextClient : public CContextClient { public: // Contructor CLegacyContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0); // Send event to server void sendEvent(CEventClient& event); void eventLoop(void) ; void releaseBuffers(void); bool havePendingRequests(void); bool isNotifiedFinalized(void) ; void finalize(void); void setBufferSize(const std::map& mapSize); private: // Functions to set/get buffers bool getBuffers(const size_t timeLine, const list& serverList, const list& sizeList, list& retBuffers, bool nonBlocking = false); void newBuffer(int rank); bool checkBuffers(list& ranks); bool checkBuffers(void); void callGlobalEventLoop() ; bool havePendingRequests(list& ranks) ; void setGrowableBuffer(void) { isGrowableBuffer_=true;} void setFixedBuffer(void) { isGrowableBuffer_=false;} void lockBuffers(list& ranks) ; void unlockBuffers(list& ranks) ; size_t timeLine; //!< Timeline of each event MPI_Comm interCommMerged_; //!< Communicator of the client group + server group (intraCommunicator) needed for one sided communication. MPI_Comm commSelf_ ; //!< Communicator for proc alone from interCommMerged map buffers; //!< Buffers for connection to servers bool pureOneSided ; //!< if true, client will communicated with servers only trough one sided communication. Otherwise the hybrid mode P2P /One sided is used. //! Mapping of server and buffer size for each connection to server std::map mapBufferSize_; //! Maximum event sizes estimated for each connection to server std::map maxEventSizes; //! Maximum number of events that can be buffered StdSize maxBufferedEvents; std::map winComm_ ; //! Window communicators std::map >windows_ ; //! one sided mpi windows to expose client buffers to servers == windows[nbServers][2] bool isGrowableBuffer_ = true ; double latency_=0e-2 ; bool locked_ = false ; //!< The context client is locked to avoid recursive checkBuffer }; } #endif // __LEGACY_CONTEXT_CLIENT_HPP__