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

Last change on this file since 576 was 569, checked in by mhnguyen, 9 years ago

Correct some bugs on discovering server index and do some code cleanings

+) Add some checking functions to make sure mpi_isend and mpi_irecv work correctly
+) Add comments to code
+) Remove some redundant code and comments

Test
+) On Curie
+) The new functions are tested in test_new_features.f90. Test_client and test_complete work like before
+) Test cases:

  • 3 dimension grid with: 1 domain, 1 axis
  • 3 dimension grid with: 3 axis
  • Attached and connected

+) All pass and results are correct

TODO:
+) Fix zoom bug with grid composed of only one axis

File size: 2.4 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 "xmlioserver_spl.hpp"
13#include "array_new.hpp"
14#include "mpi.hpp"
15
16namespace xios {
17
18/*!
19  \class CClientServerMapping
20  This class computes index of data which are sent to server as well as index of data
21on server side.
22*/
23class 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    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__
Note: See TracBrowser for help on using the repository browser.