Ignore:
Timestamp:
03/10/15 10:49:13 (9 years ago)
Author:
mhnguyen
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/client_server_mapping_distributed.hpp

    r568 r569  
     1/*! 
     2   \file client_server_mapping.hpp 
     3   \author Ha NGUYEN 
     4   \since 27 Feb 2015 
     5   \date 09 Mars 2015 
     6 
     7   \brief Mapping between index client and server. 
     8   Clients pre-calculate all information of server distribution. 
     9 */ 
     10 
    111#ifndef __XIOS_CLIENT_SERVER_MAPPING_DISTRIBUTED_HPP__ 
    212#define __XIOS_CLIENT_SERVER_MAPPING_DISTRIBUTED_HPP__ 
     
    1020namespace xios 
    1121{ 
    12  
     22/*! 
     23  \class CClientServerMappingDistributed 
     24  This class computes index of data which are sent to server as well as index of data 
     25on server side with a distributed alogrithm. Each client has a piece of information about the distribution 
     26of servers. To find out all these info, first of all, all client join a discovering process in which each client 
     27announces the others about the info they have as well as demand others info they are lacked of. After this process, 
     28each client has enough info to decide to which client it need to send a demand for corresponding server of a global index. 
     29The alogrithm depends on hashed index. 
     30*/ 
    1331class CClientServerMappingDistributed : public CClientServerMapping 
    1432{ 
     
    1735    CClientServerMappingDistributed(const boost::unordered_map<size_t,int>& globalIndexOfServer, 
    1836                                    const MPI_Comm& clientIntraComm); 
     37 
     38    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient); 
    1939 
    2040    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
     
    2545 
    2646  protected: 
     47    // Redistribute global index and server index among clients 
    2748    void computeDistributedServerIndex(const boost::unordered_map<size_t,int>& globalIndexOfServer, 
    2849                                       const MPI_Comm& clientIntraComm); 
    2950 
    30     void processReceivedRequest(unsigned long* buffIndexGlobal, int* buffIndexServer, int count); 
    31  
    32     void testSendRequest(std::list<MPI_Request>& sendRequest); 
    33  
    34     int computeBuffCount(MPI_Request& requestRecvIndexGlobal, MPI_Request& requestRecvIndexServer); 
    35  
    36     void computeHashIndex(); 
    37  
    38 //    void sendIndexServerToClients(std::map<int, std::vector<int> >& indexServer, 
    39 //                                  const MPI_Comm& clientIntraComm, 
    40 //                                  std::list<MPI_Request>& requestSendIndexServer); 
    41  
    42 //    void sendIndexGlobalToClients(std::map<int, std::vector<size_t> >& indexGlobal, 
    43 //                                  const MPI_Comm& clientIntraComm, 
    44 //                                  std::list<MPI_Request>& requestSendIndexGlobal); 
    45  
     51    // Send server index to clients 
    4652    void sendIndexServerToClients(int clientDestRank, std::vector<int>& indexServer, 
    4753                                  const MPI_Comm& clientIntraComm, std::list<MPI_Request>& requestSendIndexServer); 
    4854 
     55    // Send global index to clients 
    4956    void sendIndexGlobalToClients(int clientDestRank, std::vector<size_t>& indexGlobal, 
    5057                                  const MPI_Comm& clientIntraComm, std::list<MPI_Request>& requestSendIndexGlobal); 
    5158 
    52     void resetRequestAndCount(); 
     59    // Verify sending request 
     60    void testSendRequest(std::list<MPI_Request>& sendRequest); 
    5361 
     62    // Process request 
     63    void processReceivedRequest(unsigned long* buffIndexGlobal, int* buffIndexServer, int count); 
     64 
     65    // Probe and receive message of global index 
    5466    void probeIndexGlobalMessageFromClients(unsigned long* recvIndexGlobalBuff, int recvNbIndexCount); 
    5567 
     68    // Probe and receive message of server index 
    5669    void probeIndexServerMessageFromClients(int* recvIndexServerBuff, int recvNbIndexCount); 
    5770 
     71    // Compute range of hashing 
     72    void computeHashIndex(); 
     73 
     74    // Compute size of receiving buffer for global index 
    5875    int computeBuffCountIndexGlobal(MPI_Request& requestRecv); 
    5976 
     77    // Compute size of receiving buffer for server index 
    6078    int computeBuffCountIndexServer(MPI_Request& requestRecv); 
     79 
     80    // Reset request map 
     81    void resetReceivingRequestAndCount(); 
     82 
    6183  private: 
     84    //! Mapping of global index to the corresponding server 
    6285    boost::unordered_map<size_t,int> globalIndexToServerMapping_; 
    6386 
     87    //! Bounds of hash index 
     88    std::vector<size_t> indexClientHash_; 
     89 
     90    //! Number of client 
     91    int nbClient_; 
     92 
     93    //! Rank of client 
     94    int clientRank_; 
     95 
     96    //! Counting of buffer for receiving global index 
     97    int countIndexGlobal_; 
     98 
     99    //! Counting of buffer for receiving server index 
     100    int countIndexServer_; 
     101 
     102    //! intracommuntion of clients 
     103    MPI_Comm clientIntraComm_; 
     104 
     105    //! Request returned by MPI_IRecv function about global index 
    64106    std::map<int, MPI_Request> requestRecvIndexGlobal_; 
    65107 
     108    //! Request returned by MPI_IRecv function about index of server 
    66109    std::map<int, MPI_Request> requestRecvIndexServer_; 
    67110 
    68     std::vector<size_t> indexClientHash_; 
    69  
    70     int nbClient_; 
    71  
    72     int clientRank_; 
    73  
    74     int countIndexGlobal_; 
    75  
    76     int countIndexServer_; 
    77  
    78     MPI_Comm clientIntraComm_; 
    79  
     111    //! Mapping client rank and the beginning position of receiving buffer for message of global index from this client 
    80112    std::map<int, unsigned long*> indexGlobalBuffBegin_; 
    81113 
     114    //! Mapping client rank and the begining position of receiving buffer for message of server index from this client 
    82115    std::map<int, int*> indexServerBuffBegin_; 
    83  
    84116}; 
    85117 
Note: See TracChangeset for help on using the changeset viewer.