Ignore:
Timestamp:
05/23/17 16:32:26 (7 years ago)
Author:
mhnguyen
Message:

Cleaning up some redundant codes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/node/domain.cpp

    r1143 r1144  
    7979   } 
    8080 
    81    const std::set<StdString> & CDomain::getRelFiles(void) const 
    82    { 
    83       return (this->relFiles); 
    84    } 
    85  
    86  
    87    const std::vector<int>& CDomain::getIndexesToWrite(void) const 
    88    { 
    89      return indexesToWrite; 
    90    } 
    91  
    9281   /*! 
    9382     Returns the number of indexes written by each server. 
     
    115104   { 
    116105     return offsetWrittenIndexes_; 
    117    } 
    118  
    119    /*! 
    120      Returns the start of indexes written by each server. 
    121      \return the start of indexes written by each server 
    122    */ 
    123    const std::vector<int>& CDomain::getStartWriteIndex() const 
    124    { 
    125      return start_write_index_; 
    126    } 
    127  
    128    /*! 
    129      Returns the count of indexes written by each server. 
    130      \return the count of indexes written by each server 
    131    */ 
    132    const std::vector<int>& CDomain::getCountWriteIndex() const 
    133    { 
    134      return count_write_index_; 
    135    } 
    136  
    137    /*! 
    138      Returns the local data written by each server.      
    139    */ 
    140    const std::vector<int>& CDomain::getLocalWriteSize() const 
    141    { 
    142      return local_write_size_; 
    143    } 
    144  
    145    /*! 
    146      Returns the global data written by all server.      
    147    */ 
    148    const std::vector<int>& CDomain::getGlobalWriteSize() const 
    149    { 
    150      return global_write_size_; 
    151106   } 
    152107 
     
    15641519   } 
    15651520 
    1566  
    1567   // void CDomain::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, 
    1568   //                                     CServerDistributionDescription::ServerDistributionType distType) 
    15691521  /*! 
    1570      Compute the connection of a client to other clients to determine which clients to send attributes to 
     1522     Compute the connection of a client to other clients to determine which clients to send attributes to. 
     1523     The sending clients are supposed to already know the distribution of receiving clients (In simple cases, it's band) 
     1524     The connection among clients is calculated by using global index.  
     1525     A client connects to other clients which holds the same global index as it.      
    15711526  */ 
    15721527  void CDomain::computeConnectedClients() 
     
    16091564      } 
    16101565 
    1611       // for (i = 0; i < nbIndex; ++i) 
    1612       // { 
    1613       //   i_ind=i_index(i); 
    1614       //   j_ind=j_index(i); 
    1615  
    1616       //   if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1617       //   { 
    1618       //     ++globalIndexCountZoom; 
    1619       //   } 
    1620       // } 
    1621  
    1622       // int globalIndexWrittenCount = 0; 
    1623       // if (isCompressible_) 
    1624       // { 
    1625       //   for (i = 0; i < data_i_index.numElements(); ++i) 
    1626       //   { 
    1627       //     i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
    1628       //                                                 data_ibegin, data_jbegin, data_dim, ni, 
    1629       //                                                 j_ind); 
    1630       //     if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
    1631       //     { 
    1632       //       i_ind += ibegin; 
    1633       //       j_ind += jbegin; 
    1634       //       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1635       //         ++globalIndexWrittenCount; 
    1636       //     } 
    1637       //   } 
    1638       // } 
    16391566 
    16401567      // Fill in index 
    1641  
    16421568      CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 
    16431569      CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 
     
    16721598          globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    16731599          ++globalIndexCountZoom; 
    1674           // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1675           // { 
    1676           //   globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    1677           //   localIndexDomainZoom(globalIndexCountZoom) = i; 
    1678           //   ++globalIndexCountZoom; 
    1679           // } 
    16801600        } 
    16811601      } 
     
    16991619          int jend = jbegin + nj -1; 
    17001620          zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin; 
    1701           int zoom_iend   = global_zoom_iend < iend ? zoom_iend : iend ; 
     1621          int zoom_iend  = global_zoom_iend < iend ? zoom_iend : iend ; 
    17021622          zoom_ni     = zoom_iend-zoom_ibegin+1 ; 
    17031623 
     
    17071627      } 
    17081628 
    1709       // if (globalLocalIndexZoomMap_.empty()) 
    1710       // { 
    1711       //   int nbIndexZoom = globalIndexDomainZoom.numElements(); 
    1712       //   for (i = 0; i < nbIndex; ++i) 
    1713       //     globalLocalIndexZoomMap_[globalIndexDomainZoom(i)] = i; 
    1714       // } 
    1715  
    1716  
    1717       // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 
    1718       // if (isCompressible_) 
    1719       // { 
    1720       //   globalIndexWrittenCount = 0; 
    1721       //   for (i = 0; i < data_i_index.numElements(); ++i) 
    1722       //   { 
    1723       //     i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 
    1724       //                                                 data_ibegin, data_jbegin, data_dim, ni, 
    1725       //                                                 j_ind); 
    1726       //     if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 
    1727       //     { 
    1728       //       i_ind += ibegin; 
    1729       //       j_ind += jbegin; 
    1730       //       if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1731       //       { 
    1732       //         globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 
    1733       //         ++globalIndexWrittenCount; 
    1734       //       } 
    1735       //     } 
    1736       //   } 
    1737       // } 
    17381629 
    17391630      size_t globalSizeIndex = 1, indexBegin, indexEnd; 
     
    17721663      CClientServerMapping::GlobalIndexMap::const_iterator it  = globalIndexDomainOnServer.begin(), 
    17731664                                                           ite = globalIndexDomainOnServer.end(); 
    1774       // typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 
    1775       // std::vector<int>::iterator itVec; 
    1776  
    1777       // indSrv_.clear(); 
    1778       // indWrittenSrv_.clear(); 
    1779       // for (; it != ite; ++it) 
    1780       // { 
    1781       //   int rank = it->first; 
    1782       //   int indexSize = it->second.size(); 
    1783       //   std::vector<int> permutIndex(indexSize); 
    1784       //   XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 
    1785       //   XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); 
    1786       //   BinarySearch binSearch(it->second); 
    1787       //   int nb = globalIndexDomainZoom.numElements(); 
    1788       //   for (int i = 0; i < nb; ++i) 
    1789       //   { 
    1790       //     if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 
    1791       //     { 
    1792       //       indSrv_[rank].push_back(localIndexDomainZoom(i)); 
    1793       //     } 
    1794       //   } 
    1795       //   for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 
    1796       //   { 
    1797       //     if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 
    1798       //     { 
    1799       //       indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 
    1800       //     } 
    1801       //   } 
    1802       // } 
    1803  
    18041665      connectedServerRank_.clear(); 
    18051666      for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 
     
    18231684  } 
    18241685 
    1825   const boost::unordered_map<int, vector<size_t> >& CDomain::getIndexServer() const 
    1826   { 
    1827     return indSrv_; 
    1828   } 
    1829  
     1686   /*! 
     1687     Compute index to write data. We only write data on the zoomed region, therefore, there should 
     1688     be a map between the complete grid and the reduced grid where we write data. 
     1689     By using global index we can easily create this kind of mapping. 
     1690   */ 
    18301691   void CDomain::computeWrittenIndex() 
    18311692   {   
     
    19761837        list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); 
    19771838        
    1978         // if (isCompressible_) 
    1979         // { 
    1980         //   std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 
    1981         //   list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 
    1982         //   CArray<int,1>& writtenInd = list_writtenInd.back(); 
    1983  
    1984         //   for (n = 0; n < writtenInd.numElements(); ++n) 
    1985         //     writtenInd(n) = writtenIndSrc[n]; 
    1986  
    1987         //   list_msgsIndex.back() << writtenInd; 
    1988         // } 
    1989  
    19901839        eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 
    19911840      } 
     
    19971846  /*! 
    19981847    Send global index and zoom index from client to connected client(s) 
    1999     zoom index can be smaller than global index 
     1848    zoom index can be smaller than global index. 
     1849    This function can be used in the future??? 
    20001850  */ 
    20011851  void CDomain::sendIndexZoom() 
     
    21001950 
    21011951  /*! 
    2102     Send mask index from client to connected(s) 
     1952    Send mask index from client to connected(s) clients     
    21031953  */ 
    21041954  void CDomain::sendMask() 
     
    21962046  /*! 
    21972047    Send longitude and latitude from client to servers 
    2198     Each client send long and lat information to corresponding connected server(s). 
     2048    Each client send long and lat information to corresponding connected clients(s). 
    21992049    Because longitude and latitude are optional, this function only called if latitude and longitude exist 
    22002050  */ 
     
    22952145    Data index can be compressed however, we always send decompressed data index 
    22962146    and they will be compressed on receiving. 
     2147    The compressed index are represented with 1 and others are represented with -1 
    22972148  */ 
    22982149  void CDomain::sendDataIndex() 
     
    24312282    } 
    24322283    get(domainId)->recvIndex(rankBuffers); 
    2433  
    2434     // if (domain->isCompressible_) 
    2435     // { 
    2436     //   std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); 
    2437  
    2438     //   CContextServer* server = CContext::getCurrent()->server; 
    2439     //   domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); 
    2440     //   MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    2441     //   MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    2442     //   domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; 
    2443     // } 
    24442284  } 
    24452285 
    24462286  /*! 
    2447     Receive index information from client(s) 
     2287    Receive index information from client(s). We use the global index for mapping index between 
     2288    sending clients and receiving clients. 
    24482289    \param[in] rankBuffers rank of sending client and the corresponding receive buffer   
    24492290  */ 
     
    24842325         ++nbIndGlob; 
    24852326      }  
    2486     }    
    2487      
    2488     // { 
    2489     //   CContextServer* server = CContext::getCurrent()->server; 
    2490     //   count_write_index_.resize(2); 
    2491     //   start_write_index_.resize(2); 
    2492     //   local_write_size_.resize(2); 
    2493     //   global_write_size_.resize(2); 
    2494     //   if ((this->type) == CDomain::type_attr::unstructured) 
    2495     //   { 
    2496     //     count_write_index_[0] = zoom_i_index.numElements(); 
    2497     //     count_write_index_[1] = 0; 
    2498     //   } 
    2499     //   else 
    2500     //   { 
    2501     //     int ni_zoom = zoom_i_index.numElements(), idx, nbIZoom = 0, nbJZoom = 0; 
    2502     //     for (idx =0; idx < ni_zoom; ++idx) 
    2503     //     { 
    2504     //        if ((ibegin <= zoom_i_index(idx)) && (zoom_i_index(idx) < ibegin+ni) && (nbIZoom < ni)) 
    2505     //         ++nbIZoom; 
    2506     //        if ((jbegin <= zoom_j_index(idx)) && (zoom_j_index(idx) < jbegin+nj) && (nbJZoom < nj)) 
    2507     //         ++nbJZoom; 
    2508     //     } 
    2509     //     count_write_index_[0] = nbIZoom; 
    2510     //     count_write_index_[1] = nbJZoom; 
    2511  
    2512     //     // Reoder the zoom_index 
    2513     //     for (int j = 0; j < nbJZoom; ++j) 
    2514     //       for (int i = 0; i < nbIZoom; ++i) 
    2515     //       { 
    2516     //         idx = nbIZoom * j + i; 
    2517     //         if (idx < ni_zoom) 
    2518     //         { 
    2519     //           zoom_i_index(idx) = ibegin + i; 
    2520     //           zoom_j_index(idx) = jbegin + j; 
    2521     //         } 
    2522     //       }   
    2523  
    2524     //     // Reorder the global index 
    2525     //     for (int j = 0; j < nj; ++j) 
    2526     //       for (int i = 0; i < ni; ++i) 
    2527     //       { 
    2528     //         idx = ni * j + i; 
    2529     //         if (idx < nbIndGlob) 
    2530     //         { 
    2531     //           i_index(idx) = ibegin + i; 
    2532     //           j_index(idx) = jbegin + j; 
    2533     //         } 
    2534     //       }          
    2535     //   } 
    2536  
    2537              
    2538     //   MPI_Scan(&count_write_index_[0], &start_write_index_[0], 2, MPI_INT, MPI_SUM, server->intraComm);       
    2539     //   start_write_index_[0] = 0;  
    2540     //   start_write_index_[1] -= count_write_index_[1]; 
    2541     //   local_write_size_[0] = count_write_index_[0]; 
    2542     //   local_write_size_[1] = count_write_index_[1]; 
    2543     //   MPI_Allreduce(&count_write_index_[0], &global_write_size_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 
    2544     //   global_write_size_[0] = count_write_index_[0]; 
    2545     //   global_write_size_[1] = (global_write_size_[1] > nj_glo) ? nj_glo : global_write_size_[1]; 
    2546           
    2547  
    2548     // } 
    2549  
    2550     // int type_int; 
    2551     // buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; 
    2552     // type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 
    2553  
    2554     // if (isCompressible_) 
    2555     // { 
    2556     //   CArray<int, 1> writtenIndexes; 
    2557     //   buffer >> writtenIndexes; 
    2558     //   indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 
    2559     //   for (int i = 0; i < writtenIndexes.numElements(); ++i) 
    2560     //     indexesToWrite.push_back(writtenIndexes(i)); 
    2561     // } 
     2327    }  
    25622328  } 
    25632329 
     
    26272393    { 
    26282394    } 
    2629  
    2630     // globalLocalIndexZoomMap_.rehash(std::ceil(nbZoomInd/globalLocalIndexZoomMap_.max_load_factor())); 
    2631     // nbZoomInd = 0; 
    2632     // for (int j = 0; j < zoom_nj; ++j)  
    2633     //   for (int i = 0; i < zoom_ni; ++i) 
    2634     //   { 
    2635     //     globalLocalIndexZoomMap_[(i + zoom_ibegin) + (j + zoom_jbegin) * ni_glo] = nbZoomInd; 
    2636     //     ++nbZoomInd; 
    2637     //   } 
    26382395  } 
    26392396 
     
    30042761    } 
    30052762    get(domainId)->recvDataIndex(rankBuffers); 
    3006  
    3007     // if (domain->isCompressible_) 
    3008     // { 
    3009     //   std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); 
    3010  
    3011     //   CContextServer* server = CContext::getCurrent()->server; 
    3012     //   domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); 
    3013     //   MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    3014     //   MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    3015     //   domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; 
    3016     // } 
    30172763  } 
    30182764 
Note: See TracChangeset for help on using the changeset viewer.