Ignore:
Timestamp:
04/14/17 16:53:56 (7 years ago)
Author:
mhnguyen
Message:

Updating 2-level server

+) Make some changes in the way data rebuilt on each level of server
+) Make some changes in the order of functions call during close context to make sure that each server receives the global indexes before calculating index to send to next level
+) Modify some functions to make sure data sent to the correct server pool

Test
+) On Curie
+) Only test_client

File:
1 edited

Legend:

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

    r1054 r1099  
    3333      , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 
    3434      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    35       , isRedistributed_(false), hasPole(false) 
     35      , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 
     36      , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 
     37      , globalLocalIndexMap_() 
    3638   { 
    3739   } 
     
    4244      , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 
    4345      , isClientAfterTransformationChecked(false), hasLonLat(false) 
    44       , isRedistributed_(false), hasPole(false) 
     46      , isRedistributed_(false), hasPole(false), doZoomByIndex_(false) 
     47      , lonvalue(), latvalue(), bounds_lonvalue(), bounds_latvalue() 
     48      , globalLocalIndexMap_() 
    4549   { 
    4650         } 
     
    756760    if (zoom_i_index.isEmpty()) zoom_i_index.setValue(i_index.getValue()); 
    757761    if (zoom_j_index.isEmpty()) zoom_j_index.setValue(j_index.getValue()); 
     762    if (zoom_ibegin.isEmpty()) zoom_ibegin.setValue(ibegin); 
     763    if (zoom_ni.isEmpty()) zoom_ni.setValue(ni); 
     764    if (zoom_jbegin.isEmpty()) zoom_jbegin.setValue(jbegin); 
     765    if (zoom_nj.isEmpty()) zoom_nj.setValue(nj); 
    758766   } 
    759767 
     
    10761084   void CDomain::completeLonLatClient(void) 
    10771085   { 
    1078      if (!lonvalue_2d.isEmpty()) 
     1086     bool lonlatValueExisted = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 
     1087     if (!lonvalue_2d.isEmpty() && !lonlatValueExisted) 
    10791088     { 
    10801089       lonvalue.resize(ni * nj); 
     
    11061115       } 
    11071116     } 
    1108      else if (!lonvalue_1d.isEmpty()) 
     1117     else if (!lonvalue_1d.isEmpty()  && !lonlatValueExisted) 
    11091118     { 
    11101119       if (type_attr::rectilinear == type) 
     
    11401149           } 
    11411150         } 
    1142          else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements()) 
     1151         else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements()  && !lonlatValueExisted) 
    11431152         { 
    11441153           lonvalue.reference(lonvalue_1d); 
     
    11591168                 << i_index.numElements() << " and "  << j_index.numElements() << "."); 
    11601169       } 
    1161        else if (type == type_attr::curvilinear || type == type_attr::unstructured) 
     1170       else if (type == type_attr::curvilinear || type == type_attr::unstructured  && !lonlatValueExisted) 
    11621171       { 
    11631172         lonvalue.reference(lonvalue_1d); 
     
    11741183   void CDomain::checkBounds(void) 
    11751184   { 
    1176      if (!nvertex.isEmpty() && nvertex > 0) 
     1185     bool hasBoundValues = (0 != bounds_lonvalue.numElements()) || (0 != bounds_latvalue.numElements()); 
     1186     if (!nvertex.isEmpty() && nvertex > 0 && !hasBoundValues) 
    11771187     { 
    11781188       if (!bounds_lon_1d.isEmpty() && !bounds_lon_2d.isEmpty()) 
     
    12621272   void CDomain::checkArea(void) 
    12631273   { 
     1274     bool hasAreaValue = (0 != areavalue.numElements()); 
    12641275     hasArea = !area.isEmpty() || !areavalue.isEmpty(); 
    12651276     if (hasArea) 
     
    12921303     hasLonLat = (!latvalue_1d.isEmpty() && !lonvalue_1d.isEmpty()) || 
    12931304                 (!latvalue_2d.isEmpty() && !lonvalue_2d.isEmpty()); 
    1294      if (hasLonLat) 
     1305     bool hasLonLatValue = (0 != lonvalue.numElements()) || (0 != latvalue.numElements()); 
     1306     if (hasLonLat && !hasLonLatValue) 
    12951307     { 
    12961308       if (!lonvalue_1d.isEmpty() && !lonvalue_2d.isEmpty()) 
     
    14431455   } 
    14441456 
    1445   /*! 
    1446     Send distribution from client to other clients 
    1447     Because a client in a level knows correctly the grid distribution of client on the next level 
    1448     it calculates this distribution then sends it to the corresponding clients on the next level 
    1449   */ 
    1450   void CDomain::sendDistributionAttributes(void) 
    1451   { 
    1452     CContext* context = CContext::getCurrent(); 
    1453      // Use correct context client to send message 
    1454     // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    1455     int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
    1456     for (int p = 0; p < nbSrvPools; ++p) 
    1457     { 
    1458       CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[p] 
    1459                                                                        : context->client; 
    1460  
    1461       int nbServer = contextClientTmp->serverSize; 
    1462       std::vector<int> nGlobDomain(2); 
    1463       nGlobDomain[0] = this->ni_glo; 
    1464       nGlobDomain[1] = this->nj_glo; 
    1465  
    1466       CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
    1467       if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); 
    1468       else serverDescription.computeServerDistribution(false, 1); 
    1469  
    1470       std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
    1471       std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
    1472  
    1473       CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 
    1474       if (contextClientTmp->isServerLeader()) 
    1475       { 
    1476         std::list<CMessage> msgs; 
    1477  
    1478         const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
    1479         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1480         { 
    1481           // Use const int to ensure CMessage holds a copy of the value instead of just a reference 
    1482           const int ibegin_srv = serverIndexBegin[*itRank][0]; 
    1483           const int jbegin_srv = serverIndexBegin[*itRank][1]; 
    1484           const int ni_srv = serverDimensionSizes[*itRank][0]; 
    1485           const int nj_srv = serverDimensionSizes[*itRank][1]; 
    1486  
    1487           msgs.push_back(CMessage()); 
    1488           CMessage& msg = msgs.back(); 
    1489           msg << this->getId() ; 
    1490         msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv;         
    1491           msg << isCompressible_; 
    1492  
    1493           event.push(*itRank,1,msg); 
    1494         } 
    1495         contextClientTmp->sendEvent(event); 
    1496       } 
    1497       else contextClientTmp->sendEvent(event); 
    1498     } 
    1499   } 
    15001457 
    15011458  // void CDomain::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, 
     
    15071464  { 
    15081465    CContext* context=CContext::getCurrent() ; 
     1466 
    15091467    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    15101468    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     
    15121470    { 
    15131471      CContextClient* client = (0 != context->clientPrimServer.size()) ? context->clientPrimServer[p] : context->client; 
    1514       int nbServer=client->serverSize; 
    1515       int rank = client->clientRank; 
     1472      int nbServer = client->serverSize; 
     1473      int rank     = client->clientRank; 
    15161474      bool doComputeGlobalIndexServer = true; 
    15171475 
    15181476      int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 
    1519       int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
    1520       int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
     1477      int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 
     1478      int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 
    15211479 
    15221480      // Precompute number of index 
    15231481      int globalIndexCountZoom = 0; 
    15241482      nbIndex = i_index.numElements(); 
     1483 
     1484      if (doZoomByIndex_)  
     1485      { 
     1486        globalIndexCountZoom = zoom_i_index.numElements(); 
     1487      } 
     1488      else  
     1489      { 
     1490        for (i = 0; i < nbIndex; ++i) 
     1491        { 
     1492          i_ind=i_index(i); 
     1493          j_ind=j_index(i); 
     1494 
     1495          if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1496          { 
     1497            ++globalIndexCountZoom; 
     1498          } 
     1499        } 
     1500      } 
     1501 
    15251502      // for (i = 0; i < nbIndex; ++i) 
    15261503      // { 
     
    15541531      // Fill in index 
    15551532 
     1533      CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 
    15561534      CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 
    15571535      CArray<size_t,1> globalIndexDomain(nbIndex); 
     
    15591537      int globalIndexCount = 0; 
    15601538 
    1561  
    15621539      for (i = 0; i < nbIndex; ++i) 
    15631540      { 
     
    15651542        j_ind=j_index(i); 
    15661543        globalIndex = i_ind + j_ind * ni_glo; 
    1567         globalIndexDomain(globalIndexCount) = globalIndex; 
    1568         globalLocalIndexMap_[globalIndex] = i; 
    1569         ++globalIndexCount; 
    1570       } 
    1571  
    1572       nbIndexZoom = zoom_i_index.numElements(); 
    1573       CArray<size_t,1> globalIndexDomainZoom(nbIndexZoom); 
     1544        globalIndexDomain(i) = globalIndex;                 
     1545      } 
     1546 
     1547      if (globalLocalIndexMap_.empty()) 
     1548      { 
     1549        for (i = 0; i < nbIndex; ++i) 
     1550          globalLocalIndexMap_[globalIndexDomain(i)] = i; 
     1551 
     1552      } 
     1553 
    15741554      globalIndexCountZoom = 0; 
    1575       for (i = 0; i < nbIndexZoom; ++i) 
    1576       { 
    1577         i_ind=zoom_i_index(i); 
    1578         j_ind=zoom_j_index(i); 
    1579         globalIndex = i_ind + j_ind * ni_glo; 
    1580         globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    1581  
    1582         ++globalIndexCountZoom; 
    1583         // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
    1584         // { 
    1585         //   globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    1586         //   localIndexDomainZoom(globalIndexCountZoom) = i; 
    1587         //   ++globalIndexCountZoom; 
    1588         // } 
    1589       } 
     1555      if (doZoomByIndex_)  
     1556      { 
     1557        int nbIndexZoom = zoom_i_index.numElements();         
     1558         
     1559        for (i = 0; i < nbIndexZoom; ++i) 
     1560        { 
     1561          i_ind=zoom_i_index(i); 
     1562          j_ind=zoom_j_index(i); 
     1563          globalIndex = i_ind + j_ind * ni_glo; 
     1564          globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     1565          ++globalIndexCountZoom; 
     1566          // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1567          // { 
     1568          //   globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     1569          //   localIndexDomainZoom(globalIndexCountZoom) = i; 
     1570          //   ++globalIndexCountZoom; 
     1571          // } 
     1572        } 
     1573      } 
     1574      else  
     1575      { 
     1576          int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1; 
     1577          int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1; 
     1578          for (i = 0; i < nbIndex; ++i) 
     1579          { 
     1580            i_ind=i_index(i); 
     1581            j_ind=j_index(i); 
     1582            globalIndex = i_ind + j_ind * ni_glo; 
     1583            if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 
     1584            { 
     1585              globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     1586              ++globalIndexCountZoom; 
     1587            } 
     1588          } 
     1589 
     1590          int iend = ibegin + ni -1; 
     1591          int jend = jbegin + nj -1; 
     1592          zoom_ibegin = global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin; 
     1593          int zoom_iend   = global_zoom_iend < iend ? zoom_iend : iend ; 
     1594          zoom_ni     = zoom_iend-zoom_ibegin+1 ; 
     1595 
     1596          zoom_jbegin = global_zoom_jbegin > jbegin ? global_zoom_jbegin : jbegin ; 
     1597          int zoom_jend   = global_zoom_jend < jend ? zoom_jend : jend; 
     1598          zoom_nj     = zoom_jend-zoom_jbegin+1; 
     1599      } 
     1600 
    15901601 
    15911602      // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 
     
    16791690      for (it = globalIndexDomainOnServer.begin(); it != ite; ++it) { 
    16801691        connectedServerRank_.push_back(it->first); 
    1681         std::vector<size_t> vec = it->second; 
    1682         std::sort(vec.begin(), vec.end()); 
    1683         indSrv_[it->first] = vec; 
    1684       } 
    1685  
    1686 //      indSrv_.swap(globalIndexDomainOnServer); 
     1692        // std::vector<size_t> vec = it->second; 
     1693        // std::sort(vec.begin(), vec.end()); 
     1694        // indSrv_[it->first] = vec; 
     1695      } 
     1696 
     1697      indSrv_.swap(globalIndexDomainOnServer); 
    16871698      nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    16881699 
     
    16901701      CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 
    16911702//      indZoomSrv_.swap(globalIndexDomainZoomOnServer); 
    1692       std::vector<int> connectedServerZoomRank(indZoomSrv_.size()); 
     1703      std::vector<int> connectedServerZoomRank; //(indZoomSrv_.size()); 
    16931704//      for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 
    16941705//        connectedServerZoomRank.push_back(it->first); 
     
    17191730    sendDistributionAttributes(); 
    17201731    sendIndex(); 
     1732    sendIndex();     
    17211733    sendMask(); 
    17221734    sendLonLat(); 
     
    17331745    int ns, n, i, j, ind, nv, idx; 
    17341746    CContext* context = CContext::getCurrent(); 
     1747 
    17351748    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    17361749    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     
    17761789        list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
    17771790        list_msgsIndex.back() << isCurvilinear; 
    1778         list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back(); //list_indi.back() << list_indj.back(); 
    1779  
     1791        list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back() << doZoomByIndex_; //list_indi.back() << list_indj.back(); 
     1792        if (!doZoomByIndex_)  
     1793        { 
     1794          //list_msgsIndex.back() << zoom_ni.getValue() << zoom_ibegin.getValue() << zoom_nj.getValue() << zoom_jbegin.getValue(); 
     1795        } 
     1796        
    17801797        // if (isCompressible_) 
    17811798        // { 
     
    17981815 
    17991816  /*! 
     1817    Send distribution from client to other clients 
     1818    Because a client in a level knows correctly the grid distribution of client on the next level 
     1819    it calculates this distribution then sends it to the corresponding clients on the next level 
     1820  */ 
     1821  void CDomain::sendDistributionAttributes(void) 
     1822  { 
     1823    CContext* context = CContext::getCurrent(); 
     1824     // Use correct context client to send message 
     1825    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
     1826    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     1827    for (int i = 0; i < nbSrvPools; ++i) 
     1828    { 
     1829      CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] 
     1830                                                                         : context->client;     
     1831      int nbServer = contextClientTmp->serverSize; 
     1832      std::vector<int> nGlobDomain(2); 
     1833      nGlobDomain[0] = this->ni_glo; 
     1834      nGlobDomain[1] = this->nj_glo; 
     1835 
     1836      CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
     1837      if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); 
     1838      else serverDescription.computeServerDistribution(false, 1); 
     1839 
     1840      std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
     1841      std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
     1842 
     1843      CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 
     1844      if (contextClientTmp->isServerLeader()) 
     1845      { 
     1846        std::list<CMessage> msgs; 
     1847 
     1848        const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     1849        for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1850        { 
     1851          // Use const int to ensure CMessage holds a copy of the value instead of just a reference 
     1852          const int ibegin_srv = serverIndexBegin[*itRank][0]; 
     1853          const int jbegin_srv = serverIndexBegin[*itRank][1]; 
     1854          const int ni_srv = serverDimensionSizes[*itRank][0]; 
     1855          const int nj_srv = serverDimensionSizes[*itRank][1]; 
     1856 
     1857          msgs.push_back(CMessage()); 
     1858          CMessage& msg = msgs.back(); 
     1859          msg << this->getId() ; 
     1860          msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; 
     1861          msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue();         
     1862          msg << isCompressible_; 
     1863 
     1864          event.push(*itRank,1,msg); 
     1865        } 
     1866        contextClientTmp->sendEvent(event); 
     1867      } 
     1868      else contextClientTmp->sendEvent(event); 
     1869    } 
     1870  } 
     1871 
     1872  /*! 
    18001873    Send mask index from client to connected(s) 
    18011874  */ 
     
    18041877    int ns, n, i, j, ind, nv, idx; 
    18051878    CContext* context = CContext::getCurrent(); 
     1879 
    18061880    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    18071881    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     
    18511925    int ns, n, i, j, ind, nv, idx; 
    18521926    CContext* context = CContext::getCurrent(); 
     1927 
    18531928    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    18541929    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     
    19011976    int ns, n, i, j, ind, nv, idx; 
    19021977    CContext* context = CContext::getCurrent(); 
     1978 
    19031979    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    19041980    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     
    19862062    int ns, n, i, j, ind, nv, idx; 
    19872063    CContext* context = CContext::getCurrent(); 
     2064 
    19882065    // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    19892066    int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
     
    20852162 
    20862163  /*! 
    2087     Receive attributes event from clients(s) 
    2088     \param[in] event event contain info about rank and associated attributes 
    2089   */ 
    2090   void CDomain::recvDistributionAttributes(CEventServer& event) 
    2091   { 
    2092     CBufferIn* buffer=event.subEvents.begin()->buffer; 
    2093     string domainId ; 
    2094     *buffer>>domainId ; 
    2095     get(domainId)->recvDistributionAttributes(*buffer) ; 
    2096   } 
    2097  
    2098   /*! 
    2099     Receive attributes from client(s): zoom info and begin and n of each server 
    2100     \param[in] rank rank of client source 
    2101     \param[in] buffer message containing attributes info 
    2102   */ 
    2103   void CDomain::recvDistributionAttributes(CBufferIn& buffer) 
    2104   { 
    2105     int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 
    2106     buffer >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp            
    2107            >> isCompressible_; 
    2108     ni.setValue(ni_tmp); 
    2109     ibegin.setValue(ibegin_tmp); 
    2110     nj.setValue(nj_tmp); 
    2111     jbegin.setValue(jbegin_tmp); 
    2112   } 
    2113  
    2114   /*! 
    21152164    Receive index event from clients(s) 
    21162165    \param[in] event event contain info about rank and associated index 
     
    21512200    recvClientRanks_.resize(nbReceived); 
    21522201    vector<CArray<int,1> > recvZoomInd(nbReceived); 
     2202    int ni_zoom_tmp, ibegin_zoom_tmp, nj_zoom_tmp, jbegin_zoom_tmp; 
    21532203 
    21542204    std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); 
     
    21582208       recvClientRanks_[ind] = it->first; 
    21592209       CBufferIn& buffer = *(it->second); 
    2160        buffer >> type_int >> isCurvilinear >> indGlob_[it->first] >> recvZoomInd[ind]; //recvIndGlob[ind]; 
     2210       buffer >> type_int >> isCurvilinear >> indGlob_[it->first] >> recvZoomInd[ind] >> doZoomByIndex_;  
     2211       if (!doZoomByIndex_) 
     2212       { 
     2213        //buffer >> ni_zoom_tmp >> ibegin_zoom_tmp >> nj_zoom_tmp >> jbegin_zoom_tmp; 
     2214       } 
    21612215       type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 
    21622216    } 
     
    21892243    } 
    21902244 
    2191     zoom_i_index.resize(nbZoomInd); 
    2192     zoom_j_index.resize(nbZoomInd); 
     2245    if (doZoomByIndex_) 
     2246    { 
     2247      zoom_i_index.resize(nbZoomInd); 
     2248      zoom_j_index.resize(nbZoomInd); 
     2249       
     2250      nbZoomInd = 0; 
     2251      for (i = 0; i < nbReceived; ++i) 
     2252      { 
     2253        CArray<int,1>& tmp = recvZoomInd[i]; 
     2254        for (ind = 0; ind < tmp.numElements(); ++ind) 
     2255        { 
     2256           index = tmp(ind); 
     2257           zoom_i_index(nbZoomInd) = index % ni_glo; 
     2258           zoom_j_index(nbZoomInd) = index / ni_glo; 
     2259           ++nbZoomInd; 
     2260        }  
     2261      }       
     2262    } 
     2263    else  
     2264    { 
     2265      // zoom_ni.setValue(ni_zoom_tmp); 
     2266      // zoom_ibegin.setValue(ibegin_zoom_tmp); 
     2267      // zoom_nj.setValue(nj_zoom_tmp); 
     2268      // zoom_jbegin.setValue(jbegin_zoom_tmp); 
     2269      // int nbZoom = ni_zoom_tmp * nj_zoom_tmp; 
     2270      // zoom_i_index.resize(nbZoom); 
     2271      // zoom_j_index.resize(nbZoom); 
     2272      // nbZoom = 0; 
     2273      // for (int j = 0; j < nj_zoom_tmp; ++j)  
     2274      //   for (int i = 0; i < ni_zoom_tmp; ++i) 
     2275      //   { 
     2276      //     zoom_i_index(nbZoom) = ibegin_zoom_tmp + i; 
     2277      //     zoom_j_index(nbZoom) = jbegin_zoom_tmp + j; 
     2278      //     ++nbZoom; 
     2279      //   } 
     2280    } 
     2281 
     2282    globalLocalIndexMap_.rehash(std::ceil(nbIndGlob/globalLocalIndexMap_.max_load_factor())); 
     2283    nbIndGlob = 0; 
     2284    for (int j = 0; j < nj; ++j)  
     2285      for (int i = 0; i < ni; ++i) 
     2286      { 
     2287        globalLocalIndexMap_[(i + ibegin) + (j + jbegin) * ni_glo] = nbIndGlob; 
     2288        ++nbIndGlob; 
     2289      } 
     2290 
     2291 
    21932292     
    2194     nbZoomInd = 0; 
    2195     for (i = 0; i < nbReceived; ++i) 
    2196     { 
    2197       CArray<int,1>& tmp = recvZoomInd[i]; 
    2198       for (ind = 0; ind < tmp.numElements(); ++ind) 
    2199       { 
    2200          index = tmp(ind); 
    2201          zoom_i_index(nbZoomInd) = index % ni_glo; 
    2202          zoom_j_index(nbZoomInd) = index / ni_glo; 
    2203          ++nbZoomInd; 
    2204       }  
    2205     }     
    2206  
    2207     { 
    2208       CContextServer* server = CContext::getCurrent()->server; 
    2209       count_write_index_.resize(2); 
    2210       start_write_index_.resize(2); 
    2211       local_write_size_.resize(2); 
    2212       global_write_size_.resize(2); 
    2213       if ((this->type) == CDomain::type_attr::unstructured) 
    2214       { 
    2215         count_write_index_[0] = zoom_i_index.numElements(); 
    2216         count_write_index_[1] = 0; 
    2217       } 
    2218       else 
    2219       { 
    2220         int ni_zoom = zoom_i_index.numElements(), idx, nbIZoom = 0, nbJZoom = 0; 
    2221         for (idx =0; idx < ni_zoom; ++idx) 
    2222         { 
    2223           if ((ibegin <= zoom_i_index(idx)) && (zoom_i_index(idx) < ibegin+ni) && (nbIZoom < ni)) 
    2224             ++nbIZoom; 
    2225           if ((jbegin <= zoom_j_index(idx)) && (zoom_j_index(idx) < jbegin+nj) && (nbJZoom < nj)) 
    2226             ++nbJZoom; 
    2227         } 
    2228         count_write_index_[0] = nbIZoom; 
    2229         count_write_index_[1] = nbJZoom; 
    2230  
    2231         // Reoder the zoom_index 
    2232         for (int j = 0; j < nbJZoom; ++j) 
    2233           for (int i = 0; i < nbIZoom; ++i) 
    2234           { 
    2235             idx = nbIZoom * j + i; 
    2236             if (idx < ni_zoom) 
    2237             { 
    2238               zoom_i_index(idx) = ibegin + i; 
    2239               zoom_j_index(idx) = jbegin + j; 
    2240             } 
    2241           }   
    2242  
    2243         // Reorder the global index 
    2244         for (int j = 0; j < nj; ++j) 
    2245           for (int i = 0; i < ni; ++i) 
    2246           { 
    2247             idx = ni * j + i; 
    2248             if (idx < nbIndGlob) 
    2249             { 
    2250               i_index(idx) = ibegin + i; 
    2251               j_index(idx) = jbegin + j; 
    2252             } 
    2253           }          
    2254       } 
     2293    // { 
     2294    //   CContextServer* server = CContext::getCurrent()->server; 
     2295    //   count_write_index_.resize(2); 
     2296    //   start_write_index_.resize(2); 
     2297    //   local_write_size_.resize(2); 
     2298    //   global_write_size_.resize(2); 
     2299    //   if ((this->type) == CDomain::type_attr::unstructured) 
     2300    //   { 
     2301    //     count_write_index_[0] = zoom_i_index.numElements(); 
     2302    //     count_write_index_[1] = 0; 
     2303    //   } 
     2304    //   else 
     2305    //   { 
     2306    //     int ni_zoom = zoom_i_index.numElements(), idx, nbIZoom = 0, nbJZoom = 0; 
     2307    //     for (idx =0; idx < ni_zoom; ++idx) 
     2308    //     { 
     2309    //        if ((ibegin <= zoom_i_index(idx)) && (zoom_i_index(idx) < ibegin+ni) && (nbIZoom < ni)) 
     2310    //         ++nbIZoom; 
     2311    //        if ((jbegin <= zoom_j_index(idx)) && (zoom_j_index(idx) < jbegin+nj) && (nbJZoom < nj)) 
     2312    //         ++nbJZoom; 
     2313    //     } 
     2314    //     count_write_index_[0] = nbIZoom; 
     2315    //     count_write_index_[1] = nbJZoom; 
     2316 
     2317    //     // Reoder the zoom_index 
     2318    //     for (int j = 0; j < nbJZoom; ++j) 
     2319    //       for (int i = 0; i < nbIZoom; ++i) 
     2320    //       { 
     2321    //         idx = nbIZoom * j + i; 
     2322    //         if (idx < ni_zoom) 
     2323    //         { 
     2324    //           zoom_i_index(idx) = ibegin + i; 
     2325    //           zoom_j_index(idx) = jbegin + j; 
     2326    //         } 
     2327    //       }   
     2328 
     2329    //     // Reorder the global index 
     2330    //     for (int j = 0; j < nj; ++j) 
     2331    //       for (int i = 0; i < ni; ++i) 
     2332    //       { 
     2333    //         idx = ni * j + i; 
     2334    //         if (idx < nbIndGlob) 
     2335    //         { 
     2336    //           i_index(idx) = ibegin + i; 
     2337    //           j_index(idx) = jbegin + j; 
     2338    //         } 
     2339    //       }          
     2340    //   } 
     2341 
    22552342             
    2256       MPI_Scan(&count_write_index_[0], &start_write_index_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 
    2257       if ((this->type) != CDomain::type_attr::unstructured) 
    2258       { 
    2259         start_write_index_[0] = 0; 
    2260         start_write_index_[1] -= count_write_index_[1]; 
    2261       } 
    2262       else 
    2263       { 
    2264         start_write_index_[0] -= count_write_index_[0]; 
    2265       } 
    2266       local_write_size_[0] = count_write_index_[0]; 
    2267       local_write_size_[1] = count_write_index_[1]; 
    2268       MPI_Allreduce(&count_write_index_[0], &global_write_size_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 
    2269       if ((this->type) != CDomain::type_attr::unstructured) 
    2270       { 
    2271         global_write_size_[0] = count_write_index_[0]; 
    2272         global_write_size_[1] = (global_write_size_[1] > nj_glo) ? nj_glo : global_write_size_[1]; 
    2273       } 
    2274     } 
     2343    //   MPI_Scan(&count_write_index_[0], &start_write_index_[0], 2, MPI_INT, MPI_SUM, server->intraComm);       
     2344    //   start_write_index_[0] = 0;  
     2345    //   start_write_index_[1] -= count_write_index_[1]; 
     2346    //   local_write_size_[0] = count_write_index_[0]; 
     2347    //   local_write_size_[1] = count_write_index_[1]; 
     2348    //   MPI_Allreduce(&count_write_index_[0], &global_write_size_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 
     2349    //   global_write_size_[0] = count_write_index_[0]; 
     2350    //   global_write_size_[1] = (global_write_size_[1] > nj_glo) ? nj_glo : global_write_size_[1]; 
     2351          
     2352 
     2353    // } 
    22752354 
    22762355    // int type_int; 
     
    22892368 
    22902369  /*! 
     2370    Receive attributes event from clients(s) 
     2371    \param[in] event event contain info about rank and associated attributes 
     2372  */ 
     2373  void CDomain::recvDistributionAttributes(CEventServer& event) 
     2374  { 
     2375    CBufferIn* buffer=event.subEvents.begin()->buffer; 
     2376    string domainId ; 
     2377    *buffer>>domainId ; 
     2378    get(domainId)->recvDistributionAttributes(*buffer); 
     2379  } 
     2380 
     2381  /*! 
     2382    Receive attributes from client(s): zoom info and begin and n of each server 
     2383    \param[in] rank rank of client source 
     2384    \param[in] buffer message containing attributes info 
     2385  */ 
     2386  void CDomain::recvDistributionAttributes(CBufferIn& buffer) 
     2387  { 
     2388    int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 
     2389    int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; 
     2390    buffer >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp 
     2391           >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp            
     2392           >> isCompressible_; 
     2393    ni.setValue(ni_tmp); 
     2394    ibegin.setValue(ibegin_tmp); 
     2395    nj.setValue(nj_tmp); 
     2396    jbegin.setValue(jbegin_tmp); 
     2397 
     2398    global_zoom_ni.setValue(global_zoom_ni_tmp); 
     2399    global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); 
     2400    global_zoom_nj.setValue(global_zoom_nj_tmp); 
     2401    global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); 
     2402 
     2403    int iend = ibegin + ni  - 1; 
     2404    int jend = jbegin + nj  - 1; 
     2405    int zoom_iend_glob = global_zoom_ibegin + global_zoom_ni - 1; 
     2406    int zoom_jend_glob = global_zoom_jbegin + global_zoom_nj - 1; 
     2407 
     2408    zoom_ibegin.setValue(global_zoom_ibegin > ibegin ? global_zoom_ibegin : ibegin); 
     2409    int zoom_iend = zoom_iend_glob < iend ? zoom_iend_glob : iend ; 
     2410    zoom_ni.setValue(zoom_iend-zoom_ibegin+1); 
     2411 
     2412    zoom_jbegin.setValue(global_zoom_jbegin > jbegin ? global_zoom_jbegin : jbegin); 
     2413    int zoom_jend = zoom_jend_glob < jend ? zoom_jend_glob : jend ; 
     2414    zoom_nj.setValue(zoom_jend-zoom_jbegin+1); 
     2415 
     2416    if (zoom_ni<=0 || zoom_nj<=0) 
     2417    { 
     2418      zoom_ibegin=0 ; zoom_iend=0 ; zoom_ni=0 ; 
     2419      zoom_jbegin=0 ; zoom_jend=0 ; zoom_nj=0 ; 
     2420    } 
     2421 
     2422  } 
     2423 
     2424  /*! 
    22912425    Receive area event from clients(s) 
    22922426    \param[in] event event contain info about rank and associated area 
     
    23722506  void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 
    23732507  { 
    2374     int nbReceived = rankBuffers.size(), i, ind, index; 
     2508    int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex; 
    23752509    if (nbReceived != recvClientRanks_.size()) 
    23762510      ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", 
     
    23912525    } 
    23922526 
    2393     int nbLonInd = 0; 
     2527    lonvalue.resize(zoom_ni*zoom_nj); 
     2528    lonvalue = 0; 
     2529 
     2530    if (hasBounds) 
     2531    { 
     2532      bounds_lonvalue.resize(nvertex,zoom_ni*zoom_nj); 
     2533      bounds_lonvalue = 0.; 
     2534    } 
     2535     
    23942536    for (i = 0; i < nbReceived; ++i) 
    23952537    { 
    2396       nbLonInd += recvLonValue[i].numElements(); 
    2397     } 
    2398  
    2399     lonvalue.resize(nbLonInd); 
    2400     if (hasBounds) 
    2401     { 
    2402       bounds_lonvalue.resize(nvertex, nbLonInd); 
    2403     } 
    2404  
    2405     nbLonInd = 0; 
    2406     for (i = 0; i < nbReceived; ++i) 
    2407     { 
    2408       CArray<double,1>& tmp = recvLonValue[i]; 
    2409       for (ind = 0; ind < tmp.numElements(); ++ind) 
    2410       { 
    2411          lonvalue(nbLonInd) = tmp(ind); 
     2538      int rank = recvClientRanks_[i]; 
     2539      CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank];       
     2540      for (ind = 0; ind < indi.numElements(); ++ind) 
     2541      { 
     2542         iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 
     2543         index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 
     2544         lonvalue(index) = recvLonValue[i](ind); 
    24122545         if (hasBounds) 
    2413          { 
    2414           CArray<double,2>& tmpBnds = recvBoundsLonValue[i]; 
     2546         {           
    24152547          for (int nv = 0; nv < nvertex; ++nv) 
    2416             bounds_lonvalue(nv, nbLonInd) = tmpBnds(nv, ind); 
    2417          }        
    2418          ++nbLonInd; 
     2548            bounds_lonvalue(nv, index) = recvBoundsLonValue[i](nv, ind); 
     2549         }          
    24192550      } 
    24202551    } 
     
    24462577  void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 
    24472578  { 
    2448     int nbReceived = rankBuffers.size(), i, ind, index; 
     2579    int nbReceived = rankBuffers.size(), i, ind, index, iindex, jindex; 
    24492580    if (nbReceived != recvClientRanks_.size()) 
    24502581      ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 
     
    24652596    } 
    24662597 
    2467     int nbLatInd = 0; 
     2598    latvalue.resize(zoom_ni*zoom_nj); 
     2599    latvalue = 0; 
     2600 
     2601    if (hasBounds) 
     2602    { 
     2603      bounds_latvalue.resize(nvertex,zoom_ni*zoom_nj); 
     2604      bounds_latvalue = 0. ; 
     2605    } 
     2606     
    24682607    for (i = 0; i < nbReceived; ++i) 
    24692608    { 
    2470       nbLatInd += recvLatValue[i].numElements(); 
    2471     } 
    2472  
    2473     latvalue.resize(nbLatInd); 
    2474     if (hasBounds) 
    2475     { 
    2476       bounds_latvalue.resize(nvertex, nbLatInd); 
    2477     } 
    2478      
    2479     nbLatInd = 0; 
    2480     for (i = 0; i < nbReceived; ++i) 
    2481     { 
    2482       CArray<double,1>& tmp = recvLatValue[i]; 
    2483       for (ind = 0; ind < tmp.numElements(); ++ind) 
    2484       {          
    2485          latvalue(nbLatInd) = tmp(ind); 
     2609      int rank = recvClientRanks_[i]; 
     2610      CArray<int,1> &indi = indGlob_[rank], &indj = indGlob_[rank]; 
     2611      CArray<double,1>& lat = recvLatValue[i]; 
     2612      for (ind = 0; ind < indi.numElements(); ++ind) 
     2613      { 
     2614         iindex = indi(ind) % ni_glo; jindex = indj(ind) / ni_glo; 
     2615         index = (iindex - zoom_ibegin) + (jindex - zoom_jbegin) * zoom_ni; 
     2616         latvalue(index) = lat(ind); 
    24862617         if (hasBounds) 
    24872618         { 
    2488           CArray<double,2>& tmpBnds = recvBoundsLatValue[i]; 
     2619          CArray<double,2>& boundslat = recvBoundsLatValue[i]; 
    24892620          for (int nv = 0; nv < nvertex; ++nv) 
    2490             bounds_latvalue(nv, nbLatInd) = tmpBnds(nv, ind); 
    2491          }        
    2492          ++nbLatInd; 
     2621            bounds_latvalue(nv, index) = boundslat(nv, ind); 
     2622         }          
    24932623      } 
    24942624    } 
Note: See TracChangeset for help on using the changeset viewer.