Ignore:
Timestamp:
06/09/16 11:33:19 (8 years ago)
Author:
mhnguyen
Message:

Various clean up

+) Remove some redundant codes

Test
+) On Curie
+) tests pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/axis_algorithm_transformation.cpp

    r866 r867  
    1414#include "context_client.hpp" 
    1515#include "client_client_dht_template.hpp" 
     16#include "axis.hpp" 
    1617 
    1718namespace xios { 
     
    3233} 
    3334 
     35void CAxisAlgorithmTransformation::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
     36{ 
     37} 
     38 
     39/*! 
     40  Compute global index of axis on different processes 
     41  \param [in] globalAxisIndex global index of axis source 
     42  \param [out] globalAxisIndexOnProc processes which contain the corresponding global index of axis source 
     43*/ 
    3444void CAxisAlgorithmTransformation::computeExchangeGlobalIndex(const CArray<size_t,1>& globalAxisIndex, 
    3545                                                              CClientClientDHTInt::Index2VectorInfoTypeMap& globalAxisIndexOnProc) 
     
    4959    globalIndex2ProcRank[globalIndex].resize(1); 
    5060    globalIndex2ProcRank[globalIndex][0] = clientRank; 
    51 //    globalIndex2ProcRank[globalIndex].push_back(clientRank); 
    5261  } 
    5362 
     
    5564  dhtIndexProcRank.computeIndexInfoMapping(globalAxisIndex); 
    5665 
    57 //  std::vector<int> countIndex(clientSize,0); 
    58 //  const CClientClientDHTInt::Index2VectorInfoTypeMap& computedGlobalIndexOnProc = dhtIndexProcRank.getInfoIndexMap(); 
    5966  globalAxisIndexOnProc = dhtIndexProcRank.getInfoIndexMap(); 
    60 // 
    61 //  CClientClientDHTInt::Index2VectorInfoTypeMap::const_iterator itb = computedGlobalIndexOnProc.begin(), it, 
    62 //                                                               ite = computedGlobalIndexOnProc.end(); 
    63 //  for (it = itb; it != ite; ++it) 
    64 //  { 
    65 //    const std::vector<int>& procList = it->second; 
    66 //    for (int idx = 0; idx < procList.size(); ++idx) ++countIndex[procList[idx]]; 
    67 //  } 
    68 // 
    69 //  globalAxisIndexOnProc.rehash(std::ceil(clientSize/globalAxisIndexOnProc.max_load_factor())); 
    70 //  for (int idx = 0; idx < clientSize; ++idx) 
    71 //  { 
    72 //    if (0 != countIndex[idx]) 
    73 //    { 
    74 //      globalAxisIndexOnProc[idx].resize(countIndex[idx]); 
    75 //      countIndex[idx] = 0; 
    76 //    } 
    77 //  } 
    78 // 
    79 //  for (it = itb; it != ite; ++it) 
    80 //  { 
    81 //    const std::vector<int>& procList = it->second; 
    82 //    for (int idx = 0; idx < procList.size(); ++idx) 
    83 //    { 
    84 //      globalAxisIndexOnProc[procList[idx]][countIndex[procList[idx]]] = it->first; 
    85 //      ++countIndex[procList[idx]]; 
    86 //    } 
    87 //  } 
    8867} 
    8968 
    90 void CAxisAlgorithmTransformation::computeIndexSourceMapping_(const std::vector<CArray<double,1>* >& dataAuxInputs) 
    91 { 
    9269} 
    93  
    94 /*! 
    95   Compute an array of global index from a global index on a axis 
    96   \param[in] axisDestGlobalIndex global index on an axis of destination grid 
    97   \param[in] axisSrcGlobalIndex global index on an axis of source grid (which are needed by one index on axis destination) 
    98   \param[in] axisPositionInGrid position of the axis in the grid 
    99   \param[in] gridDestGlobalDim dimension size of destination grid (it should share the same size for all dimension, maybe except the axis on which transformation is performed) 
    100   \param[in] globalIndexGridDestSendToServer global index of destination grid which are to be sent to server(s), this array is already acsending sorted 
    101   \param[in/out] globalIndexDestGrid array of global index (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated 
    102   \param[in/out] globalIndexSrcGrid array of global index of source grid (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated 
    103 */ 
    104 void CAxisAlgorithmTransformation::computeGlobalGridIndexFromGlobalIndexElement(int axisDestGlobalIndex, 
    105                                                                           const std::vector<int>& axisSrcGlobalIndex, 
    106                                                                           const std::vector<int>& destGlobalIndexPositionInGrid, 
    107                                                                           int axisPositionInGrid, 
    108                                                                           const std::vector<int>& gridDestGlobalDim, 
    109                                                                           const std::vector<int>& gridSrcGlobalDim, 
    110                                                                           const GlobalLocalMap& globalLocalIndexDestSendToServerMap, 
    111                                                                           std::vector<std::pair<size_t,int> >& globalLocalIndexDestMap, 
    112                                                                           std::vector<std::vector<size_t> >& globalIndexSrcGrid) 
    113 { 
    114   bool hasDestGlobalIndexPos = !destGlobalIndexPositionInGrid.empty(); 
    115   int globalDim = gridDestGlobalDim.size(); 
    116  
    117   std::vector<size_t> currentIndex(globalDim); 
    118   std::vector<int> gridAxisGlobalDim(globalDim); 
    119   std::vector<int> idxLoop(globalDim, 0); 
    120  
    121   size_t ssize = 1, idx = 0, realGlobalIndexSize = 0; 
    122   for (int i = 0; i< globalDim; ++i) 
    123   { 
    124     if (axisPositionInGrid == i) gridAxisGlobalDim[i] = 1; 
    125     else 
    126     { 
    127       if (!hasDestGlobalIndexPos) gridAxisGlobalDim[i] = gridDestGlobalDim[i]; 
    128       else gridAxisGlobalDim[i] = 1; 
    129     } 
    130     ssize *= gridAxisGlobalDim[i]; 
    131   } 
    132  
    133   GlobalLocalMap::const_iterator iteArr = globalLocalIndexDestSendToServerMap.end(), it; 
    134  
    135   while (idx < ssize) 
    136   { 
    137     for (int i = 0; i < globalDim-1; ++i) 
    138     { 
    139       if (idxLoop[i] == gridAxisGlobalDim[i]) 
    140       { 
    141         idxLoop[i] = 0; 
    142         ++idxLoop[i+1]; 
    143       } 
    144     } 
    145  
    146     int j = 0; 
    147     for (int i = 0; i < globalDim; ++i) 
    148     { 
    149       if (!hasDestGlobalIndexPos) currentIndex[i] = idxLoop[i]; 
    150       else 
    151       { 
    152         if (axisPositionInGrid == i) currentIndex[i] = axisDestGlobalIndex; 
    153         else 
    154         { 
    155           currentIndex[i] = destGlobalIndexPositionInGrid[j]; 
    156           ++j; 
    157         } 
    158       } 
    159     } 
    160  
    161     currentIndex[axisPositionInGrid] = axisDestGlobalIndex; 
    162  
    163     size_t globIndex = currentIndex[0]; 
    164     size_t mulDim = 1; 
    165     for (int k = 1; k < globalDim; ++k) 
    166     { 
    167       mulDim *= gridDestGlobalDim[k-1]; 
    168       globIndex += (currentIndex[k])*mulDim; 
    169     } 
    170  
    171     if (iteArr != globalLocalIndexDestSendToServerMap.find(globIndex)) ++realGlobalIndexSize; 
    172     ++idxLoop[0]; 
    173     ++idx; 
    174   } 
    175  
    176   if (globalLocalIndexDestMap.size() != realGlobalIndexSize) 
    177     globalLocalIndexDestMap.resize(realGlobalIndexSize); 
    178  
    179   if (realGlobalIndexSize != globalIndexSrcGrid.size()) globalIndexSrcGrid.resize(realGlobalIndexSize); 
    180   for (int i = 0; i < globalIndexSrcGrid.size(); ++i) 
    181     if (globalIndexSrcGrid[i].size() != axisSrcGlobalIndex.size()) 
    182       globalIndexSrcGrid[i].resize(axisSrcGlobalIndex.size()); 
    183  
    184   size_t realGlobalIndex = 0; 
    185   idx = 0; 
    186   idxLoop.assign(globalDim, 0); 
    187   while (idx < ssize) 
    188   { 
    189     for (int i = 0; i < globalDim-1; ++i) 
    190     { 
    191       if (idxLoop[i] == gridAxisGlobalDim[i]) 
    192       { 
    193         idxLoop[i] = 0; 
    194         ++idxLoop[i+1]; 
    195       } 
    196     } 
    197  
    198     int j = 0; 
    199     for (int i = 0; i < globalDim; ++i) 
    200     { 
    201       if (!hasDestGlobalIndexPos) currentIndex[i] = idxLoop[i]; 
    202       else 
    203       { 
    204         if (axisPositionInGrid == i) currentIndex[i] = axisDestGlobalIndex; 
    205         else 
    206         { 
    207           currentIndex[i] = destGlobalIndexPositionInGrid[j]; 
    208           ++j; 
    209         } 
    210       } 
    211     } 
    212     currentIndex[axisPositionInGrid] = axisDestGlobalIndex; 
    213  
    214     size_t globIndex = currentIndex[0]; 
    215     size_t mulDim = 1; 
    216     for (int k = 1; k < globalDim; ++k) 
    217     { 
    218       mulDim *= gridDestGlobalDim[k-1]; 
    219       globIndex += (currentIndex[k])*mulDim; 
    220     } 
    221  
    222     it = globalLocalIndexDestSendToServerMap.find(globIndex); 
    223     if (iteArr != it) 
    224     { 
    225       globalLocalIndexDestMap[realGlobalIndex] = (std::make_pair(it->first,it->second)); 
    226       for (int i = 0; i < globalIndexSrcGrid[realGlobalIndex].size(); ++i) 
    227       { 
    228         currentIndex[axisPositionInGrid] = axisSrcGlobalIndex[i]; 
    229         globIndex = currentIndex[0]; 
    230         mulDim = 1; 
    231         for (int k = 1; k < globalDim; ++k) 
    232         { 
    233           mulDim *= gridDestGlobalDim[k-1]; 
    234           globIndex += (currentIndex[k])*mulDim; 
    235         } 
    236         (globalIndexSrcGrid[realGlobalIndex])[i] = globIndex; 
    237       } 
    238       ++realGlobalIndex; 
    239     } 
    240  
    241     ++idxLoop[0]; 
    242     ++idx; 
    243   } 
    244 } 
    245 } 
Note: See TracChangeset for help on using the changeset viewer.