1 | /*! |
---|
2 | \file client_server_mapping.hpp |
---|
3 | \author Ha NGUYEN |
---|
4 | \since 04 Feb 2015 |
---|
5 | \date 09 Mars 2015 |
---|
6 | |
---|
7 | \brief Mapping between index client and server. |
---|
8 | */ |
---|
9 | #ifndef __XIOS_CLIENT_SERVER_MAPPING_HPP__ |
---|
10 | #define __XIOS_CLIENT_SERVER_MAPPING_HPP__ |
---|
11 | |
---|
12 | #include "xios_spl.hpp" |
---|
13 | #include "array_new.hpp" |
---|
14 | #include "mpi.hpp" |
---|
15 | |
---|
16 | namespace xios { |
---|
17 | |
---|
18 | /*! |
---|
19 | \class CClientServerMapping |
---|
20 | This class computes index of data which are sent to server as well as index of data |
---|
21 | on server side. |
---|
22 | */ |
---|
23 | class CClientServerMapping |
---|
24 | { |
---|
25 | public: |
---|
26 | /** Default constructor */ |
---|
27 | CClientServerMapping(); |
---|
28 | |
---|
29 | /** Default destructor */ |
---|
30 | virtual ~CClientServerMapping(); |
---|
31 | |
---|
32 | // Only need global index on client to calculate mapping (supposed client has info of distribution) |
---|
33 | virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) = 0; |
---|
34 | |
---|
35 | // // In case of computing local index on client sent to server |
---|
36 | // virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, |
---|
37 | // const CArray<int,1>& localIndexOnClient) = 0; |
---|
38 | |
---|
39 | // Simple case, global index on client and index on servers |
---|
40 | virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, |
---|
41 | const std::vector<CArray<size_t,1>* >& globalIndexOnServer); |
---|
42 | |
---|
43 | static std::map<int,int> computeConnectedClients(int nbServer, int nbClient, |
---|
44 | MPI_Comm& clientIntraComm, |
---|
45 | const std::vector<int>& connectedServerRank); |
---|
46 | |
---|
47 | const std::map<int, std::vector<size_t> >& getGlobalIndexOnServer() const; |
---|
48 | const std::map<int, std::vector<int> >& getLocalIndexSendToServer() const; |
---|
49 | |
---|
50 | protected: |
---|
51 | void defaultComputeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, |
---|
52 | const std::vector<CArray<size_t,1>* >& globalIndexOnServer, |
---|
53 | const CArray<int,1>* localIndexOnClient = 0); |
---|
54 | |
---|
55 | protected: |
---|
56 | //! Global index of data on SERVER, which are calculated by client(s) |
---|
57 | std::map<int, std::vector<size_t> > indexGlobalOnServer_; |
---|
58 | |
---|
59 | //! Index of the local data which will be sent to the corresponding server(s) |
---|
60 | std::map<int, std::vector<int> > localIndexSend2Server_; |
---|
61 | |
---|
62 | //!< Number of clients connected to a server |
---|
63 | std::map<int, int> connectedClients_; |
---|
64 | }; |
---|
65 | |
---|
66 | } // namespace xios |
---|
67 | #endif // __XIOS_CLIENT_SERVER_MAPPING_HPP__ |
---|