source: XIOS/trunk/src/client_server_mapping.hpp @ 829

Last change on this file since 829 was 829, checked in by mhnguyen, 5 years ago

Refactoring transformation code

+) On exchanging information during transformation, not only global index are sent but also local index
+) Correct a bug in distributed hash table (dht)
+) Add new type for dht
+) Clean up some redundant codes

Test
+) On Curie
+) Every test passes
+) Code runs faster in some cases (up to 30%)

File size: 2.3 KB
Line 
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#include <boost/unordered_map.hpp>
16
17namespace xios {
18
19/*!
20  \class CClientServerMapping
21  This class computes index of data which are sent to server as well as index of data
22on server side.
23*/
24class CClientServerMapping
25{
26public:
27  typedef boost::unordered_map<int, std::vector<size_t> > GlobalIndexMap;
28  typedef std::map<int, std::vector<int> > LocalIndexMap;
29  public:
30    /** Default constructor */
31    CClientServerMapping();
32
33    /** Default destructor */
34    virtual ~CClientServerMapping();
35
36    // Only need global index on client to calculate mapping (supposed client has info of distribution)
37    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) = 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 GlobalIndexMap& getGlobalIndexOnServer() const;
48//    const LocalIndexMap& 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    GlobalIndexMap indexGlobalOnServer_;
58
59    //! Index of the local data which will be sent to the corresponding server(s)
60//    LocalIndexMap  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__
Note: See TracBrowser for help on using the repository browser.