Ignore:
Timestamp:
01/14/19 13:33:48 (5 years ago)
Author:
oabramkina
Message:

Merging dev to trunk. Major changes:

(1) Grid mask is applied in the source filter of clients: unmasked values are replaced by NaN. It is not reconstructed any more by servers.

(2) Domain/axis mask has been incorporated into data index, with only data index sent to servers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/axis.cpp

    r1622 r1637  
    274274   TRY 
    275275   { 
    276       if (this->n_glo.isEmpty()) 
     276     CContext* context=CContext::getCurrent(); 
     277 
     278     if (this->n_glo.isEmpty()) 
    277279        ERROR("CAxis::checkAttributes(void)", 
    278280              << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     
    314316      } 
    315317 
    316       // Remove this check because it doesn't make sense in case of a hole or overlapping axes 
    317318      if (!this->value.isEmpty()) 
    318319      { 
    319 //        StdSize true_size = value.numElements(); 
    320 //        if (this->n.getValue() != true_size) 
    321 //          ERROR("CAxis::checkAttributes(void)", 
    322 //                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
    323 //                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     320        // Avoid this check at writing because it fails in case of a hole 
     321        if (context->hasClient) 
     322        { 
     323          StdSize true_size = value.numElements(); 
     324          if (this->n.getValue() != true_size) 
     325            ERROR("CAxis::checkAttributes(void)", 
     326                << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 
     327                << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size 
     328                << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 
     329        } 
    324330        this->hasValue = true; 
    325331      } 
     
    327333      this->checkBounds(); 
    328334 
    329       CContext* context=CContext::getCurrent(); 
    330335      if (context->hasClient) 
    331336      { 
     337        this->checkMask(); 
    332338        this->checkData(); 
    333         this->checkMask(); 
    334339        this->checkLabel(); 
    335340      } 
     
    338343 
    339344   /*! 
    340       Check the validity of data and fill in values if any. 
     345      Check the validity of data, fill in values if any, and apply mask. 
    341346   */ 
    342347   void CAxis::checkData() 
     
    359364      { 
    360365        data_index.resize(data_n); 
    361         for (int i = 0; i < data_n; ++i) data_index(i) = i; 
    362       } 
     366        for (int i = 0; i < data_n; ++i) 
     367        { 
     368          if ((i+data_begin) >= 0 && (i+data_begin<n)) 
     369          { 
     370            if (mask(i+data_begin)) 
     371              data_index(i) = i+data_begin; 
     372            else 
     373              data_index(i) = -1; 
     374          } 
     375          else 
     376            data_index(i) = -1; 
     377        } 
     378      } 
     379      else 
     380      { 
     381        if (data_index.numElements() != data_n) 
     382        { 
     383          ERROR("CAxis::checkData(void)", 
     384                << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     385                << "The size of data_index = "<< data_index.numElements() << "is not equal to the data size data_n = " << data_n.getValue() << ")."); 
     386        } 
     387        for (int i = 0; i < data_n; ++i) 
     388        { 
     389          if ((i+data_begin) >= 0 && (i+data_begin<n) && !mask(i+data_begin)) 
     390            data_index(i) = -1; 
     391        } 
     392      } 
     393 
    363394   } 
    364395   CATCH_DUMP_ATTR 
     
    377408      if (!mask.isEmpty()) 
    378409      { 
    379          if (mask.extent(0) != n) 
    380            ERROR("CAxis::checkMask(void)", 
    381                  << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
    382                  << "The mask does not have the same size as the local domain." << std::endl 
    383                  << "Local size is " << n.getValue() << "." << std::endl 
    384                  << "Mask size is " << mask.extent(0) << "."); 
    385       } 
    386       else // (mask.isEmpty()) 
    387       { // If no mask was defined, we create a default one without any masked point. 
    388          mask.resize(n); 
    389          for (int i = 0; i < n; ++i) 
    390          { 
    391            mask(i) = true; 
    392          } 
     410        if (mask.extent(0) != n) 
     411        { 
     412          ERROR("CAxis::checkMask(void)", 
     413              << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 
     414              << "The mask does not have the same size as the local domain." << std::endl 
     415              << "Local size is " << n.getValue() << "." << std::endl 
     416              << "Mask size is " << mask.extent(0) << "."); 
     417        } 
     418      } 
     419      else 
     420      { 
     421        mask.resize(n); 
     422        mask = true; 
    393423      } 
    394424   } 
     
    598628 
    599629        // Calculate the compressed index if any 
    600         std::set<int> writtenInd; 
    601         if (isCompressible_) 
    602         { 
    603           for (int idx = 0; idx < data_index.numElements(); ++idx) 
    604           { 
    605             int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
    606  
    607             if (ind >= 0 && ind < ni && mask(ind)) 
    608             { 
    609               ind += ibegin; 
    610               writtenInd.insert(ind); 
    611             } 
    612           } 
    613         } 
     630//        std::set<int> writtenInd; 
     631//        if (isCompressible_) 
     632//        { 
     633//          for (int idx = 0; idx < data_index.numElements(); ++idx) 
     634//          { 
     635//            int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
     636// 
     637//            if (ind >= 0 && ind < ni && mask(ind)) 
     638//            { 
     639//              ind += ibegin; 
     640//              writtenInd.insert(ind); 
     641//            } 
     642//          } 
     643//        } 
    614644 
    615645        // Compute the global index of the current client (process) hold 
     
    680710          connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 
    681711 
    682          nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
     712        nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 
    683713 
    684714        delete clientServerMap; 
     
    718748    CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 
    719749                                     itSrve = writtenGlobalIndex.end(), itSrv;   
     750 
     751    localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
     752    nbWritten = 0; 
    720753    for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    721754    { 
     
    723756      if (ite != globalLocalIndexMap_.find(indGlo)) 
    724757      { 
    725         ++nbWritten; 
    726       } 
    727     } 
    728  
    729     localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 
    730 //      localIndexToWriteOnServer.resize(nbWritten); 
    731  
    732     nbWritten = 0; 
    733     for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 
    734     { 
    735       indGlo = *itSrv; 
    736       if (ite != globalLocalIndexMap_.find(indGlo)) 
    737       { 
    738758        localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 
    739         ++nbWritten; 
    740       } 
    741     } 
     759      } 
     760      else 
     761      { 
     762        localIndexToWriteOnServer(nbWritten) = -1; 
     763      } 
     764      ++nbWritten; 
     765    } 
     766 
    742767  } 
    743768  CATCH_DUMP_ATTR 
     
    780805        }                  
    781806      } 
     807// 
     808//      nbWritten = 0; 
     809//      for (int idx = 0; idx < data_index.numElements(); ++idx) 
     810//      { 
     811//        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
     812//        { 
     813//          ++nbWritten; 
     814//        } 
     815//      } 
     816// 
     817//      compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); 
     818//      nbWritten = 0; 
     819//      for (int idx = 0; idx < data_index.numElements(); ++idx) 
     820//      { 
     821//        if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 
     822//        { 
     823//          compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)]; 
     824//          ++nbWritten; 
     825//        } 
     826//      } 
    782827 
    783828      nbWritten = 0; 
     
    10271072 
    10281073  /* 
    1029     Send attributes of axis from a group of client to other group of clients/servers  
    1030     on supposing that these attributes are distributed among the clients of the sending group 
    1031     In the future, if new attributes are added, they should also be processed in this function 
     1074    Send axis attributes from a group of clients to another group of clients/servers 
     1075    supposing that these attributes are distributed among the clients of the sending group 
     1076    In future, if new attributes are added, they should also be processed in this function 
    10321077  */ 
    10331078  void CAxis::sendDistributedAttributes(void) 
    10341079  TRY 
    10351080  { 
    1036     int ns, n, i, j, ind, nv, idx; 
     1081    int ind, idx; 
    10371082    std::list<CContextClient*>::iterator it; 
    10381083 
     
    10461091      list<CMessage> listData; 
    10471092      list<CArray<int,1> > list_indi, list_dataInd; 
    1048       list<CArray<bool,1> > list_mask; 
    10491093      list<CArray<double,1> > list_val; 
    10501094      list<CArray<double,2> > list_bounds; 
    10511095      list<CArray<string,1> > list_label; 
    10521096 
     1097      // Cut off the ghost points 
    10531098      int nbIndex = index.numElements(); 
    10541099      CArray<int,1> dataIndex(nbIndex); 
     
    10571102      { 
    10581103        if (0 <= data_index(idx) && data_index(idx) < nbIndex) 
    1059           dataIndex(idx) = 1; 
     1104          dataIndex(data_index(idx)) = 1; 
    10601105      } 
    10611106 
     
    10641109      for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 
    10651110      { 
    1066         int nbData = 0; 
     1111        int nbData = 0, nbDataCount = 0; 
    10671112        int rank = connectedServerRank_[nbServer][k]; 
    10681113        it = indSrv_[nbServer].find(rank); 
     
    10711116 
    10721117        list_indi.push_back(CArray<int,1>(nbData)); 
    1073         list_dataInd.push_back(CArray<int,1>(nbData));         
    1074         list_mask.push_back(CArray<bool,1>(nbData)); 
     1118        list_dataInd.push_back(CArray<int,1>(nbData)); 
    10751119 
    10761120        if (hasValue) 
     
    10841128 
    10851129        CArray<int,1>& indi = list_indi.back(); 
    1086         CArray<int,1>& dataIndi = list_dataInd.back();         
    1087         CArray<bool,1>& maskIndi = list_mask.back(); 
    1088  
    1089         for (n = 0; n < nbData; ++n) 
     1130        CArray<int,1>& dataIndi = list_dataInd.back(); 
     1131        dataIndi = -1; 
     1132 
     1133        for (int n = 0; n < nbData; ++n) 
    10901134        { 
    10911135          idx = static_cast<int>(it->second[n]); 
     
    10941138          ind = globalLocalIndexMap_[idx]; 
    10951139          dataIndi(n) = dataIndex(ind); 
    1096           maskIndi(n) = mask(ind); 
    10971140 
    10981141          if (hasValue) 
     
    11181161        listData.push_back(CMessage()); 
    11191162        listData.back() << this->getId() 
    1120                         << list_indi.back() << list_dataInd.back() << list_mask.back(); 
     1163                        << list_indi.back() << list_dataInd.back(); 
    11211164 
    11221165        listData.back() << hasValue; 
     
    11731216    int nbReceived = ranks.size(), idx, ind, gloInd, locInd; 
    11741217    vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived); 
    1175     vector<CArray<bool,1> > vec_mask(nbReceived); 
    11761218    vector<CArray<double,1> > vec_val(nbReceived); 
    11771219    vector<CArray<double,2> > vec_bounds(nbReceived); 
     
    11831225      buffer >> vec_indi[idx]; 
    11841226      buffer >> vec_dataInd[idx];       
    1185       buffer >> vec_mask[idx]; 
    11861227 
    11871228      buffer >> hasValue; 
     
    12201261         if (0 == globalLocalIndexMap_.count(gloInd)) 
    12211262         { 
    1222            index(nbIndLoc) = gloInd % n_glo; 
    1223            globalLocalIndexMap_[gloInd] = nbIndLoc; 
     1263           index(nbIndexGlob) = gloInd % n_glo; 
     1264           globalLocalIndexMap_[gloInd] = nbIndexGlob; 
    12241265           ++nbIndexGlob; 
    12251266         }  
     
    12341275    CArray<int,1> nonCompressedData(nbData); 
    12351276    nonCompressedData = -1;    
    1236     mask.resize(nbData); 
     1277    // Mask is incorporated into data_index and is not sent/received anymore 
     1278    mask.resize(0); 
    12371279    if (hasValue) 
    12381280      value.resize(nbData); 
     
    12471289      CArray<int,1>& indi = vec_indi[idx]; 
    12481290      CArray<int,1>& dataIndi = vec_dataInd[idx]; 
    1249       CArray<bool,1>& maskIndi = vec_mask[idx]; 
    12501291      int nb = indi.numElements(); 
    12511292      for (int n = 0; n < nb; ++n) 
     
    12551296        nonCompressedData(locInd) = (-1 == nonCompressedData(locInd)) ? dataIndi(n) : nonCompressedData(locInd); 
    12561297 
    1257         if (!mask(locInd)) // Only rewrite mask if it's not true 
    1258           mask(locInd) = maskIndi(n); 
    1259          
    12601298        if (hasValue) 
    12611299          value(locInd) = vec_val[idx](n); 
     
    12721310    } 
    12731311     
    1274     int nbCompressedData = 0;  
     1312    int nbCompressedData = 0; 
    12751313    for (idx = 0; idx < nonCompressedData.numElements(); ++idx) 
    12761314    { 
    12771315      if (0 <= nonCompressedData(idx)) 
    1278         ++nbCompressedData;         
     1316        ++nbCompressedData; 
    12791317    } 
    12801318 
     
    12861324      { 
    12871325        data_index(nbCompressedData) = idx % n; 
    1288         ++nbCompressedData;         
     1326        ++nbCompressedData; 
    12891327      } 
    12901328    } 
    12911329 
    12921330    data_begin.setValue(0); 
     1331    data_n.setValue(data_index.numElements()); 
    12931332  } 
    12941333  CATCH_DUMP_ATTR 
Note: See TracChangeset for help on using the changeset viewer.