Ignore:
Timestamp:
03/23/16 16:11:01 (8 years ago)
Author:
mhnguyen
Message:

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

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/client_server_mapping.cpp

    r569 r829  
    1212 
    1313CClientServerMapping::CClientServerMapping() 
    14   : indexGlobalOnServer_(), localIndexSend2Server_(), connectedClients_() 
     14  : indexGlobalOnServer_(), connectedClients_() //, localIndexSend2Server_() 
    1515{ 
    1616} 
     
    2020} 
    2121 
    22 /*! 
    23   Compute mapping global index of server which client sends to. 
    24   \param [in] globalIndexOnClient global index on client 
    25   \param [in] globalIndexServer global index of servers 
    26 */ 
    27 void CClientServerMapping::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
    28                                                      const std::vector<CArray<size_t,1>* >& globalIndexServer) 
    29 { 
    30   defaultComputeServerIndexMapping(globalIndexOnClient, globalIndexServer); 
    31 } 
     22///*! 
     23//  Compute mapping global index of server which client sends to. 
     24//  \param [in] globalIndexOnClient global index on client 
     25//  \param [in] globalIndexServer global index of servers 
     26//*/ 
     27//void CClientServerMapping::computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
     28//                                                     const std::vector<CArray<size_t,1>* >& globalIndexServer) 
     29//{ 
     30//  defaultComputeServerIndexMapping(globalIndexOnClient, globalIndexServer); 
     31//} 
    3232 
    33 /*! 
    34    Compute index of data which are sent to server and index global on server side 
    35    \param [in] globalIndexOnClient global index of data on client 
    36    \param [in] globalIndexServer global index of server(s) 
    37    \param [in] localIndexOnClient local index of data on client which are sent to server 
    38 */ 
    39 void CClientServerMapping::defaultComputeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
    40                                                             const std::vector<CArray<size_t,1>* >& globalIndexServer, 
    41                                                             const CArray<int,1>* localIndexOnClient) 
    42 { 
    43   int nServer = globalIndexServer.size(); 
    44   std::vector<CArray<size_t,1>::const_iterator> itBegin(nServer), itEnd(nServer), it(nServer); 
    45   for (int i = 0; i < nServer; ++i) 
    46   { 
    47     itBegin[i] = it[i] = globalIndexServer[i]->begin(); 
    48     itEnd[i]   = globalIndexServer[i]->end(); 
    49   } 
    50  
    51   size_t ssize = globalIndexOnClient.numElements(); 
    52   for (int i = 0; i < ssize; ++i) 
    53   { 
    54     for (int j = 0; j < nServer; ++j) 
    55     { 
    56       // Just temporarily, it's bad. 
    57       if (std::binary_search(itBegin[j], itEnd[j], globalIndexOnClient(i))) 
    58       { 
    59         // Just try to calculate local index server on client side 
    60         (indexGlobalOnServer_[j]).push_back((globalIndexOnClient)(i)); 
    61         if (0 != localIndexOnClient) (localIndexSend2Server_[j]).push_back((*localIndexOnClient)(i)); 
    62         else 
    63           (localIndexSend2Server_[j]).push_back(i); 
    64         continue; 
    65       } 
    66     } 
    67   } 
    68 } 
     33///*! 
     34//   Compute index of data which are sent to server and index global on server side 
     35//   \param [in] globalIndexOnClient global index of data on client 
     36//   \param [in] globalIndexServer global index of server(s) 
     37//   \param [in] localIndexOnClient local index of data on client which are sent to server 
     38//*/ 
     39//void CClientServerMapping::defaultComputeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient, 
     40//                                                            const std::vector<CArray<size_t,1>* >& globalIndexServer, 
     41//                                                            const CArray<int,1>* localIndexOnClient) 
     42//{ 
     43//  int nServer = globalIndexServer.size(); 
     44//  std::vector<CArray<size_t,1>::const_iterator> itBegin(nServer), itEnd(nServer), it(nServer); 
     45//  for (int i = 0; i < nServer; ++i) 
     46//  { 
     47//    itBegin[i] = it[i] = globalIndexServer[i]->begin(); 
     48//    itEnd[i]   = globalIndexServer[i]->end(); 
     49//  } 
     50// 
     51//  size_t ssize = globalIndexOnClient.numElements(); 
     52//  for (int i = 0; i < ssize; ++i) 
     53//  { 
     54//    for (int j = 0; j < nServer; ++j) 
     55//    { 
     56//      // Just temporarily, it's bad. 
     57//      if (std::binary_search(itBegin[j], itEnd[j], globalIndexOnClient(i))) 
     58//      { 
     59//        // Just try to calculate local index server on client side 
     60//        (indexGlobalOnServer_[j]).push_back((globalIndexOnClient)(i)); 
     61//        if (0 != localIndexOnClient) (localIndexSend2Server_[j]).push_back((*localIndexOnClient)(i)); 
     62//        else 
     63//          (localIndexSend2Server_[j]).push_back(i); 
     64//        continue; 
     65//      } 
     66//    } 
     67//  } 
     68//} 
    6969 
    7070/*! 
     
    134134} 
    135135 
    136 /*! 
    137   Return local index of data that is send to server 
    138   \return mapping of server rank and local index of sending data on the client 
    139 */ 
    140 const std::map<int, std::vector<int> >& CClientServerMapping::getLocalIndexSendToServer() const 
    141 { 
    142   return localIndexSend2Server_; 
    143 } 
     136///*! 
     137//  Return local index of data that is send to server 
     138//  \return mapping of server rank and local index of sending data on the client 
     139//*/ 
     140//const CClientServerMapping::LocalIndexMap& CClientServerMapping::getLocalIndexSendToServer() const 
     141//{ 
     142//  return localIndexSend2Server_; 
     143//} 
    144144 
    145145/*! 
     
    149149  \return mapping of server rank and its global index. 
    150150*/ 
    151 const std::map<int, std::vector<size_t> >& CClientServerMapping::getGlobalIndexOnServer() const 
     151const CClientServerMapping::GlobalIndexMap& CClientServerMapping::getGlobalIndexOnServer() const 
    152152{ 
    153153  return indexGlobalOnServer_; 
Note: See TracChangeset for help on using the changeset viewer.