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/grid.cpp

    r1143 r1144  
    536536   } 
    537537 
    538    std::vector<int> CGrid::getAxisPositionInGrid() const 
    539    { 
    540      return axisPositionInGrid_; 
    541    } 
    542  
     538   /*! 
     539      Compute the index to for write data into a file 
     540   */ 
    543541   void CGrid::computeWrittenIndex() 
    544542   {       
     
    561559      localIndexToWriteOnClient.resize(nbWritten);   
    562560      localIndexToWriteOnServer.resize(nbWritten); 
    563  
    564       // if (isCompressible()) 
     561       
    565562      { 
    566563        numberWrittenIndexes_ = nbWritten; 
     
    607604       int rank = client->clientRank; 
    608605 
    609          clientDistribution_ = new CDistributionClient(rank, this); 
    610          // Get local data index on client 
    611          storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
    612          int nbStoreIndex = storeIndex_client.numElements(); 
    613          for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 
    614        // } 
     606       clientDistribution_ = new CDistributionClient(rank, this); 
     607       // Get local data index on client 
     608       storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 
     609       int nbStoreIndex = storeIndex_client.numElements(); 
     610       for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx];        
    615611      
    616612       if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); 
    617613       else           
    618        { 
    619            
     614       {           
    620615          // Mapping global index received from clients to the storeIndex_client 
    621616          CDistributionClient::GlobalLocalDataMap& globalDataIndex = clientDistribution_->getGlobalDataIndexOnClient(); 
     
    858853         } 
    859854 
    860 //         nbIndexOnServer = 0; 
    861 //         for (it = itb; it != ite; ++it) 
    862 //         { 
    863 //           const std::vector<int>& tmp = it->second; 
    864 //           nbIndexOnServerTmp = 0; 
    865 //           for (int i = 0; i < tmp.size(); ++i) 
    866 //           { 
    867 //             if (0 == nbIndexOnServerTmp(tmp[i])) 
    868 //             { 
    869 //               globalElementIndexOnServer[idx][tmp[i]][nbIndexOnServer(tmp[i])] = it->first; 
    870 //               ++nbIndexOnServerTmp(tmp[i]); 
    871 //             } 
    872 //           } 
    873 //           nbIndexOnServer += nbIndexOnServerTmp; 
    874 //         } 
    875 //       } 
    876  
    877855       nbIndexOnServer = 0; 
    878856       for (size_t j = 0; j < globalIndexElementOnServerMap.size(); ++j) 
     
    11441122   } 
    11451123 
    1146    void CGrid::outputField(int rank, const CArray<double, 1>& stored, double* field) 
    1147    { 
    1148      const CArray<size_t,1>& out_i = outIndexFromClient[rank]; 
    1149      StdSize numElements = stored.numElements(); 
    1150      for (StdSize n = 0; n < numElements; ++n) 
    1151      { 
    1152        field[out_i(n)] = stored(n); 
    1153      } 
    1154    } 
    1155  
    1156    void CGrid::inputField(int rank, const double* const field, CArray<double,1>& stored) 
    1157    { 
    1158      const CArray<size_t,1>& out_i = outIndexFromClient[rank]; 
    1159      StdSize numElements = stored.numElements(); 
    1160      for (StdSize n = 0; n < numElements; ++n) 
    1161      { 
    1162        stored(n) = field[out_i(n)]; 
    1163      } 
    1164    } 
    1165  
    1166    void CGrid::outputCompressedField(int rank, const CArray<double,1>& stored, double* field) 
    1167    { 
    1168      const CArray<size_t,1>& out_i = compressedOutIndexFromClient[rank]; 
    1169      StdSize numElements = stored.numElements(); 
    1170      for (StdSize n = 0; n < numElements; ++n) 
    1171      { 
    1172        field[out_i(n)] = stored(n); 
    1173      } 
    1174    } 
    1175  
    1176    //---------------------------------------------------------------- 
    1177  
    11781124   void CGrid::storeField_arr(const double* const data, CArray<double, 1>& stored) const 
    11791125   { 
     
    11931139  void CGrid::computeIndexScalarGrid() 
    11941140  { 
    1195     CContext* context = CContext::getCurrent(); 
    1196     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1141    CContext* context = CContext::getCurrent();     
    11971142    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    11981143    connectedServerRank_.resize(nbSrvPools); 
     
    12191164      } 
    12201165      isDataDistributed_ = false; 
    1221     } 
    1222   } 
    1223  
    1224   void CGrid::computeCompressedIndex() 
    1225   { 
    1226     compressedOutIndexFromClient = outIndexFromClient; 
    1227  
    1228     std::map<size_t, size_t> indexes; 
    1229  
    1230     { 
    1231       std::map<int, CArray<size_t,1> >::const_iterator it = compressedOutIndexFromClient.begin(); 
    1232       std::map<int, CArray<size_t,1> >::const_iterator itEnd = compressedOutIndexFromClient.end(); 
    1233       for (; it != itEnd; ++it) 
    1234       { 
    1235         for (int i = 0; i < it->second.numElements(); ++i) 
    1236           indexes.insert(std::make_pair(it->second(i), 0)); 
    1237       } 
    1238     } 
    1239  
    1240     { 
    1241       std::map<size_t, size_t>::iterator it = indexes.begin(); 
    1242       std::map<size_t, size_t>::iterator itEnd = indexes.end(); 
    1243       for (size_t i = 0; it != itEnd; ++it, ++i) 
    1244         it->second = i; 
    1245     } 
    1246  
    1247     { 
    1248       std::map<int, CArray<size_t,1> >::iterator it = compressedOutIndexFromClient.begin(); 
    1249       std::map<int, CArray<size_t,1> >::iterator itEnd = compressedOutIndexFromClient.end(); 
    1250       for (; it != itEnd; ++it) 
    1251       { 
    1252         for (int i = 0; i < it->second.numElements(); ++i) 
    1253           it->second(i) = indexes[it->second(i)]; 
    1254       } 
    12551166    } 
    12561167  } 
     
    13781289      else 
    13791290      { 
    1380         // CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap, itbGlobalMap; 
    1381         // itbGlobalMap = globalIndexOnServer_.begin(), itGlobalMap; 
    1382         // iteGlobalMap = globalIndexOnServer_.end(); 
    1383          
    1384         // std::map<int,int > nbGlobalLocalTmp; 
    1385         // for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
    1386         // { 
    1387         //   int serverRank = itGlobalMap->first; 
    1388         //   nbGlobalLocalTmp[serverRank] = 0; 
    1389         //   const std::vector<size_t>& indexVec = itGlobalMap->second; 
    1390         //   int indexSize = indexVec.size();           
    1391         //   for (int idx = 0; idx < indexSize; ++idx) 
    1392         //   { 
    1393         //     itIndex = globalLocalIndexSendToServer.find(indexVec[idx]); 
    1394         //     if (iteIndex != itIndex) 
    1395         //     { 
    1396         //       ++nbGlobalLocalTmp[serverRank]; 
    1397         //     } 
    1398         //   } 
    1399         // } 
    1400  
    1401         // std::map<int,std::vector<int> >localIndexTmp; 
    1402         // std::map<int,std::vector<size_t> > globalIndexTmp; 
    1403         // for (std::map<int,int>::iterator it = nbGlobalLocalTmp.begin(); it != nbGlobalLocalTmp.end(); ++it) 
    1404         // { 
    1405         //   localIndexTmp[it->first].resize(it->second); 
    1406         //   globalIndexTmp[it->first].resize(it->second); 
    1407         //   it->second = 0; 
    1408         // } 
    1409  
    1410         // for (itGlobalMap = itbGlobalMap; itGlobalMap != iteGlobalMap; ++itGlobalMap) 
    1411         // { 
    1412         //   int serverRank = itGlobalMap->first;           
    1413         //   const std::vector<size_t>& indexVec = itGlobalMap->second; 
    1414         //   int indexSize = indexVec.size();           
    1415         //   int ind = 0; 
    1416         //   for (int idx = 0; idx < indexSize; ++idx) 
    1417         //   { 
    1418         //     itIndex = globalLocalIndexSendToServer.find(indexVec[idx]); 
    1419         //     if (iteIndex != itIndex) 
    1420         //     {               
    1421         //       ind = nbGlobalLocalTmp[serverRank]; 
    1422         //       globalIndexTmp[serverRank][ind] = itIndex->first; 
    1423         //       localIndexTmp[serverRank][ind]  = itIndex->second; 
    1424         //       ++nbGlobalLocalTmp[serverRank]; 
    1425         //     } 
    1426         //   } 
    1427         // } 
    1428  
    14291291        CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itGlobalMap; 
    14301292        itGlobalMap = globalIndexOnServer_.begin(); 
     
    15021364 
    15031365    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 1) : 1; 
    1504     nbSrvPools = 1; 
    1505     // connectedServerRank_.resize(nbSrvPools); 
     1366    nbSrvPools = 1;     
    15061367    nbReadSenders.resize(nbSrvPools); 
    15071368    for (int p = 0; p < nbSrvPools; ++p) 
     
    15101371      CContextClient* client = (!context->hasClient) ? context->client : context->clientPrimServer[p]; 
    15111372       
    1512 //      CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer[p]; 
    1513 //      CContextClient* client = (context->hasServer) ? context->client : context->clientPrimServer[p]; 
    1514       // numberWrittenIndexes_ = totalNumberWrittenIndexes_ = offsetWrittenIndexes_ = 0; 
    1515       //connectedServerRank_[p] = ranks; 
    1516  
    15171373      int idx = 0, numElement = axis_domain_order.numElements(); 
    15181374      int ssize = numElement; 
     
    15961452        else 
    15971453        { 
    1598 //          dataSize = outIndex.numElements(); 
    1599 //          for (int i = 0; i < outIndex.numElements(); ++i) outIndex(i) = i; 
    16001454          // THE PROBLEM HERE IS THAT DATA CAN BE NONDISTRIBUTED ON CLIENT AND DISTRIBUTED ON SERVER 
    16011455          // BELOW IS THE TEMPORARY FIX only for a single type of element (domain, asix, scalar) 
    16021456          dataSize = serverDistribution_->getGridSize(); 
    1603           // dataSize = serverDistribution_->getGlobalIndexEachDimension()[0].numElements(); 
    1604           // outIndex.resize(dataSize); 
    1605           // outIndex = serverDistribution_->getGlobalIndexEachDimension()[0]; 
    1606  
    16071457        } 
    16081458        writtenDataSize_ += dataSize; 
    1609  
    1610         // outIndexFromClient.insert(std::make_pair(rank, outIndex)); 
    1611         // connectedDataSize_[p][rank] = outIndex.numElements(); 
    1612         // numberWrittenIndexes_ += outIndex.numElements(); 
    16131459      } 
    16141460 
     
    16861532      } 
    16871533 
    1688       // if (isScalarGrid()) return; 
    1689  
    1690       // if (isDataDistributed_) 
    1691       // { 
    1692       //   MPI_Allreduce(&numberWrittenIndexes_, &totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    1693       //   MPI_Scan(&numberWrittenIndexes_, &offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 
    1694       //   offsetWrittenIndexes_ -= numberWrittenIndexes_; 
    1695       // } 
    1696       // else 
    1697       //   totalNumberWrittenIndexes_ = numberWrittenIndexes_; 
     1534      if (isScalarGrid()) return; 
    16981535 
    16991536      nbReadSenders[p] = CClientServerMappingDistributed::computeConnectedClients(context->client->serverSize, context->client->clientSize, context->client->intraComm, ranks); 
     
    19101747   { 
    19111748      sendAddItem(id, (int)EVENT_ID_ADD_DOMAIN); 
    1912     // CContext* context=CContext::getCurrent(); 
    1913  
    1914     // if (! context->hasServer ) 
    1915     // { 
    1916     //    CContextClient* client=context->client; 
    1917  
    1918     //    CEventClient event(this->getType(),EVENT_ID_ADD_DOMAIN); 
    1919     //    if (client->isServerLeader()) 
    1920     //    { 
    1921     //      CMessage msg; 
    1922     //      msg<<this->getId(); 
    1923     //      msg<<id; 
    1924     //      const std::list<int>& ranks = client->getRanksServerLeader(); 
    1925     //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1926     //        event.push(*itRank,1,msg); 
    1927     //      client->sendEvent(event); 
    1928     //    } 
    1929     //    else client->sendEvent(event); 
    1930     // } 
    19311749   } 
    19321750 
     
    19381756   { 
    19391757      sendAddItem(id, (int)EVENT_ID_ADD_AXIS); 
    1940     // CContext* context=CContext::getCurrent(); 
    1941  
    1942     // if (! context->hasServer ) 
    1943     // { 
    1944     //    CContextClient* client=context->client; 
    1945  
    1946     //    CEventClient event(this->getType(),EVENT_ID_ADD_AXIS); 
    1947     //    if (client->isServerLeader()) 
    1948     //    { 
    1949     //      CMessage msg; 
    1950     //      msg<<this->getId(); 
    1951     //      msg<<id; 
    1952     //      const std::list<int>& ranks = client->getRanksServerLeader(); 
    1953     //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1954     //        event.push(*itRank,1,msg); 
    1955     //      client->sendEvent(event); 
    1956     //    } 
    1957     //    else client->sendEvent(event); 
    1958     // } 
    19591758   } 
    19601759 
     
    19661765   { 
    19671766      sendAddItem(id, (int)EVENT_ID_ADD_SCALAR); 
    1968     // CContext* context=CContext::getCurrent(); 
    1969  
    1970     // if (! context->hasServer ) 
    1971     // { 
    1972     //    CContextClient* client=context->client; 
    1973  
    1974     //    CEventClient event(this->getType(),EVENT_ID_ADD_SCALAR); 
    1975     //    if (client->isServerLeader()) 
    1976     //    { 
    1977     //      CMessage msg; 
    1978     //      msg<<this->getId(); 
    1979     //      msg<<id; 
    1980     //      const std::list<int>& ranks = client->getRanksServerLeader(); 
    1981     //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1982     //        event.push(*itRank,1,msg); 
    1983     //      client->sendEvent(event); 
    1984     //    } 
    1985     //    else client->sendEvent(event); 
    1986     // } 
    19871767   } 
    19881768 
     
    20751855    { 
    20761856      CDomain* pDom = CDomain::get(*it); 
    2077       if (context->hasClient && !context->hasServer) 
    2078       //if (context->hasClient) 
     1857      if (context->hasClient && !context->hasServer)       
    20791858      { 
    20801859        pDom->solveRefInheritance(apply); 
     
    20891868      CAxis* pAxis = CAxis::get(*it); 
    20901869      if (context->hasClient && !context->hasServer) 
    2091 //     if (context->hasClient) 
    20921870      { 
    20931871        pAxis->solveRefInheritance(apply); 
     
    21021880      CScalar* pScalar = CScalar::get(*it); 
    21031881      if (context->hasClient && !context->hasServer) 
    2104 //     if (context->hasClient) 
    21051882      { 
    21061883        pScalar->solveRefInheritance(apply); 
Note: See TracChangeset for help on using the changeset viewer.