Changeset 1870 for XIOS


Ignore:
Timestamp:
04/17/20 18:55:28 (4 years ago)
Author:
ymipsl
Message:

Some update on XIOS_COUPLING branch...

YM

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp

    r1869 r1870  
    546546 
    547547   */ 
     548   //ym obsolete : to be removed 
    548549   void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
    549550                                     CServerDistributionDescription::ServerDistributionType distType) 
     
    555556 
    556557     if (this->isChecked) return; 
    557      if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) sendAttributes(globalDim, orderPositionInGrid, distType);     
     558     if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) /*sendAttributes(globalDim, orderPositionInGrid, distType)*/;     
    558559 
    559560     this->isChecked = true; 
    560561   } 
    561562   CATCH_DUMP_ATTR 
     563 
     564   
     565   void CAxis::sendAxisToFileServer(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid) 
     566   { 
     567     if (sendAxisToFileServer_done_.count(client)!=0) return ; 
     568     else sendAxisToFileServer_done_.insert(client) ; 
     569      
     570     StdString axisDefRoot("axis_definition"); 
     571     CAxisGroup* axisPtr = CAxisGroup::get(axisDefRoot); 
     572     axisPtr->sendCreateChild(this->getId(),client); 
     573     this->sendAllAttributesToServer(client)  ;  
     574     this->sendAttributes(client, globalDim, orderPositionInGrid, CServerDistributionDescription::BAND_DISTRIBUTION) ; 
     575   } 
    562576 
    563577  /*! 
     
    566580    \param[in] order 
    567581  */ 
    568   void CAxis::sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
     582  void CAxis::sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 
    569583                             CServerDistributionDescription::ServerDistributionType distType) 
    570584  TRY 
    571585  { 
    572      sendDistributionAttribute(globalDim, orderPositionInGrid, distType); 
     586     sendDistributionAttribute(client, globalDim, orderPositionInGrid, distType); 
    573587 
    574588     // if (index.numElements() == n_glo.getValue()) 
     
    576590         || (index.numElements() != n_glo)) 
    577591     { 
    578        sendDistributedAttributes();        
     592       sendDistributedAttributes(client);        
    579593     } 
    580594     else 
    581595     { 
    582        sendNonDistributedAttributes();     
     596       sendNonDistributedAttributes(client);     
    583597     }      
    584598  } 
     
    874888    \param [in] distType distribution type of the server. For now, we only have band distribution. 
    875889  */ 
    876   void CAxis::sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid, 
     890  void CAxis::sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 
    877891                                        CServerDistributionDescription::ServerDistributionType distType) 
    878892  TRY 
    879893  { 
    880     std::list<CContextClient*>::iterator it; 
    881     for (it=clients.begin(); it!=clients.end(); ++it) 
    882     { 
    883       CContextClient* client = *it; 
    884       int nbServer = client->serverSize; 
    885  
    886       CServerDistributionDescription serverDescription(globalDim, nbServer); 
    887       serverDescription.computeServerDistribution(); 
    888  
    889       std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
    890       std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
    891  
    892       CEventClient event(getType(),EVENT_ID_DISTRIBUTION_ATTRIBUTE); 
    893       if (client->isServerLeader()) 
    894       { 
    895         std::list<CMessage> msgs; 
    896  
    897         const std::list<int>& ranks = client->getRanksServerLeader(); 
    898         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    899         { 
    900           // Use const int to ensure CMessage holds a copy of the value instead of just a reference 
    901           const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 
    902           const int ni    = serverDimensionSizes[*itRank][orderPositionInGrid]; 
    903  
    904           msgs.push_back(CMessage()); 
    905           CMessage& msg = msgs.back(); 
    906           msg << this->getId(); 
    907           msg << ni << begin; 
    908           msg << isCompressible_;                     
    909  
    910           event.push(*itRank,1,msg); 
    911         } 
    912         client->sendEvent(event); 
    913       } 
    914       else client->sendEvent(event); 
    915     } 
     894    int nbServer = client->serverSize; 
     895 
     896    CServerDistributionDescription serverDescription(globalDim, nbServer); 
     897    serverDescription.computeServerDistribution(); 
     898 
     899    std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
     900    std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
     901 
     902    CEventClient event(getType(),EVENT_ID_DISTRIBUTION_ATTRIBUTE); 
     903    if (client->isServerLeader()) 
     904    { 
     905      std::list<CMessage> msgs; 
     906 
     907      const std::list<int>& ranks = client->getRanksServerLeader(); 
     908      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     909      { 
     910        // Use const int to ensure CMessage holds a copy of the value instead of just a reference 
     911        const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 
     912        const int ni    = serverDimensionSizes[*itRank][orderPositionInGrid]; 
     913 
     914        msgs.push_back(CMessage()); 
     915        CMessage& msg = msgs.back(); 
     916        msg << this->getId(); 
     917        msg << ni << begin; 
     918        msg << isCompressible_;                     
     919 
     920        event.push(*itRank,1,msg); 
     921      } 
     922      client->sendEvent(event); 
     923    } 
     924    else client->sendEvent(event); 
    916925  } 
    917926  CATCH_DUMP_ATTR 
     
    953962    In the future, if new attributes are added, they should also be processed in this function 
    954963  */ 
    955   void CAxis::sendNonDistributedAttributes() 
    956   TRY 
    957   { 
    958     std::list<CContextClient*>::iterator it; 
    959     for (it=clients.begin(); it!=clients.end(); ++it) 
    960         { 
    961           CContextClient* client = *it; 
    962  
    963       CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); 
    964       size_t nbIndex = index.numElements(); 
    965       size_t nbDataIndex = 0; 
    966  
    967       for (int idx = 0; idx < data_index.numElements(); ++idx) 
    968       { 
    969         int ind = data_index(idx); 
    970         if (ind >= 0 && ind < nbIndex) ++nbDataIndex; 
    971       } 
    972  
    973       CArray<int,1> dataIndex(nbDataIndex); 
    974       nbDataIndex = 0; 
    975       for (int idx = 0; idx < data_index.numElements(); ++idx) 
    976       { 
    977         int ind = data_index(idx); 
    978         if (ind >= 0 && ind < nbIndex) 
    979         { 
    980           dataIndex(nbDataIndex) = ind; 
    981           ++nbDataIndex; 
    982         } 
    983       } 
    984  
    985       if (client->isServerLeader()) 
    986       { 
    987         std::list<CMessage> msgs; 
    988  
    989         const std::list<int>& ranks = client->getRanksServerLeader(); 
    990         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    991         { 
    992           msgs.push_back(CMessage()); 
    993           CMessage& msg = msgs.back(); 
    994           msg << this->getId(); 
    995           msg << index.getValue() << dataIndex << mask.getValue(); 
    996           msg << hasValue; 
    997           if (hasValue) msg << value.getValue(); 
    998           msg << hasBounds; 
    999           if (hasBounds) msg << bounds.getValue(); 
    1000           msg << hasLabel; 
    1001           if (hasLabel) msg << label.getValue(); 
    1002  
    1003           event.push(*itRank, 1, msg); 
    1004         } 
    1005         client->sendEvent(event); 
    1006       } 
    1007       else client->sendEvent(event); 
    1008     } 
     964  void CAxis::sendNonDistributedAttributes(CContextClient* client) 
     965  TRY 
     966  { 
     967    CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); 
     968    size_t nbIndex = index.numElements(); 
     969    size_t nbDataIndex = 0; 
     970 
     971    for (int idx = 0; idx < data_index.numElements(); ++idx) 
     972    { 
     973      int ind = data_index(idx); 
     974      if (ind >= 0 && ind < nbIndex) ++nbDataIndex; 
     975    } 
     976 
     977    CArray<int,1> dataIndex(nbDataIndex); 
     978    nbDataIndex = 0; 
     979    for (int idx = 0; idx < data_index.numElements(); ++idx) 
     980    { 
     981      int ind = data_index(idx); 
     982      if (ind >= 0 && ind < nbIndex) 
     983      { 
     984        dataIndex(nbDataIndex) = ind; 
     985        ++nbDataIndex; 
     986      } 
     987    } 
     988 
     989    if (client->isServerLeader()) 
     990    { 
     991      std::list<CMessage> msgs; 
     992 
     993      const std::list<int>& ranks = client->getRanksServerLeader(); 
     994      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     995      { 
     996        msgs.push_back(CMessage()); 
     997        CMessage& msg = msgs.back(); 
     998        msg << this->getId(); 
     999        msg << index.getValue() << dataIndex << mask.getValue(); 
     1000        msg << hasValue; 
     1001        if (hasValue) msg << value.getValue(); 
     1002        msg << hasBounds; 
     1003        if (hasBounds) msg << bounds.getValue(); 
     1004        msg << hasLabel; 
     1005        if (hasLabel) msg << label.getValue(); 
     1006 
     1007        event.push(*itRank, 1, msg); 
     1008      } 
     1009      client->sendEvent(event); 
     1010    } 
     1011    else client->sendEvent(event); 
    10091012  } 
    10101013  CATCH_DUMP_ATTR 
     
    10831086    In future, if new attributes are added, they should also be processed in this function 
    10841087  */ 
    1085   void CAxis::sendDistributedAttributes(void) 
     1088  void CAxis::sendDistributedAttributes(CContextClient* client) 
    10861089  TRY 
    10871090  { 
    10881091    int ind, idx; 
    1089     std::list<CContextClient*>::iterator it; 
    1090  
    1091     for (it=clients.begin(); it!=clients.end(); ++it) 
    1092     { 
    1093       CContextClient* client = *it; 
    1094       int nbServer = client->serverSize; 
    1095  
    1096       CEventClient eventData(getType(), EVENT_ID_DISTRIBUTED_ATTRIBUTES); 
    1097  
    1098       list<CMessage> listData; 
    1099       list<CArray<int,1> > list_indi, list_dataInd; 
    1100       list<CArray<double,1> > list_val; 
    1101       list<CArray<double,2> > list_bounds; 
    1102       list<CArray<string,1> > list_label; 
    1103  
    1104       // Cut off the ghost points 
    1105       int nbIndex = index.numElements(); 
    1106       CArray<int,1> dataIndex(nbIndex); 
    1107       dataIndex = -1; 
    1108       for (idx = 0; idx < data_index.numElements(); ++idx) 
    1109       { 
    1110         if (0 <= data_index(idx) && data_index(idx) < nbIndex) 
    1111           dataIndex(data_index(idx)) = 1; 
    1112       } 
    1113  
    1114       std::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap; 
    1115       iteMap = indSrv_[nbServer].end(); 
    1116       for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 
    1117       { 
    1118         int nbData = 0, nbDataCount = 0; 
    1119         int rank = connectedServerRank_[nbServer][k]; 
    1120         it = indSrv_[nbServer].find(rank); 
    1121         if (iteMap != it) 
    1122           nbData = it->second.size(); 
    1123  
    1124         list_indi.push_back(CArray<int,1>(nbData)); 
    1125         list_dataInd.push_back(CArray<int,1>(nbData)); 
     1092    int nbServer = client->serverSize; 
     1093 
     1094    CEventClient eventData(getType(), EVENT_ID_DISTRIBUTED_ATTRIBUTES); 
     1095 
     1096    list<CMessage> listData; 
     1097    list<CArray<int,1> > list_indi, list_dataInd; 
     1098    list<CArray<double,1> > list_val; 
     1099    list<CArray<double,2> > list_bounds; 
     1100    list<CArray<string,1> > list_label; 
     1101 
     1102    // Cut off the ghost points 
     1103    int nbIndex = index.numElements(); 
     1104    CArray<int,1> dataIndex(nbIndex); 
     1105    dataIndex = -1; 
     1106    for (idx = 0; idx < data_index.numElements(); ++idx) 
     1107    { 
     1108      if (0 <= data_index(idx) && data_index(idx) < nbIndex) 
     1109        dataIndex(data_index(idx)) = 1; 
     1110    } 
     1111 
     1112    std::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap; 
     1113    iteMap = indSrv_[nbServer].end(); 
     1114    for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 
     1115    { 
     1116      int nbData = 0, nbDataCount = 0; 
     1117      int rank = connectedServerRank_[nbServer][k]; 
     1118      it = indSrv_[nbServer].find(rank); 
     1119      if (iteMap != it) 
     1120        nbData = it->second.size(); 
     1121 
     1122      list_indi.push_back(CArray<int,1>(nbData)); 
     1123      list_dataInd.push_back(CArray<int,1>(nbData)); 
     1124 
     1125      if (hasValue) 
     1126        list_val.push_back(CArray<double,1>(nbData)); 
     1127 
     1128      if (hasBounds)         
     1129        list_bounds.push_back(CArray<double,2>(2,nbData)); 
     1130 
     1131      if (hasLabel) 
     1132        list_label.push_back(CArray<string,1>(nbData)); 
     1133 
     1134      CArray<int,1>& indi = list_indi.back(); 
     1135      CArray<int,1>& dataIndi = list_dataInd.back(); 
     1136      dataIndi = -1; 
     1137 
     1138      for (int n = 0; n < nbData; ++n) 
     1139      { 
     1140        idx = static_cast<int>(it->second[n]); 
     1141        indi(n) = idx; 
     1142 
     1143        ind = globalLocalIndexMap_[idx]; 
     1144        dataIndi(n) = dataIndex(ind); 
    11261145 
    11271146        if (hasValue) 
    1128           list_val.push_back(CArray<double,1>(nbData)); 
    1129  
    1130         if (hasBounds)         
    1131           list_bounds.push_back(CArray<double,2>(2,nbData)); 
     1147        { 
     1148          CArray<double,1>& val = list_val.back(); 
     1149          val(n) = value(ind); 
     1150        } 
     1151 
     1152        if (hasBounds) 
     1153        { 
     1154          CArray<double,2>& boundsVal = list_bounds.back(); 
     1155          boundsVal(0, n) = bounds(0,ind); 
     1156          boundsVal(1, n) = bounds(1,ind); 
     1157        } 
    11321158 
    11331159        if (hasLabel) 
    1134           list_label.push_back(CArray<string,1>(nbData)); 
    1135  
    1136         CArray<int,1>& indi = list_indi.back(); 
    1137         CArray<int,1>& dataIndi = list_dataInd.back(); 
    1138         dataIndi = -1; 
    1139  
    1140         for (int n = 0; n < nbData; ++n) 
    1141         { 
    1142           idx = static_cast<int>(it->second[n]); 
    1143           indi(n) = idx; 
    1144  
    1145           ind = globalLocalIndexMap_[idx]; 
    1146           dataIndi(n) = dataIndex(ind); 
    1147  
    1148           if (hasValue) 
    1149           { 
    1150             CArray<double,1>& val = list_val.back(); 
    1151             val(n) = value(ind); 
    1152           } 
    1153  
    1154           if (hasBounds) 
    1155           { 
    1156             CArray<double,2>& boundsVal = list_bounds.back(); 
    1157             boundsVal(0, n) = bounds(0,ind); 
    1158             boundsVal(1, n) = bounds(1,ind); 
    1159           } 
    1160  
    1161           if (hasLabel) 
    1162           { 
    1163             CArray<string,1>& labelVal = list_label.back(); 
    1164             labelVal(n) = label(ind);  
    1165           } 
    1166         } 
    1167  
    1168         listData.push_back(CMessage()); 
    1169         listData.back() << this->getId() 
    1170                         << list_indi.back() << list_dataInd.back(); 
    1171  
    1172         listData.back() << hasValue; 
    1173         if (hasValue) 
    1174           listData.back() << list_val.back(); 
    1175  
    1176         listData.back() << hasBounds; 
    1177         if (hasBounds) 
    1178           listData.back() << list_bounds.back(); 
    1179  
    1180         listData.back() << hasLabel; 
    1181         if (hasLabel) 
    1182           listData.back() << list_label.back(); 
    1183  
    1184         eventData.push(rank, nbSenders[nbServer][rank], listData.back()); 
    1185       } 
    1186  
    1187       client->sendEvent(eventData); 
    1188     } 
     1160        { 
     1161          CArray<string,1>& labelVal = list_label.back(); 
     1162          labelVal(n) = label(ind);  
     1163        } 
     1164      } 
     1165 
     1166      listData.push_back(CMessage()); 
     1167      listData.back() << this->getId() 
     1168                      << list_indi.back() << list_dataInd.back(); 
     1169 
     1170      listData.back() << hasValue; 
     1171      if (hasValue) 
     1172        listData.back() << list_val.back(); 
     1173 
     1174      listData.back() << hasBounds; 
     1175      if (hasBounds) 
     1176        listData.back() << list_bounds.back(); 
     1177 
     1178      listData.back() << hasLabel; 
     1179      if (hasLabel) 
     1180        listData.back() << list_label.back(); 
     1181 
     1182      eventData.push(rank, nbSenders[nbServer][rank], listData.back()); 
     1183    } 
     1184 
     1185    client->sendEvent(eventData); 
    11891186  } 
    11901187  CATCH_DUMP_ATTR 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp

    r1869 r1870  
    145145         void checkBounds(); 
    146146         void checkLabel(); 
    147          void sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
     147      public: 
     148         void sendAxisToFileServer(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid) ; 
     149      private: 
     150         std::set<CContextClient*> sendAxisToFileServer_done_ ; 
     151       
     152      private: 
     153         void sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 
    148154                             CServerDistributionDescription::ServerDistributionType distType); 
    149          void sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid, 
     155         void sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 
    150156                                        CServerDistributionDescription::ServerDistributionType distType); 
    151157          
    152158 
    153          void sendNonDistributedAttributes(void); 
    154          void sendDistributedAttributes(void); 
     159         void sendNonDistributedAttributes(CContextClient* client); 
     160         void sendDistributedAttributes(CContextClient* client); 
    155161 
    156162         static void recvNonDistributedAttributes(CEventServer& event); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp

    r1869 r1870  
    271271 
    272272 
     273   void CContext::setClientServerBuffer(vector<CField*>& fields, bool bufferForWriting) 
     274   TRY 
     275   { 
     276      // Estimated minimum event size for small events (20 is an arbitrary constant just for safety) 
     277     const size_t minEventSize = CEventClient::headerSize + 20 * sizeof(int); 
     278      // Ensure there is at least some room for 20 of such events in the buffers 
     279     size_t minBufferSize = std::max(CXios::minBufferSize, 20 * minEventSize); 
     280 
     281#define DECLARE_NODE(Name_, name_)    \ 
     282     if (minBufferSize < sizeof(C##Name_##Definition)) minBufferSize = sizeof(C##Name_##Definition); 
     283#define DECLARE_NODE_PAR(Name_, name_) 
     284#include "node_type.conf" 
     285#undef DECLARE_NODE 
     286#undef DECLARE_NODE_PAR 
     287 
     288 
     289     map<CContextClient*,map<int,size_t>> dataSize ; 
     290     map<CContextClient*,map<int,size_t>> maxEventSize ; 
     291     map<CContextClient*,map<int,size_t>> attributesSize ;   
     292 
     293     for(auto field : fields) 
     294     { 
     295       field->setContextClientDataBufferSize(dataSize, maxEventSize, bufferForWriting) ; 
     296       field->setContextClientAttributesBufferSize(attributesSize, maxEventSize, bufferForWriting) ; 
     297     } 
     298      
     299 
     300     for(auto& it : attributesSize) 
     301     { 
     302       auto contextClient = it.first ; 
     303       auto& contextDataSize =  dataSize[contextClient] ; 
     304       auto& contextAttributesSize =  attributesSize[contextClient] ; 
     305       auto& contextMaxEventSize =  maxEventSize[contextClient] ; 
     306    
     307       for (auto& it : contextAttributesSize) 
     308       { 
     309         auto serverRank=it.first ; 
     310         auto& buffer = contextAttributesSize[serverRank] ; 
     311         if (contextDataSize[serverRank] > buffer) buffer=contextDataSize[serverRank] ; 
     312         buffer *= CXios::bufferSizeFactor; 
     313         if (buffer < minBufferSize) buffer = minBufferSize; 
     314         if (buffer > CXios::maxBufferSize ) buffer = CXios::maxBufferSize; 
     315       } 
     316 
     317       // Leaders will have to send some control events so ensure there is some room for those in the buffers 
     318       if (contextClient->isServerLeader()) 
     319         for(auto& rank : contextClient->getRanksServerLeader()) 
     320           if (!contextAttributesSize.count(rank)) 
     321           { 
     322             contextAttributesSize[rank] = minBufferSize; 
     323             contextMaxEventSize[rank] = minEventSize; 
     324           } 
     325       
     326       contextClient->setBufferSize(contextAttributesSize, contextMaxEventSize);     
     327     } 
     328   } 
     329   CATCH_DUMP_ATTR 
     330 
     331 
    273332    /*! 
    274333    Sets client buffers. 
     
    277336    This flag is only true for client and server-1 for communication with server-2 
    278337  */ 
     338  // ym obsolete to be removed 
    279339   void CContext::setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting) 
    280340   TRY 
     
    327387   } 
    328388   CATCH_DUMP_ATTR 
     389 
     390 /*! 
     391    * Compute the required buffer size to send the fields data. 
     392    * \param maxEventSize [in/out] the size of the bigger event for each connected server 
     393    * \param [in] contextClient 
     394    * \param [in] bufferForWriting True if buffers are used for sending data for writing 
     395      This flag is only true for client and server-1 for communication with server-2 
     396    */ 
     397   std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize, 
     398                                                      CContextClient* contextClient, bool bufferForWriting /*= "false"*/) 
     399   TRY 
     400   { 
     401     std::map<int, StdSize> dataSize; 
     402 
     403     // Find all reference domain and axis of all active fields 
     404     std::vector<CFile*>& fileList = bufferForWriting ? this->enabledWriteModeFiles : this->enabledReadModeFiles; 
     405     size_t numEnabledFiles = fileList.size(); 
     406     for (size_t i = 0; i < numEnabledFiles; ++i) 
     407     { 
     408       CFile* file = fileList[i]; 
     409       if (file->getContextClient() == contextClient) 
     410       { 
     411         std::vector<CField*> enabledFields = file->getEnabledFields(); 
     412         size_t numEnabledFields = enabledFields.size(); 
     413         for (size_t j = 0; j < numEnabledFields; ++j) 
     414         { 
     415           // const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(contextClient); 
     416           const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataBufferSize(contextClient,bufferForWriting); 
     417           std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
     418           for (; it != itE; ++it) 
     419           { 
     420             // If dataSize[it->first] does not exist, it will be zero-initialized 
     421             // so we can use it safely without checking for its existance 
     422           if (CXios::isOptPerformance) 
     423               dataSize[it->first] += it->second; 
     424             else if (dataSize[it->first] < it->second) 
     425               dataSize[it->first] = it->second; 
     426 
     427           if (maxEventSize[it->first] < it->second) 
     428               maxEventSize[it->first] = it->second; 
     429           } 
     430         } 
     431       } 
     432     } 
     433     return dataSize; 
     434   } 
     435   CATCH_DUMP_ATTR 
     436 
     437/*! 
     438    * Compute the required buffer size to send the attributes (mostly those grid related). 
     439    * \param maxEventSize [in/out] the size of the bigger event for each connected server 
     440    * \param [in] contextClient 
     441    * \param [in] bufferForWriting True if buffers are used for sending data for writing 
     442      This flag is only true for client and server-1 for communication with server-2 
     443    */ 
     444   std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, 
     445                                                           CContextClient* contextClient, bool bufferForWriting /*= "false"*/) 
     446   TRY 
     447   { 
     448   // As calendar attributes are sent even if there are no active files or fields, maps are initialized according the size of calendar attributes 
     449     std::map<int, StdSize> attributesSize = CCalendarWrapper::get(CCalendarWrapper::GetDefName())->getMinimumBufferSizeForAttributes(contextClient); 
     450     maxEventSize = CCalendarWrapper::get(CCalendarWrapper::GetDefName())->getMinimumBufferSizeForAttributes(contextClient); 
     451 
     452     std::vector<CFile*>& fileList = this->enabledFiles; 
     453     size_t numEnabledFiles = fileList.size(); 
     454     for (size_t i = 0; i < numEnabledFiles; ++i) 
     455     { 
     456//         CFile* file = this->enabledWriteModeFiles[i]; 
     457        CFile* file = fileList[i]; 
     458        std::vector<CField*> enabledFields = file->getEnabledFields(); 
     459        size_t numEnabledFields = enabledFields.size(); 
     460        for (size_t j = 0; j < numEnabledFields; ++j) 
     461        { 
     462          const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient, bufferForWriting); 
     463          std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
     464          for (; it != itE; ++it) 
     465          { 
     466         // If attributesSize[it->first] does not exist, it will be zero-initialized 
     467         // so we can use it safely without checking for its existence 
     468             if (attributesSize[it->first] < it->second) 
     469         attributesSize[it->first] = it->second; 
     470 
     471         if (maxEventSize[it->first] < it->second) 
     472         maxEventSize[it->first] = it->second; 
     473          } 
     474        } 
     475     } 
     476     return attributesSize; 
     477   } 
     478   CATCH_DUMP_ATTR 
     479 
     480 
    329481 
    330482   //! Verify whether a context is initialized 
     
    8991051 
    9001052    // Find all enabled fields of each file       
    901     const vector<CField*>&& fileOutField = findAllEnabledFieldsInFileOut(this->enabledWriteModeFiles); 
    902     const vector<CField*>&& fileInField = findAllEnabledFieldsInFileIn(this->enabledReadModeFiles); 
    903     const vector<CField*>&& CouplerOutField = findAllEnabledFieldsCouplerOut(this->enabledCouplerOut); 
    904     const vector<CField*>&& CouplerInField = findAllEnabledFieldsCouplerIn(this->enabledCouplerIn); 
     1053    vector<CField*>&& fileOutField = findAllEnabledFieldsInFileOut(this->enabledWriteModeFiles); 
     1054    vector<CField*>&& fileInField = findAllEnabledFieldsInFileIn(this->enabledReadModeFiles); 
     1055    vector<CField*>&& CouplerOutField = findAllEnabledFieldsCouplerOut(this->enabledCouplerOut); 
     1056    vector<CField*>&& CouplerInField = findAllEnabledFieldsCouplerIn(this->enabledCouplerIn); 
    9051057    findFieldsWithReadAccess(); 
    906     const vector<CField*>& fieldWithReadAccess = fieldsWithReadAccess_ ; 
     1058    vector<CField*>& fieldWithReadAccess = fieldsWithReadAccess_ ; 
     1059    vector<CField*> fieldModelIn ; // fields potentially from model 
    9071060       
    9081061// find all field potentially at workflow end 
     
    9151068    for(auto endWorkflowField : endWorkflowFields) endWorkflowField->buildWorkflowGraph(garbageCollector) ; 
    9161069     
    917     // Distribute files between secondary servers according to the data size => assign a context to a file 
     1070    // get all field coming potentially from model 
     1071    for (auto field : CField::getAll() ) if (field->getModelIn()) fieldModelIn.push_back(field) ; 
     1072 
     1073    // Distribute files between secondary servers according to the data size => assign a context to a file and then to fields 
    9181074    if (serviceType_==CServicesManager::GATHERER) distributeFiles(this->enabledWriteModeFiles); 
    9191075    else if (serviceType_==CServicesManager::CLIENT) for(auto file : this->enabledWriteModeFiles) file->setContextClient(client) ; 
    9201076 
     1077    
     1078    // workflow endpoint => sent to IO/SERVER 
    9211079    if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) 
    9221080    { 
     
    9261084        field->computeGridIndexToFileServer() ; // compute grid index for transfer to the server context 
    9271085      } 
     1086      setClientServerBuffer(fileOutField, true) ; // set context 
     1087      for(auto field : fileOutField) field->sendFieldToFileServer() ; 
    9281088    } 
    929      
    930  
    931  
    932  
    933  
     1089 
     1090 
     1091    // workflow startpoint => data from model 
     1092    if (serviceType_==CServicesManager::CLIENT) 
     1093    { 
     1094      for(auto field : fieldModelIn)  
     1095      { 
     1096        field->connectToModelInput(garbageCollector) ; // connect the field to server filter 
     1097        // grid index will be computed on the fly 
     1098      } 
     1099    } 
     1100 
     1101   
     1102 
     1103 
     1104    return ; 
    9341105    // For now, only read files with client and only one level server 
    9351106    // if (hasClient && !hasServer) findEnabledReadModeFiles();       
     
    10571228  CATCH_DUMP_ATTR 
    10581229 
    1059  
     1230 /*! 
     1231  * Send context attribute and calendar to file server, it must be done once by context file server 
     1232  * \param[in] client : context client to send    
     1233  */   
     1234  void CContext::sendContextToFileServer(CContextClient* client) 
     1235  { 
     1236    if (sendToFileServer_done_.count(client)!=0) return ; 
     1237    else sendToFileServer_done_.insert(client) ; 
     1238     
     1239    this->sendAllAttributesToServer(client); // Send all attributes of current context to server 
     1240    CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(client); // Send all attributes of current cale 
     1241  } 
     1242 
     1243  // ym obsolete now to be removed 
    10601244   void CContext::closeDefinition_old(void) 
    10611245   TRY 
     
    20682252   CATCH_DUMP_ATTR 
    20692253 
    2070    /*! 
    2071     * Compute the required buffer size to send the attributes (mostly those grid related). 
    2072     * \param maxEventSize [in/out] the size of the bigger event for each connected server 
    2073     * \param [in] contextClient 
    2074     * \param [in] bufferForWriting True if buffers are used for sending data for writing 
    2075       This flag is only true for client and server-1 for communication with server-2 
    2076     */ 
    2077    std::map<int, StdSize> CContext::getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, 
    2078                                                            CContextClient* contextClient, bool bufferForWriting /*= "false"*/) 
    2079    TRY 
    2080    { 
    2081          // As calendar attributes are sent even if there are no active files or fields, maps are initialized according the size of calendar attributes 
    2082      std::map<int, StdSize> attributesSize = CCalendarWrapper::get(CCalendarWrapper::GetDefName())->getMinimumBufferSizeForAttributes(contextClient); 
    2083      maxEventSize = CCalendarWrapper::get(CCalendarWrapper::GetDefName())->getMinimumBufferSizeForAttributes(contextClient); 
    2084  
    2085      std::vector<CFile*>& fileList = this->enabledFiles; 
    2086      size_t numEnabledFiles = fileList.size(); 
    2087      for (size_t i = 0; i < numEnabledFiles; ++i) 
    2088      { 
    2089 //         CFile* file = this->enabledWriteModeFiles[i]; 
    2090         CFile* file = fileList[i]; 
    2091         std::vector<CField*> enabledFields = file->getEnabledFields(); 
    2092         size_t numEnabledFields = enabledFields.size(); 
    2093         for (size_t j = 0; j < numEnabledFields; ++j) 
    2094         { 
    2095           const std::map<int, StdSize> mapSize = enabledFields[j]->getGridAttributesBufferSize(contextClient, bufferForWriting); 
    2096           std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    2097           for (; it != itE; ++it) 
    2098           { 
    2099                      // If attributesSize[it->first] does not exist, it will be zero-initialized 
    2100                      // so we can use it safely without checking for its existence 
    2101              if (attributesSize[it->first] < it->second) 
    2102                            attributesSize[it->first] = it->second; 
    2103  
    2104                      if (maxEventSize[it->first] < it->second) 
    2105                            maxEventSize[it->first] = it->second; 
    2106           } 
    2107         } 
    2108      } 
    2109      return attributesSize; 
    2110    } 
    2111    CATCH_DUMP_ATTR 
    2112  
    2113    /*! 
    2114     * Compute the required buffer size to send the fields data. 
    2115     * \param maxEventSize [in/out] the size of the bigger event for each connected server 
    2116     * \param [in] contextClient 
    2117     * \param [in] bufferForWriting True if buffers are used for sending data for writing 
    2118       This flag is only true for client and server-1 for communication with server-2 
    2119     */ 
    2120    std::map<int, StdSize> CContext::getDataBufferSize(std::map<int, StdSize>& maxEventSize, 
    2121                                                       CContextClient* contextClient, bool bufferForWriting /*= "false"*/) 
    2122    TRY 
    2123    { 
    2124      std::map<int, StdSize> dataSize; 
    2125  
    2126      // Find all reference domain and axis of all active fields 
    2127      std::vector<CFile*>& fileList = bufferForWriting ? this->enabledWriteModeFiles : this->enabledReadModeFiles; 
    2128      size_t numEnabledFiles = fileList.size(); 
    2129      for (size_t i = 0; i < numEnabledFiles; ++i) 
    2130      { 
    2131        CFile* file = fileList[i]; 
    2132        if (file->getContextClient() == contextClient) 
    2133        { 
    2134          std::vector<CField*> enabledFields = file->getEnabledFields(); 
    2135          size_t numEnabledFields = enabledFields.size(); 
    2136          for (size_t j = 0; j < numEnabledFields; ++j) 
    2137          { 
    2138            // const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(contextClient); 
    2139            const std::map<int, StdSize> mapSize = enabledFields[j]->getGridDataBufferSize(contextClient,bufferForWriting); 
    2140            std::map<int, StdSize>::const_iterator it = mapSize.begin(), itE = mapSize.end(); 
    2141            for (; it != itE; ++it) 
    2142            { 
    2143              // If dataSize[it->first] does not exist, it will be zero-initialized 
    2144              // so we can use it safely without checking for its existance 
    2145                  if (CXios::isOptPerformance) 
    2146                dataSize[it->first] += it->second; 
    2147              else if (dataSize[it->first] < it->second) 
    2148                dataSize[it->first] = it->second; 
    2149  
    2150                  if (maxEventSize[it->first] < it->second) 
    2151                maxEventSize[it->first] = it->second; 
    2152            } 
    2153          } 
    2154        } 
    2155      } 
    2156      return dataSize; 
    2157    } 
    2158    CATCH_DUMP_ATTR 
    2159  
    2160    //! Client side: Send infomation of active files (files are enabled to write out) 
     2254   
     2255     //! Client side: Send infomation of active files (files are enabled to write out) 
    21612256   void CContext::sendEnabledFiles(const std::vector<CFile*>& activeFiles) 
    21622257   TRY 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp

    r1869 r1870  
    159159         std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 
    160160         std::map<int, StdSize> getDataBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 
    161          void setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting = false); 
     161         void setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting = false); // old interface to be removed 
     162         void setClientServerBuffer(vector<CField*>& fields, bool bufferForWriting) ;  
    162163 
    163164         // Distribute files (in write mode) among secondary-server pools according to the estimated data flux 
     
    181182         void sendRegistry(void) ; 
    182183         void sendFinalizeClient(CContextClient* contextClient, const string& contextClientId); 
    183  
     184          
     185         public: 
     186         void sendContextToFileServer(CContextClient* client) ; 
     187         private: 
     188         std::set<CContextClient*> sendToFileServer_done_ ; 
     189          
     190         public:  
    184191         std::string getContextId() {return contextId_;} 
    185192 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp

    r1869 r1870  
    20852085  CATCH_DUMP_ATTR 
    20862086 
     2087  void CDomain::sendDomainToFileServer(CContextClient* client) 
     2088  { 
     2089    if (sendDomainToFileServer_done_.count(client)!=0) return ; 
     2090    else sendDomainToFileServer_done_.insert(client) ; 
     2091 
     2092    StdString domDefRoot("domain_definition"); 
     2093    CDomainGroup* domPtr = CDomainGroup::get(domDefRoot); 
     2094    domPtr->sendCreateChild(this->getId(), client); 
     2095    this->sendAllAttributesToServer(client)  ; 
     2096    this->sendDistributionAttributes(client);    
     2097    this->sendIndex(client);        
     2098    this->sendLonLat(client); 
     2099    this->sendArea(client);     
     2100    this->sendDataIndex(client); 
     2101  } 
     2102 
    20872103  /*! 
    20882104    Send all attributes from client to connected clients 
    20892105    The attributes will be rebuilt on receiving side 
    20902106  */ 
     2107  // ym obsolete to be removed 
    20912108  void CDomain::sendAttributes() 
    20922109  TRY 
    20932110  { 
    2094     sendDistributionAttributes(); 
    2095     sendIndex();        
    2096     sendLonLat(); 
    2097     sendArea();     
    2098     sendDataIndex(); 
     2111    //sendDistributionAttributes(); 
     2112    //sendIndex();        
     2113    //sendLonLat(); 
     2114    //sendArea();     
     2115    //sendDataIndex(); 
    20992116  } 
    21002117  CATCH 
     
    21022119    Send global index from client to connected client(s) 
    21032120  */ 
    2104   void CDomain::sendIndex() 
     2121  void CDomain::sendIndex(CContextClient* client) 
    21052122  TRY 
    21062123  { 
    21072124    int ns, n, i, j, ind, nv, idx; 
    2108     std::list<CContextClient*>::iterator it; 
    2109     for (it=clients.begin(); it!=clients.end(); ++it) 
     2125    
     2126    int serverSize = client->serverSize; 
     2127    CEventClient eventIndex(getType(), EVENT_ID_INDEX); 
     2128 
     2129    list<CMessage> list_msgsIndex; 
     2130    list<CArray<int,1> > list_indGlob; 
     2131 
     2132    std::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; 
     2133    iteIndex = indSrv_[serverSize].end(); 
     2134    for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    21102135    { 
    2111       CContextClient* client = *it; 
    2112  
    2113       int serverSize = client->serverSize; 
    2114       CEventClient eventIndex(getType(), EVENT_ID_INDEX); 
    2115  
    2116       list<CMessage> list_msgsIndex; 
    2117       list<CArray<int,1> > list_indGlob; 
    2118  
    2119       std::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex; 
    2120       iteIndex = indSrv_[serverSize].end(); 
    2121       for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    2122       { 
    2123         int nbIndGlob = 0; 
    2124         int rank = connectedServerRank_[serverSize][k]; 
    2125         itIndex = indSrv_[serverSize].find(rank); 
    2126         if (iteIndex != itIndex) 
    2127           nbIndGlob = itIndex->second.size(); 
    2128  
    2129         list_indGlob.push_back(CArray<int,1>(nbIndGlob));         
    2130  
    2131         CArray<int,1>& indGlob = list_indGlob.back(); 
    2132         for (n = 0; n < nbIndGlob; ++n) 
    2133         { 
    2134           indGlob(n) = static_cast<int>(itIndex->second[n]); 
    2135         } 
    2136  
    2137         list_msgsIndex.push_back(CMessage()); 
    2138         list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
    2139         list_msgsIndex.back() << isCurvilinear; 
    2140         list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); 
     2136      int nbIndGlob = 0; 
     2137      int rank = connectedServerRank_[serverSize][k]; 
     2138      itIndex = indSrv_[serverSize].find(rank); 
     2139      if (iteIndex != itIndex) 
     2140        nbIndGlob = itIndex->second.size(); 
     2141 
     2142      list_indGlob.push_back(CArray<int,1>(nbIndGlob));         
     2143 
     2144      CArray<int,1>& indGlob = list_indGlob.back(); 
     2145      for (n = 0; n < nbIndGlob; ++n) indGlob(n) = static_cast<int>(itIndex->second[n]); 
     2146 
     2147      list_msgsIndex.push_back(CMessage()); 
     2148      list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 
     2149      list_msgsIndex.back() << isCurvilinear; 
     2150      list_msgsIndex.back() << list_indGlob.back(); //list_indi.back() << list_indj.back(); 
    21412151        
    2142         eventIndex.push(rank, nbSenders[serverSize][rank], list_msgsIndex.back()); 
    2143       } 
    2144  
    2145       client->sendEvent(eventIndex); 
    2146     } 
     2152      eventIndex.push(rank, nbSenders[serverSize][rank], list_msgsIndex.back()); 
     2153    } 
     2154    client->sendEvent(eventIndex); 
    21472155  } 
    21482156  CATCH_DUMP_ATTR 
     
    21532161    it calculates this distribution then sends it to the corresponding clients on the next level 
    21542162  */ 
    2155   void CDomain::sendDistributionAttributes(void) 
     2163  void CDomain::sendDistributionAttributes(CContextClient* client) 
    21562164  TRY 
    21572165  { 
    2158     std::list<CContextClient*>::iterator it; 
    2159     for (it=clients.begin(); it!=clients.end(); ++it) 
     2166    int nbServer = client->serverSize; 
     2167    std::vector<int> nGlobDomain(2); 
     2168    nGlobDomain[0] = this->ni_glo; 
     2169    nGlobDomain[1] = this->nj_glo; 
     2170 
     2171    CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
     2172    if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); 
     2173    else serverDescription.computeServerDistribution(false, 1); 
     2174 
     2175    std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
     2176    std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
     2177 
     2178    CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 
     2179    if (client->isServerLeader()) 
    21602180    { 
    2161       CContextClient* client = *it; 
    2162       int nbServer = client->serverSize; 
    2163       std::vector<int> nGlobDomain(2); 
    2164       nGlobDomain[0] = this->ni_glo; 
    2165       nGlobDomain[1] = this->nj_glo; 
    2166  
    2167       CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 
    2168       if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); 
    2169       else serverDescription.computeServerDistribution(false, 1); 
    2170  
    2171       std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
    2172       std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
    2173  
    2174       CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 
    2175       if (client->isServerLeader()) 
    2176       { 
    2177         std::list<CMessage> msgs; 
    2178  
    2179         const std::list<int>& ranks = client->getRanksServerLeader(); 
    2180         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    2181         { 
    2182           // Use const int to ensure CMessage holds a copy of the value instead of just a reference 
    2183           const int ibegin_srv = serverIndexBegin[*itRank][0]; 
    2184           const int jbegin_srv = serverIndexBegin[*itRank][1]; 
    2185           const int ni_srv = serverDimensionSizes[*itRank][0]; 
    2186           const int nj_srv = serverDimensionSizes[*itRank][1]; 
    2187  
    2188           msgs.push_back(CMessage()); 
    2189           CMessage& msg = msgs.back(); 
    2190           msg << this->getId() ; 
    2191           msg << isUnstructed_; 
    2192           msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; 
    2193           msg << ni_glo.getValue() << nj_glo.getValue(); 
    2194           msg << isCompressible_; 
    2195  
    2196           event.push(*itRank,1,msg); 
    2197         } 
    2198         client->sendEvent(event); 
    2199       } 
    2200       else client->sendEvent(event); 
    2201     } 
     2181      std::list<CMessage> msgs; 
     2182 
     2183      const std::list<int>& ranks = client->getRanksServerLeader(); 
     2184      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     2185      { 
     2186        // Use const int to ensure CMessage holds a copy of the value instead of just a reference 
     2187        const int ibegin_srv = serverIndexBegin[*itRank][0]; 
     2188        const int jbegin_srv = serverIndexBegin[*itRank][1]; 
     2189        const int ni_srv = serverDimensionSizes[*itRank][0]; 
     2190        const int nj_srv = serverDimensionSizes[*itRank][1]; 
     2191 
     2192        msgs.push_back(CMessage()); 
     2193        CMessage& msg = msgs.back(); 
     2194        msg << this->getId() ; 
     2195        msg << isUnstructed_; 
     2196        msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; 
     2197        msg << ni_glo.getValue() << nj_glo.getValue(); 
     2198        msg << isCompressible_; 
     2199 
     2200        event.push(*itRank,1,msg); 
     2201      } 
     2202      client->sendEvent(event); 
     2203    } 
     2204    else client->sendEvent(event); 
    22022205  } 
    22032206  CATCH_DUMP_ATTR 
     
    22062209    Send area from client to connected client(s) 
    22072210  */ 
    2208   void CDomain::sendArea() 
     2211  void CDomain::sendArea(CContextClient* client) 
    22092212  TRY 
    22102213  { 
     
    22122215 
    22132216    int ns, n, i, j, ind, nv, idx; 
    2214     std::list<CContextClient*>::iterator it; 
    2215  
    2216     for (it=clients.begin(); it!=clients.end(); ++it) 
     2217    int serverSize = client->serverSize; 
     2218 
     2219    // send area for each connected server 
     2220    CEventClient eventArea(getType(), EVENT_ID_AREA); 
     2221 
     2222    list<CMessage> list_msgsArea; 
     2223    list<CArray<double,1> > list_area; 
     2224 
     2225    std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
     2226    iteMap = indSrv_[serverSize].end(); 
     2227    for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    22172228    { 
    2218       CContextClient* client = *it; 
    2219       int serverSize = client->serverSize; 
    2220  
    2221       // send area for each connected server 
    2222       CEventClient eventArea(getType(), EVENT_ID_AREA); 
    2223  
    2224       list<CMessage> list_msgsArea; 
    2225       list<CArray<double,1> > list_area; 
    2226  
    2227       std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2228       iteMap = indSrv_[serverSize].end(); 
    2229       for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    2230       { 
    2231         int nbData = 0; 
    2232         int rank = connectedServerRank_[serverSize][k]; 
    2233         it = indSrv_[serverSize].find(rank); 
    2234         if (iteMap != it) 
    2235           nbData = it->second.size(); 
    2236         list_area.push_back(CArray<double,1>(nbData)); 
    2237  
    2238         const std::vector<size_t>& temp = it->second; 
    2239         for (n = 0; n < nbData; ++n) 
    2240         { 
    2241           idx = static_cast<int>(it->second[n]); 
    2242           list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]); 
    2243         } 
    2244  
    2245         list_msgsArea.push_back(CMessage()); 
    2246         list_msgsArea.back() << this->getId() << hasArea; 
    2247         list_msgsArea.back() << list_area.back(); 
    2248         eventArea.push(rank, nbSenders[serverSize][rank], list_msgsArea.back()); 
    2249       } 
    2250       client->sendEvent(eventArea); 
    2251     } 
     2229      int nbData = 0; 
     2230      int rank = connectedServerRank_[serverSize][k]; 
     2231      it = indSrv_[serverSize].find(rank); 
     2232      if (iteMap != it) 
     2233        nbData = it->second.size(); 
     2234      list_area.push_back(CArray<double,1>(nbData)); 
     2235 
     2236      const std::vector<size_t>& temp = it->second; 
     2237      for (n = 0; n < nbData; ++n) 
     2238      { 
     2239        idx = static_cast<int>(it->second[n]); 
     2240        list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]); 
     2241      } 
     2242 
     2243      list_msgsArea.push_back(CMessage()); 
     2244      list_msgsArea.back() << this->getId() << hasArea; 
     2245      list_msgsArea.back() << list_area.back(); 
     2246      eventArea.push(rank, nbSenders[serverSize][rank], list_msgsArea.back()); 
     2247    } 
     2248    client->sendEvent(eventArea); 
    22522249  } 
    22532250  CATCH_DUMP_ATTR 
     
    22582255    Because longitude and latitude are optional, this function only called if latitude and longitude exist 
    22592256  */ 
    2260   void CDomain::sendLonLat() 
     2257  void CDomain::sendLonLat(CContextClient* client) 
    22612258  TRY 
    22622259  { 
     
    22642261 
    22652262    int ns, n, i, j, ind, nv, idx; 
    2266     std::list<CContextClient*>::iterator it; 
    2267     for (it=clients.begin(); it!=clients.end(); ++it) 
     2263    int serverSize = client->serverSize; 
     2264 
     2265    // send lon lat for each connected server 
     2266    CEventClient eventLon(getType(), EVENT_ID_LON); 
     2267    CEventClient eventLat(getType(), EVENT_ID_LAT); 
     2268 
     2269    list<CMessage> list_msgsLon, list_msgsLat; 
     2270    list<CArray<double,1> > list_lon, list_lat; 
     2271    list<CArray<double,2> > list_boundslon, list_boundslat; 
     2272 
     2273    std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
     2274    iteMap = indSrv_[serverSize].end(); 
     2275    for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    22682276    { 
    2269       CContextClient* client = *it; 
    2270       int serverSize = client->serverSize; 
    2271  
    2272       // send lon lat for each connected server 
    2273       CEventClient eventLon(getType(), EVENT_ID_LON); 
    2274       CEventClient eventLat(getType(), EVENT_ID_LAT); 
    2275  
    2276       list<CMessage> list_msgsLon, list_msgsLat; 
    2277       list<CArray<double,1> > list_lon, list_lat; 
    2278       list<CArray<double,2> > list_boundslon, list_boundslat; 
    2279  
    2280       std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2281       iteMap = indSrv_[serverSize].end(); 
    2282       for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    2283       { 
    2284         int nbData = 0; 
    2285         int rank = connectedServerRank_[serverSize][k]; 
    2286         it = indSrv_[serverSize].find(rank); 
    2287         if (iteMap != it) 
    2288           nbData = it->second.size(); 
    2289  
    2290         list_lon.push_back(CArray<double,1>(nbData)); 
    2291         list_lat.push_back(CArray<double,1>(nbData)); 
     2277      int nbData = 0; 
     2278      int rank = connectedServerRank_[serverSize][k]; 
     2279      it = indSrv_[serverSize].find(rank); 
     2280      if (iteMap != it) 
     2281        nbData = it->second.size(); 
     2282 
     2283      list_lon.push_back(CArray<double,1>(nbData)); 
     2284      list_lat.push_back(CArray<double,1>(nbData)); 
     2285 
     2286      if (hasBounds) 
     2287      { 
     2288        list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 
     2289        list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
     2290      } 
     2291 
     2292      CArray<double,1>& lon = list_lon.back(); 
     2293      CArray<double,1>& lat = list_lat.back(); 
     2294      const std::vector<size_t>& temp = it->second; 
     2295      for (n = 0; n < nbData; ++n) 
     2296      { 
     2297        idx = static_cast<int>(it->second[n]); 
     2298        int localInd = globalLocalIndexMap_[idx]; 
     2299        lon(n) = lonvalue(localInd); 
     2300        lat(n) = latvalue(localInd); 
    22922301 
    22932302        if (hasBounds) 
    22942303        { 
    2295           list_boundslon.push_back(CArray<double,2>(nvertex, nbData)); 
    2296           list_boundslat.push_back(CArray<double,2>(nvertex, nbData)); 
    2297         } 
    2298  
    2299         CArray<double,1>& lon = list_lon.back(); 
    2300         CArray<double,1>& lat = list_lat.back(); 
    2301         const std::vector<size_t>& temp = it->second; 
    2302         for (n = 0; n < nbData; ++n) 
    2303         { 
    2304           idx = static_cast<int>(it->second[n]); 
    2305           int localInd = globalLocalIndexMap_[idx]; 
    2306           lon(n) = lonvalue(localInd); 
    2307           lat(n) = latvalue(localInd); 
    2308  
    2309           if (hasBounds) 
     2304          CArray<double,2>& boundslon = list_boundslon.back(); 
     2305          CArray<double,2>& boundslat = list_boundslat.back(); 
     2306 
     2307          for (nv = 0; nv < nvertex; ++nv) 
    23102308          { 
    2311             CArray<double,2>& boundslon = list_boundslon.back(); 
    2312             CArray<double,2>& boundslat = list_boundslat.back(); 
    2313  
    2314             for (nv = 0; nv < nvertex; ++nv) 
    2315             { 
    2316               boundslon(nv, n) = bounds_lonvalue(nv, localInd); 
    2317               boundslat(nv, n) = bounds_latvalue(nv, localInd); 
    2318             } 
     2309            boundslon(nv, n) = bounds_lonvalue(nv, localInd); 
     2310            boundslat(nv, n) = bounds_latvalue(nv, localInd); 
    23192311          } 
    23202312        } 
    2321  
    2322         list_msgsLon.push_back(CMessage()); 
    2323         list_msgsLat.push_back(CMessage()); 
    2324  
    2325         list_msgsLon.back() << this->getId() << hasLonLat; 
    2326         if (hasLonLat)  
    2327           list_msgsLon.back() << list_lon.back(); 
    2328         list_msgsLon.back()  << hasBounds; 
    2329         if (hasBounds) 
    2330         { 
    2331           list_msgsLon.back() << list_boundslon.back(); 
    2332         } 
    2333  
    2334         list_msgsLat.back() << this->getId() << hasLonLat; 
    2335         if (hasLonLat) 
    2336           list_msgsLat.back() << list_lat.back(); 
    2337         list_msgsLat.back() << hasBounds; 
    2338         if (hasBounds) 
    2339         {           
    2340           list_msgsLat.back() << list_boundslat.back(); 
    2341         } 
    2342  
    2343         eventLon.push(rank, nbSenders[serverSize][rank], list_msgsLon.back()); 
    2344         eventLat.push(rank, nbSenders[serverSize][rank], list_msgsLat.back()); 
    2345       } 
    2346       client->sendEvent(eventLon); 
    2347       client->sendEvent(eventLat); 
    2348     } 
     2313      } 
     2314 
     2315      list_msgsLon.push_back(CMessage()); 
     2316      list_msgsLat.push_back(CMessage()); 
     2317 
     2318      list_msgsLon.back() << this->getId() << hasLonLat; 
     2319      if (hasLonLat)  
     2320        list_msgsLon.back() << list_lon.back(); 
     2321      list_msgsLon.back()  << hasBounds; 
     2322      if (hasBounds) 
     2323      { 
     2324        list_msgsLon.back() << list_boundslon.back(); 
     2325      } 
     2326 
     2327      list_msgsLat.back() << this->getId() << hasLonLat; 
     2328      if (hasLonLat) 
     2329        list_msgsLat.back() << list_lat.back(); 
     2330      list_msgsLat.back() << hasBounds; 
     2331      if (hasBounds) 
     2332      {           
     2333        list_msgsLat.back() << list_boundslat.back(); 
     2334      } 
     2335 
     2336      eventLon.push(rank, nbSenders[serverSize][rank], list_msgsLon.back()); 
     2337      eventLat.push(rank, nbSenders[serverSize][rank], list_msgsLat.back()); 
     2338    } 
     2339    client->sendEvent(eventLon); 
     2340    client->sendEvent(eventLat); 
    23492341  } 
    23502342  CATCH_DUMP_ATTR 
     
    23562348    The compressed index are represented with 1 and others are represented with -1 
    23572349  */ 
    2358   void CDomain::sendDataIndex() 
     2350  void CDomain::sendDataIndex(CContextClient* client) 
    23592351  TRY 
    23602352  { 
    23612353    int ns, n, i, j, ind, nv, idx; 
    2362     std::list<CContextClient*>::iterator it; 
    2363     for (it=clients.begin(); it!=clients.end(); ++it) 
     2354    int serverSize = client->serverSize; 
     2355 
     2356    // send area for each connected server 
     2357    CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); 
     2358 
     2359    list<CMessage> list_msgsDataIndex; 
     2360    list<CArray<int,1> > list_data_i_index, list_data_j_index; 
     2361 
     2362    int nbIndex = i_index.numElements(); 
     2363    int niByIndex = max(i_index) - min(i_index) + 1; 
     2364    int njByIndex = max(j_index) - min(j_index) + 1;  
     2365    int dataIindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : niByIndex; 
     2366    int dataJindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : njByIndex; 
     2367 
     2368     
     2369    CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 
     2370    dataIIndex = -1;  
     2371    dataJIndex = -1; 
     2372    ind = 0; 
     2373 
     2374    for (idx = 0; idx < data_i_index.numElements(); ++idx) 
    23642375    { 
    2365       CContextClient* client = *it; 
    2366  
    2367       int serverSize = client->serverSize; 
    2368  
    2369       // send area for each connected server 
    2370       CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); 
    2371  
    2372       list<CMessage> list_msgsDataIndex; 
    2373       list<CArray<int,1> > list_data_i_index, list_data_j_index; 
    2374  
    2375       int nbIndex = i_index.numElements(); 
    2376       int niByIndex = max(i_index) - min(i_index) + 1; 
    2377       int njByIndex = max(j_index) - min(j_index) + 1;  
    2378       int dataIindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : niByIndex; 
    2379       int dataJindexBound = (1 == data_dim) ? (niByIndex * njByIndex) : njByIndex; 
    2380  
    2381        
    2382       CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 
    2383       dataIIndex = -1;  
    2384       dataJIndex = -1; 
    2385       ind = 0; 
    2386  
    2387       for (idx = 0; idx < data_i_index.numElements(); ++idx) 
    2388       { 
    2389         int dataIidx = data_i_index(idx) + data_ibegin; 
    2390         int dataJidx = data_j_index(idx) + data_jbegin; 
    2391         if ((0 <= dataIidx) && (dataIidx < dataIindexBound) && 
    2392             (0 <= dataJidx) && (dataJidx < dataJindexBound)) 
    2393         { 
    2394           dataIIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //i_index(dataIidx);//dataIidx; 
    2395           dataJIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //j_index(dataJidx);//           
    2396         } 
    2397       } 
    2398  
    2399       std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
    2400       iteMap = indSrv_[serverSize].end(); 
    2401       for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
    2402       { 
    2403         int nbData = 0; 
    2404         int rank = connectedServerRank_[serverSize][k]; 
    2405         it = indSrv_[serverSize].find(rank); 
    2406         if (iteMap != it) 
    2407           nbData = it->second.size(); 
    2408         list_data_i_index.push_back(CArray<int,1>(nbData)); 
    2409         list_data_j_index.push_back(CArray<int,1>(nbData)); 
    2410  
    2411         const std::vector<size_t>& temp = it->second; 
    2412         for (n = 0; n < nbData; ++n) 
    2413         { 
    2414           idx = static_cast<int>(it->second[n]); 
    2415           i = globalLocalIndexMap_[idx]; 
    2416           list_data_i_index.back()(n) = dataIIndex(i); 
    2417           list_data_j_index.back()(n) = dataJIndex(i); 
    2418         } 
    2419  
    2420         list_msgsDataIndex.push_back(CMessage()); 
    2421         list_msgsDataIndex.back() << this->getId(); 
    2422         list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 
    2423         eventDataIndex.push(rank, nbSenders[serverSize][rank], list_msgsDataIndex.back()); 
    2424       } 
    2425       client->sendEvent(eventDataIndex); 
    2426     } 
     2376      int dataIidx = data_i_index(idx) + data_ibegin; 
     2377      int dataJidx = data_j_index(idx) + data_jbegin; 
     2378      if ((0 <= dataIidx) && (dataIidx < dataIindexBound) && 
     2379          (0 <= dataJidx) && (dataJidx < dataJindexBound)) 
     2380      { 
     2381        dataIIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //i_index(dataIidx);//dataIidx; 
     2382        dataJIndex((1 == data_dim) ? dataIidx : dataJidx * ni + dataIidx) = 1; //j_index(dataJidx);//           
     2383      } 
     2384    } 
     2385 
     2386    std::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 
     2387    iteMap = indSrv_[serverSize].end(); 
     2388    for (int k = 0; k < connectedServerRank_[serverSize].size(); ++k) 
     2389    { 
     2390      int nbData = 0; 
     2391      int rank = connectedServerRank_[serverSize][k]; 
     2392      it = indSrv_[serverSize].find(rank); 
     2393      if (iteMap != it) 
     2394        nbData = it->second.size(); 
     2395      list_data_i_index.push_back(CArray<int,1>(nbData)); 
     2396      list_data_j_index.push_back(CArray<int,1>(nbData)); 
     2397 
     2398      const std::vector<size_t>& temp = it->second; 
     2399      for (n = 0; n < nbData; ++n) 
     2400      { 
     2401        idx = static_cast<int>(it->second[n]); 
     2402        i = globalLocalIndexMap_[idx]; 
     2403        list_data_i_index.back()(n) = dataIIndex(i); 
     2404        list_data_j_index.back()(n) = dataJIndex(i); 
     2405      } 
     2406 
     2407      list_msgsDataIndex.push_back(CMessage()); 
     2408      list_msgsDataIndex.back() << this->getId(); 
     2409      list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 
     2410      eventDataIndex.push(rank, nbSenders[serverSize][rank], list_msgsDataIndex.back()); 
     2411    } 
     2412    client->sendEvent(eventDataIndex); 
    24272413  } 
    24282414  CATCH 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp

    r1869 r1870  
    184184         void setTransformations(const TransMapTypes&);          
    185185         void computeNGlobDomain(); 
    186          void sendAttributes(); 
    187          void sendIndex(); 
    188          void sendDistributionAttributes(); 
    189          void sendArea(); 
    190          void sendLonLat();          
    191          void sendDataIndex(); 
     186          
     187       public: 
     188         void sendDomainToFileServer(CContextClient* client) ; 
     189       private: 
     190         std::set<CContextClient*> sendDomainToFileServer_done_ ; 
     191       private: 
     192          
     193         void sendAttributes(); // ym obsolete -> to be removed 
     194         void sendIndex(CContextClient* client); 
     195         void sendDistributionAttributes(CContextClient* client); 
     196         void sendArea(CContextClient* client); 
     197         void sendLonLat(CContextClient* client);          
     198         void sendDataIndex(CContextClient* client); 
    192199         void convertLonLatValue(); 
    193200         void fillInRectilinearLonLat(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r1869 r1870  
    246246    if (opeDate <= currDate) 
    247247    { 
    248       for (map<int, CArray<size_t, 1> >::iterator it = grid_->outLocalIndexStoreOnClient_.begin(); it != grid_->outLocalIndexStoreOnClient_.end(); ++it) 
     248      auto& outLocalIndexStoreOnClient = grid_-> getOutLocalIndexStoreOnClient() ; 
     249      for (auto it = outLocalIndexStoreOnClient.begin(); it != outLocalIndexStoreOnClient.end(); ++it) 
    249250      { 
    250251        CArray<double,1> tmp; 
    251252        CArray<size_t,1>& indexTmp = it->second; 
    252253        *(rankBuffers[it->first]) >> tmp; 
    253         for (int idx = 0; idx < indexTmp.numElements(); ++idx) 
    254         { 
    255           recv_data_tmp(indexTmp(idx)) = tmp(idx); 
    256         }       
     254        for (int idx = 0; idx < indexTmp.numElements(); ++idx) recv_data_tmp(indexTmp(idx)) = tmp(idx); 
    257255      } 
    258256    } 
     
    436434    else 
    437435    { 
    438       for (map<int, CArray<size_t, 1> >::iterator it = grid_->outLocalIndexStoreOnClient_.begin();  
    439                                                   it != grid_->outLocalIndexStoreOnClient_.end(); ++it) 
     436      auto& outLocalIndexStoreOnClient = grid_-> getOutLocalIndexStoreOnClient() ; 
     437      for (auto it = outLocalIndexStoreOnClient.begin(); it != outLocalIndexStoreOnClient.end(); ++it) 
    440438      { 
    441439        CArray<size_t,1>& indexTmp = it->second; 
     
    10251023  CATCH_DUMP_ATTR 
    10261024 
     1025  /*! 
     1026   * Compute the required buffer size to send the fields data. 
     1027   * \param [in/out] bufferSize Modifying the bufferSize for the client context 
     1028   * \param [in/out] maxEventSize Modifying the maximum event size for the client context  
     1029   * \param [in] bufferForWriting True if buffers are used for sending data for writing 
     1030   */   
     1031  void CField::setContextClientDataBufferSize(map<CContextClient*,map<int,size_t>>& bufferSize,  
     1032                                              map<CContextClient*,map<int,size_t>>& maxEventSize,  
     1033                                              bool bufferForWriting) 
     1034  { 
     1035    auto& contextBufferSize = bufferSize[client] ; 
     1036    auto& contextMaxEventSize = maxEventSize[client] ; 
     1037    const std::map<int, size_t> mapSize = grid_->getDataBufferSize(client, getId(), bufferForWriting); 
     1038    for(auto& it : mapSize ) 
     1039    { 
     1040      // If contextBufferSize[it.first] does not exist, it will be zero-initialized 
     1041      // so we can use it safely without checking for its existance 
     1042      if (CXios::isOptPerformance) contextBufferSize[it.first] += it.second; 
     1043      else if (contextBufferSize[it.first] < it.second) contextBufferSize[it.first] = it.second; 
     1044 
     1045      if (contextMaxEventSize[it.first] < it.second) contextMaxEventSize[it.first] = it.second; 
     1046    } 
     1047 
     1048  } 
     1049 
     1050  void CField::setContextClientAttributesBufferSize(map<CContextClient*,map<int,size_t>>& bufferSize,  
     1051                                                   map<CContextClient*,map<int,size_t>>& maxEventSize,  
     1052                                                   bool bufferForWriting) 
     1053  { 
     1054    auto& contextBufferSize = bufferSize[client] ; 
     1055    auto& contextMaxEventSize = maxEventSize[client] ; 
     1056    const std::map<int, size_t> mapSize = grid_->getAttributesBufferSize(client, bufferForWriting); 
     1057    for(auto& it : mapSize ) 
     1058    { 
     1059      // If contextBufferSize[it.first] does not exist, it will be zero-initialized 
     1060      // so we can use it safely without checking for its existance 
     1061      if (contextBufferSize[it.first] < it.second) contextBufferSize[it.first] = it.second; 
     1062      if (contextMaxEventSize[it.first] < it.second) contextMaxEventSize[it.first] = it.second; 
     1063    } 
     1064 
     1065  } 
     1066 
     1067 
     1068// ym obsolete to be removed  
    10271069  std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 
    10281070  TRY 
     
    10321074  CATCH_DUMP_ATTR 
    10331075 
     1076// ym obsolete to be removed  
    10341077  std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 
    10351078  TRY 
     
    10381081  } 
    10391082  CATCH_DUMP_ATTR 
     1083 
     1084 
    10401085 
    10411086  size_t CField::getGlobalWrittenSize() 
     
    11721217  } 
    11731218    
    1174    
     1219  /*! 
     1220   * Connect field to filter to send data to server. A temporal filter is inserted before accordingly to the  
     1221   * output frequency of the file 
     1222   * \param gc the garbage collector to use when building the filter graph 
     1223   */ 
    11751224  void CField::connectToFileServer(CGarbageCollector& gc) 
    11761225  { 
     
    11811230  }  
    11821231 
     1232  /*! 
     1233   * Compute grid index needed to send grid and data to server 
     1234   */ 
    11831235  void CField::computeGridIndexToFileServer(void) 
    11841236  { 
     
    11861238  } 
    11871239 
    1188    /*! 
     1240  /*! 
     1241   * Connect field to a source filter to receive data from model. 
     1242   */ 
     1243  void CField::connectToModelInput(CGarbageCollector& gc) 
     1244  { 
     1245    const bool detectMissingValues = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true); 
     1246    const double defaultValue  = detectMissingValues ? default_value : (!default_value.isEmpty() ? default_value : 0.0); 
     1247 
     1248    if (check_if_active.isEmpty()) check_if_active = false;  
     1249    clientSourceFilter = std::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid_, false, true, NoneDu, false, detectMissingValues, defaultValue)); 
     1250    clientSourceFilter -> connectOutput(inputFilter,0) ; 
     1251  }  
     1252  
     1253  /*! 
    11891254   * Transform the grid_path attribut into vector of grid. 
    11901255   * \return the vector CGrid* containing the list of grid path for tranformation 
     
    12311296   *                     read by the client or/and written to a file 
    12321297   */ 
    1233  
     1298   // ym obselete : to be removed later.... 
    12341299  void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput) 
    12351300  TRY 
     
    18881953  CATCH 
    18891954 
     1955   
     1956  void CField::sendFieldToFileServer(void) 
     1957  { 
     1958    CContext::getCurrent()->sendContextToFileServer(client); 
     1959    fileOut_->sendFileToFileServer(client); 
     1960    grid_->sendGridToFileServer(client); 
     1961    this->sendAllAttributesToServer(client); 
     1962    this->sendAddAllVariables(client); 
     1963  } 
     1964 
    18901965  void CField::sendAddAllVariables(CContextClient* client) 
    18911966  TRY 
     
    19161991      grid_ref=grid_->getId() ; 
    19171992      SuperClass::sendAllAttributesToServer(client) ; 
     1993      domain_ref.reset() ; 
     1994      axis_ref.reset() ; 
     1995      scalar_ref.reset() ; 
    19181996      grid_ref.reset(); 
    19191997    } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp

    r1869 r1870  
    142142         void sendGridOfEnabledFields(); 
    143143         void sendGridComponentOfEnabledFields(); 
     144 
     145         void sendFieldToFileServer(void) ; 
    144146 
    145147         /// Vérifications /// 
     
    224226 
    225227        void connectToFileServer(CGarbageCollector& gc) ; 
     228        void connectToModelInput(CGarbageCollector& gc) ; 
    226229        void computeGridIndexToFileServer(void) ; 
     230 
     231        void setContextClientDataBufferSize(map<CContextClient*,map<int,size_t>>& bufferSize,  
     232                                        map<CContextClient*,map<int,size_t>>& maxEventSize,  
     233                                        bool bufferForWriting) ; 
     234        void setContextClientAttributesBufferSize(map<CContextClient*,map<int,size_t>>& bufferSize,  
     235                                                 map<CContextClient*,map<int,size_t>>& maxEventSize,  
     236                                                 bool bufferForWriting) ; 
    227237      private: 
    228238        std::vector<CGrid*> getGridPath(void) ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/file.cpp

    r1869 r1870  
    13451345   CATCH_DUMP_ATTR 
    13461346 
     1347 
     1348   
     1349   /*! 
     1350    * Send file attribute, related variable and chield field tree to a given file server. 
     1351    * \param[in] client : the context client where to send file 
     1352    */ 
     1353   void CFile::sendFileToFileServer(CContextClient* client) 
     1354   TRY 
     1355   { 
     1356     if (sendFileToFileServer_done_.count(client)!=0) return ; 
     1357     else sendFileToFileServer_done_.insert(client) ; 
     1358      
     1359     StdString fileDefRoot("file_definition"); 
     1360     CFileGroup* cfgrpPtr = CFileGroup::get(fileDefRoot); 
     1361     cfgrpPtr->sendCreateChild(this->getId(), client); 
     1362     this->sendAllAttributesToServer(client); 
     1363     this->sendAddAllVariables(client); 
     1364     for(auto field : enabledFields) this->sendAddField(field->getId(), client); 
     1365   } 
     1366   CATCH_DUMP_ATTR 
    13471367   /*! 
    13481368   \brief Dispatch event received from client 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/file.hpp

    r1784 r1870  
    142142         void sendAddVariableGroup(const string& id, CContextClient* client); 
    143143         void sendAddAllVariables(CContextClient* client); 
    144           
     144      public: 
     145         void sendFileToFileServer(CContextClient* client) ; 
     146      private: 
     147         std::set<CContextClient*> sendFileToFileServer_done_ ; 
     148 
     149      public: 
    145150         // Receive info from client 
    146151         static void recvAddField(CEventServer& event); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp

    r1869 r1870  
    3333      , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    3434      , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 
    35           , isDataDistributed_(true), isCompressible_(false) 
     35            , isCompressible_(false) 
    3636      , transformations_(0), isTransformed_(false) 
    3737      , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) 
     
    5454      , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 
    5555      , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 
    56           , isDataDistributed_(true), isCompressible_(false) 
     56            , isCompressible_(false) 
    5757      , transformations_(0), isTransformed_(false) 
    5858      , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) 
     
    9696     if (!isScalarGrid()) 
    9797     { 
    98        std::vector<int> dataNindex = getDistributionClient()->getDataNIndex(); 
     98       std::vector<int> dataNindex = getClientDistribution()->getDataNIndex(); 
    9999       for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i];        
    100100     } 
     
    128128     for (size_t i = 0; i < axisList.size(); ++i) 
    129129     { 
    130        std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize(client, getGlobalDimension(),axisPositionInGrid_[i]); 
     130       std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize(client, getGlobalDimension(),getAxisPositionInGrid()[i]); 
    131131       for (it = axisAttBuffSize.begin(), itE = axisAttBuffSize.end(); it != itE; ++it) 
    132132       { 
     
    202202   CATCH_DUMP_ATTR 
    203203    
     204 
     205   void CGrid::computeAxisPositionInGrid(void) 
     206   { 
     207     axisPositionInGrid_.resize(0); 
     208     int idx = 0; 
     209     for (int i = 0; i < axis_domain_order.numElements(); ++i) 
     210     { 
     211       int elementDimension = axis_domain_order(i); 
     212       if (1 == elementDimension) 
     213       { 
     214         axisPositionInGrid_.push_back(idx); 
     215         ++idx; 
     216       } 
     217       else if (2 == elementDimension) idx += 2; 
     218     } 
     219   } 
     220 
    204221   void CGrid::checkAttributesAfterTransformation() 
    205222   TRY 
     
    207224      setAxisList(); 
    208225      std::vector<CAxis*> axisListP = this->getAxis(); 
    209       if (!axisListP.empty()) 
    210       { 
    211         int idx = 0; 
    212         axisPositionInGrid_.resize(0); 
    213         for (int i = 0; i < axis_domain_order.numElements(); ++i) 
    214         { 
    215           int elementDimension = axis_domain_order(i); 
    216           if (1 == elementDimension) 
    217           { 
    218             axisPositionInGrid_.push_back(idx); 
    219             ++idx; 
    220           } 
    221           else if (2 == elementDimension) idx += 2; 
    222         } 
    223  
    224         for (int i = 0; i < axisListP.size(); ++i) 
    225         { 
    226           axisListP[i]->checkAttributesOnClientAfterTransformation(getGlobalDimension(),axisPositionInGrid_[i]); 
    227         } 
    228       } 
    229  
     226      for (int i = 0; i < axisListP.size(); ++i) 
     227        axisListP[i]->checkAttributesOnClientAfterTransformation(getGlobalDimension(), getAxisPositionInGrid()[i]); 
     228    
    230229      setDomainList(); 
    231230      std::vector<CDomain*> domListP = this->getDomains(); 
     
    568567      if (!axisListP.empty()) 
    569568      { 
    570         int idx = 0; 
    571         axisPositionInGrid_.resize(0); 
    572         for (int i = 0; i < axis_domain_order.numElements(); ++i) 
    573         { 
    574           int elementDimension = axis_domain_order(i); 
    575           if (1 == elementDimension) 
    576           { 
    577             axisPositionInGrid_.push_back(idx); 
    578             ++idx; 
    579           } 
    580           else if (2 == elementDimension) idx += 2; 
    581         } 
    582  
    583569        for (int i = 0; i < axisListP.size(); ++i) 
    584570        { 
    585571          if (sendAtt) 
    586             axisListP[i]->sendCheckedAttributes(getGlobalDimension(),axisPositionInGrid_[i]); 
     572            axisListP[i]->sendCheckedAttributes(getGlobalDimension(),getAxisPositionInGrid()[i]); 
    587573          else 
    588574            axisListP[i]->checkAttributesOnClient(); 
     
    634620 
    635621      size_t nbWritten = 0, indGlo; 
    636       CDistributionClient::GlobalLocalDataMap& globalDataIndex = getDistributionClient()->getGlobalDataIndexOnClient(); 
     622      CDistributionClient::GlobalLocalDataMap& globalDataIndex = getClientDistribution()->getGlobalDataIndexOnClient(); 
    637623      CDistributionClient::GlobalLocalDataMap::const_iterator itb = globalDataIndex.begin(), 
    638624                                                              ite = globalDataIndex.end(), it;     
     
    651637      { 
    652638        numberWrittenIndexes_ = nbWritten; 
    653         if (isDataDistributed_) 
     639        if (isDataDistributed()) 
    654640        { 
    655641          CContext* context = CContext::getCurrent();       
     
    688674   void CGrid::computeGridIndexToFileServer(CContextClient* client) 
    689675   { 
    690      if (isScalarGrid()) 
    691      { 
    692        computeClientIndexScalarGrid(); 
    693        computeConnectedClientsScalarGrid(client); 
    694      } 
    695      else 
    696      { 
    697        computeClientIndex(); 
    698        computeConnectedClients(client); 
    699      } 
    700  
     676     if (isScalarGrid()) computeConnectedClientsScalarGrid(client); 
     677     else computeConnectedClients(client); 
     678     
    701679     // compute indices for client/server transfer for domain 
    702680     for (const auto& domainId : domList_) CDomain::get(domainId)->computeConnectedClients(client); 
     
    705683     // compute indices for client/server transfer for axis 
    706684     std::vector<CAxis*> axisList = this->getAxis(); 
    707      std::vector<int> axisPosInGrid ; 
    708      // compute axis position in grid      
    709      int idx=0 ; 
    710      for (int i = 0 ; i < axis_domain_order.numElements(); ++i) 
    711      { 
    712        if (axis_domain_order(i) == 0)  idx += 0 ; 
    713        else if (axis_domain_order(i) == 1) { axisPosInGrid.push_back(idx) ; ++idx; } 
    714        else if (axis_domain_order(i) == 2) idx += 2; 
    715      } 
    716      for(int i=0 ; i<axisList.size(); i++) axisList[i] -> computeConnectedClients(client, getGlobalDimension(),axisPositionInGrid_[i]) ; 
     685     for(int i=0 ; i<axisList.size(); i++) axisList[i] -> computeConnectedClients(client, getGlobalDimension(),getAxisPositionInGrid()[i]) ; 
    717686   } 
    718687   //--------------------------------------------------------------- 
     
    740709     else 
    741710     { 
    742        CDistributionClient* clientDistribution = getDistributionClient() ; 
     711       CDistributionClient* clientDistribution = getClientDistribution() ; 
    743712       const std::vector<int>& localDataIndex = clientDistribution->getLocalDataIndexOnClient() ; 
    744713       int nbStoreIndex = localDataIndex.size() ; 
     
    759728     else 
    760729     { 
    761        CDistributionClient* clientDistribution = getDistributionClient() ; 
     730       CDistributionClient* clientDistribution = getClientDistribution() ; 
    762731       const std::vector<bool>& localMaskIndex = clientDistribution->getLocalMaskIndexOnClient() ; 
    763732       int nbMaskIndex = localMaskIndex.size() ; 
     
    767736   } 
    768737 
    769    /* 
    770      Compute the global index and its local index taking account mask and data index. 
    771      These global indexes will be used to compute the connection of this client (sender) to its servers (receivers) 
    772      (via function computeConnectedClient) 
    773      These global indexes also correspond to data sent to servers (if any) 
    774    */ 
    775    void CGrid::computeClientIndex() 
    776    TRY 
    777    { 
    778      if (computeClientIndex_done_) return ; 
    779  
    780      CContext* context = CContext::getCurrent(); 
    781      int rank = context-> getIntraCommRank(); 
    782  
    783      auto clientDistribution = getDistributionClient(); 
    784      // Get local data index on client 
    785      int nbStoreIndex = clientDistribution->getLocalDataIndexOnClient().size(); 
    786      int nbStoreGridMask = clientDistribution->getLocalMaskIndexOnClient().size(); 
    787      // nbStoreGridMask = nbStoreIndex if grid mask is defined, and 0 otherwise 
    788      storeIndex_client_.resize(nbStoreIndex); 
    789      storeMask_client_.resize(nbStoreGridMask); 
    790      for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client_(idx) = (clientDistribution->getLocalDataIndexOnClient())[idx]; 
    791      for (int idx = 0; idx < nbStoreGridMask; ++idx) storeMask_client_(idx) = (clientDistribution->getLocalMaskIndexOnClient())[idx]; 
    792  
    793      if (0 == serverDistribution_) isDataDistributed_= clientDistribution->isDataDistributed(); 
    794      else 
    795      { 
    796         // Mapping global index received from clients to the storeIndex_client_ 
    797         CDistributionClient::GlobalLocalDataMap& globalDataIndex = clientDistribution->getGlobalDataIndexOnClient(); 
    798         CDistributionClient::GlobalLocalDataMap::const_iterator itGloe = globalDataIndex.end(); 
    799         map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient_.begin(), 
    800                                                ite = outGlobalIndexFromClient_.end(), it; 
    801  
    802         for (it = itb; it != ite; ++it) 
     738 
     739  void CGrid::computeOutLocalIndexStoreOnClient(void) 
     740  { 
     741    if (computeOutLocalIndexStoreOnClient_done_) return ; 
     742    else computeOutLocalIndexStoreOnClient_done_=true ; 
     743 
     744    if (isScalarGrid()) 
     745    { 
     746        auto& outGlobalIndexFromClient  = getOutGlobalIndexFromClient(); 
     747        auto itb = outGlobalIndexFromClient.begin(), ite = outGlobalIndexFromClient.end() ; 
     748        for (auto it = itb; it != ite; ++it) 
    803749        { 
    804750          int rank = it->first; 
    805           CArray<size_t,1>& globalIndex = outGlobalIndexFromClient_[rank]; 
     751          CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank]; 
    806752          outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 
    807753          CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient_[rank]; 
    808           size_t nbIndex = 0; 
    809  
    810           // Keep this code for this moment but it should be removed (or moved to DEBUG) to improve performance 
    811           for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
    812           { 
    813             if (itGloe != globalDataIndex.find(globalIndex(idx))) 
    814             { 
    815               ++nbIndex; 
    816             } 
    817           } 
    818  
    819           if (nbIndex != localIndex.numElements()) 
    820                ERROR("void CGrid::computeClientIndex()", 
    821                   << "Number of local index on client is different from number of received global index" 
    822                   << "Rank of sent client " << rank <<"." 
    823                   << "Number of local index " << nbIndex << ". " 
    824                   << "Number of received global index " << localIndex.numElements() << "."); 
    825  
    826           nbIndex = 0; 
    827           for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
    828           { 
    829             if (itGloe != globalDataIndex.find(globalIndex(idx))) 
    830             { 
    831               localIndex(idx) = globalDataIndex[globalIndex(idx)]; 
    832             } 
    833           } 
     754          if (1 != globalIndex.numElements()) 
     755            ERROR("void CGrid::computeClientIndexScalarGrid()", 
     756              << "Something wrong happened. " 
     757              << "Number of received global index on scalar grid should equal to 1"  
     758              << "Number of received global index " << globalIndex.numElements() << "."); 
     759 
     760          localIndex(0) = globalIndex(0); 
    834761        } 
    835       } 
    836       computeClientIndex_done_ = true ; 
    837    } 
    838    CATCH_DUMP_ATTR 
     762    } 
     763    else 
     764    { 
     765      CDistributionClient::GlobalLocalDataMap& globalDataIndex = getClientDistribution()->getGlobalDataIndexOnClient(); 
     766      CDistributionClient::GlobalLocalDataMap::const_iterator itGloe = globalDataIndex.end(); 
     767      auto& outGlobalIndexFromClient  = getOutGlobalIndexFromClient(); 
     768      auto itb = outGlobalIndexFromClient.begin(), ite = outGlobalIndexFromClient.end() ; 
     769     
     770      for (auto it = itb; it != ite; ++it) 
     771      { 
     772         int rank = it->first; 
     773         CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank]; 
     774         outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 
     775         CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient_[rank]; 
     776         size_t nbIndex = 0; 
     777 
     778        // Keep this code for this moment but it should be removed (or moved to DEBUG) to improve performance 
     779        for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
     780          if (itGloe != globalDataIndex.find(globalIndex(idx))) ++nbIndex; 
     781 
     782        if (nbIndex != localIndex.numElements()) 
     783             ERROR("void CGrid::computeClientIndex()", 
     784                 << "Number of local index on client is different from number of received global index" 
     785                 << "Rank of sent client " << rank <<"." 
     786                 << "Number of local index " << nbIndex << ". " 
     787                 << "Number of received global index " << localIndex.numElements() << "."); 
     788 
     789        nbIndex = 0; 
     790        for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 
     791          if (itGloe != globalDataIndex.find(globalIndex(idx))) 
     792            localIndex(idx) = globalDataIndex[globalIndex(idx)]; 
     793      } 
     794    } 
     795  } 
     796 
     797  bool CGrid::isDataDistributed(void)  
     798  {  
     799    return getClientDistribution()->isDataDistributed() ; 
     800  } 
    839801 
    840802   /*! 
     
    845807   { 
    846808     if (computeConnectedClients_done_.count(client)!=0) return ; 
     809     else  computeConnectedClients_done_.insert(client) ; 
    847810 
    848811     CContext* context = CContext::getCurrent(); 
     
    868831          if (client->isServerLeader()) 
    869832          { 
    870             size_t ssize = getDistributionClient()->getLocalDataIndexOnClient().size(); 
     833            size_t ssize = getClientDistribution()->getLocalDataIndexOnClient().size(); 
    871834            const std::list<int>& ranks = client->getRanksServerLeader(); 
    872835            for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     
    899862         computeIndexByElement(indexServerOnElement, client, globalIndexOnServer_[receiverSize]); 
    900863 
    901        const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getDistributionClient()->getGlobalLocalDataSendToServer(); 
     864       const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer(); 
    902865       CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 
    903866       CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; 
     
    956919       nbSenders_[receiverSize] = CClientServerMapping::computeConnectedClients(receiverSize, client->clientSize, client->intraComm, connectedServerRank_[receiverSize]); 
    957920     } 
    958      computeConnectedClients_done_.insert(client) ; 
    959921   } 
    960922   CATCH_DUMP_ATTR 
     
    975937     if (isScalarGrid()) 
    976938     { 
    977        computeClientIndexScalarGrid(); 
     939       //computeClientIndexScalarGrid(); 
    978940       if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 
    979941       { 
     
    983945     else 
    984946     { 
    985        computeClientIndex(); 
     947       //computeClientIndex(); 
    986948       if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 
    987949       { 
     
    14301392   TRY 
    14311393   { 
    1432       const std::vector<int>& localMaskedDataIndex = getDistributionClient()->getLocalMaskedDataIndexOnClient(); 
     1394      const std::vector<int>& localMaskedDataIndex = getClientDistribution()->getLocalMaskedDataIndexOnClient(); 
    14331395      const int size = localMaskedDataIndex.size(); 
    14341396      for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i]; 
     
    14361398   CATCH 
    14371399 
    1438   void CGrid::computeClientIndexScalarGrid() 
    1439   TRY 
    1440   { 
    1441     if (computeClientIndexScalarGrid_done_) return ; 
    1442  
    1443     CContext* context = CContext::getCurrent();     
    1444     { 
    1445       int rank = context->intraCommRank_; 
    1446  
    1447       auto clientDistribution = getDistributionClient(); 
    1448  
    1449       storeIndex_client_.resize(1); 
    1450       storeIndex_client_(0) = 0;       
    1451  
    1452       if (0 != serverDistribution_) 
    1453       { 
    1454         map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClient_.begin(), 
    1455                                                ite = outGlobalIndexFromClient_.end(), it; 
    1456         for (it = itb; it != ite; ++it) 
    1457         { 
    1458           int rank = it->first; 
    1459           CArray<size_t,1>& globalIndex = outGlobalIndexFromClient_[rank]; 
    1460           outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 
    1461           CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient_[rank]; 
    1462           if (1 != globalIndex.numElements()) 
    1463             ERROR("void CGrid::computeClientIndexScalarGrid()", 
    1464               << "Something wrong happened. " 
    1465               << "Number of received global index on scalar grid should equal to 1"  
    1466               << "Number of received global index " << globalIndex.numElements() << "."); 
    1467  
    1468           localIndex(0) = globalIndex(0); 
    1469         } 
    1470       } 
    1471     } 
    1472     computeClientIndexScalarGrid_done_ = true ; 
    1473   } 
    1474   CATCH_DUMP_ATTR 
    1475  
     1400   
    14761401  void CGrid::computeConnectedClientsScalarGrid(CContextClient* client) 
    14771402  TRY 
     
    15231448      } 
    15241449    } 
    1525     isDataDistributed_ = false; 
     1450    
    15261451    computeConnectedClientsScalarGrid_done_.insert(client) ; 
    15271452  } 
     
    15671492 
    15681493          listMsg.push_back(CMessage()); 
    1569           listMsg.back() << getId( )<< isDataDistributed_ << isCompressible_ << listOutIndex.back(); 
     1494          listMsg.back() << getId( )<< isCompressible_ << listOutIndex.back(); 
    15701495 
    15711496          event.push(rank, 1, listMsg.back()); 
     
    16111536      list<CMessage> listMsg; 
    16121537      list<CArray<size_t,1> > listOutIndex; 
    1613       const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getDistributionClient()->getGlobalLocalDataSendToServer(); 
     1538      const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer(); 
    16141539      CDistributionClient::GlobalLocalDataMap::const_iterator itbIndex = globalLocalIndexSendToServer.begin(), itIndex, 
    16151540                                                              iteIndex = globalLocalIndexSendToServer.end(); 
     
    16391564 
    16401565            listMsg.push_back(CMessage()); 
    1641             listMsg.back() << getId() << isDataDistributed_ << isCompressible_ << listOutIndex.back(); 
     1566            listMsg.back() << getId() << isCompressible_ << listOutIndex.back(); 
    16421567 
    16431568            event.push(*itRank, 1, listMsg.back()); 
     
    17071632          storeIndex_fromSrv_.insert(make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 
    17081633          listMsg.push_back(CMessage()); 
    1709           listMsg.back() << getId() << isDataDistributed_ << isCompressible_ << listOutIndex.back(); 
     1634          listMsg.back() << getId() << isCompressible_ << listOutIndex.back(); 
    17101635 
    17111636          event.push(rank, nbSenders_[receiverSize][rank], listMsg.back()); 
     
    17661691      CBufferIn& buffer = *buffers[n]; 
    17671692 
    1768       buffer >> isDataDistributed_ >> isCompressible_; 
     1693      buffer >> isCompressible_; 
    17691694      size_t dataSize = 0; 
    17701695 
     
    20541979  CATCH_DUMP_ATTR 
    20551980 
    2056   CDistributionClient* CGrid::getDistributionClient() 
     1981  CDistributionClient* CGrid::getClientDistribution() 
    20571982  TRY 
    20581983  { 
     
    20711996    else if (0 != client) 
    20721997    { 
    2073       return  (isDataDistributed_ ||  (1 != client->clientSize) || (1 != client->serverSize)); 
     1998      return  (isDataDistributed() ||  (1 != client->clientSize) || (1 != client->serverSize)); 
    20741999    } 
    20752000    else 
    2076       return isDataDistributed_;     
     2001      return isDataDistributed();     
    20772002  } 
    20782003  CATCH_DUMP_ATTR 
     
    21782103   CATCH_DUMP_ATTR 
    21792104 
     2105 
     2106  void CGrid::sendGridToFileServer(CContextClient* client) 
     2107  { 
     2108    if (sendGridToFileServer_done_.count(client)!=0) return ; 
     2109    else sendGridToFileServer_done_.insert(client) ; 
     2110 
     2111    StdString gridDefRoot("grid_definition"); 
     2112    CGridGroup* gridPtr = CGridGroup::get(gridDefRoot); 
     2113    gridPtr->sendCreateChild(this->getId(),client); 
     2114    this->sendAllAttributesToServer(client); 
     2115    this->sendAllDomains(client); 
     2116    this->sendAllAxis(client); 
     2117    this->sendAllScalars(client); 
     2118  } 
     2119 
    21802120   /*! 
    21812121   \brief Send a message to create a domain on server side 
     
    27942734  { 
    27952735    std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren(); 
    2796     int dSize = domList.size(); 
    2797     for (int i = 0; i < dSize; ++i) 
    2798     { 
    2799       sendAddDomain(domList[i]->getId(),contextClient); 
    2800       domList[i]->sendAllAttributesToServer(contextClient); 
     2736    for (auto domain : domList) 
     2737    { 
     2738      sendAddDomain(domain->getId(),contextClient); 
     2739      domain->sendDomainToFileServer(contextClient); 
    28012740    } 
    28022741  } 
     
    28102749  { 
    28112750    std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren(); 
    2812     int aSize = aList.size(); 
    2813  
    2814     for (int i = 0; i < aSize; ++i) 
     2751    for (int i=0; i<aList.size() ; ++i) 
    28152752    { 
    28162753      sendAddAxis(aList[i]->getId(),contextClient); 
    2817       aList[i]->sendAllAttributesToServer(contextClient); 
     2754      aList[i]->sendAxisToFileServer(contextClient, getGlobalDimension(), getAxisPositionInGrid()[i]); 
    28182755    } 
    28192756  } 
     
    28272764  { 
    28282765    std::vector<CScalar*> sList = this->getVirtualScalarGroup()->getAllChildren(); 
    2829     int sSize = sList.size(); 
    2830  
    2831     for (int i = 0; i < sSize; ++i) 
    2832     { 
    2833       sendAddScalar(sList[i]->getId(),contextClient); 
    2834       sList[i]->sendAllAttributesToServer(contextClient); 
     2766    for (auto scalar : sList) 
     2767    { 
     2768      sendAddScalar(scalar->getId(),contextClient); 
     2769      scalar->sendScalarToFileServer(contextClient); 
    28352770    } 
    28362771  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp

    r1869 r1870  
    146146         CAxis* addAxis(const std::string& id=StdString()); 
    147147         CScalar* addScalar(const std::string& id=StdString()); 
     148 
     149      public: 
     150         void sendGridToFileServer(CContextClient* client) ; 
     151      private: 
     152         std::set<CContextClient*> sendGridToFileServer_done_ ; 
     153       
     154      public: 
    148155         void sendAddDomain(const std::string& id,CContextClient* contextClient); 
    149156         void sendAddAxis(const std::string& id,CContextClient* contextClient); 
     
    193200 
    194201         CDistributionServer* getDistributionServer(); 
    195          CDistributionClient* getDistributionClient(); 
    196202         CGridTransformation* getTransformations(); 
    197203 
     
    231237 
    232238         void computeGridIndexToFileServer(CContextClient* client) ; 
    233  
    234       private: 
     239  
     240     private: 
     241        /** Client-like distribution calculated based on the knowledge of the entire grid */ 
     242       CDistributionClient* clientDistribution_; 
     243     public:  
    235244       void computeClientDistribution(void) ; 
     245     private: 
    236246       bool computeClientDistribution_done_ = false ; 
    237  
     247     public: 
     248       CDistributionClient* getClientDistribution(void);  
     249 
     250     private: 
    238251       template<int N> 
    239252       void checkGridMask(CArray<bool,N>& gridMask, 
     
    277290        int getDistributedDimension(); 
    278291 
    279         
    280         void computeClientIndex(); 
    281         bool computeClientIndex_done_ = false ; 
    282          
    283292        void computeConnectedClients(CContextClient* client); 
    284293        set<CContextClient*> computeConnectedClients_done_ ; 
    285  
    286         void computeClientIndexScalarGrid();  
    287         bool computeClientIndexScalarGrid_done_ = false ; 
    288294 
    289295        void computeConnectedClientsScalarGrid(CContextClient* client);  
     
    346352// Maybe we need a flag to determine whether a client wants to write. TODO " 
    347353 
    348 /** Map storing received data on server side. This map is the equivalent to the storeIndex_client, but for data received from client 
    349   * instead that from model. This map is used to concatenate data received from several clients into a single array on server side 
    350   * which match the local workflow grid. 
    351   * outLocalIndexStoreOnClient_[client_rank] -> Array of index from client of rank "client_rank" 
    352   * outLocalIndexStoreOnClient_[client_rank](index of buffer from client) -> local index of the workflow grid 
    353   * The map is created in CGrid::computeClientIndex and filled upon receiving data in CField::recvUpdateData(). 
    354   * Symetrically it is also used to send data from a server to several client for reading case. */ 
    355          map<int, CArray<size_t, 1> > outLocalIndexStoreOnClient_;  
    356  
    357  
     354      private: 
     355       /** Map storing received data on server side. This map is the equivalent to the storeIndex_client, but for data received from client 
     356        * instead that from model. This map is used to concatenate data received from several clients into a single array on server side 
     357        * which match the local workflow grid. 
     358        * outLocalIndexStoreOnClient_[client_rank] -> Array of index from client of rank "client_rank" 
     359        * outLocalIndexStoreOnClient_[client_rank](index of buffer from client) -> local index of the workflow grid 
     360        * The map is created in CGrid::computeClientIndex and filled upon receiving data in CField::recvUpdateData(). 
     361        * Symetrically it is also used to send data from a server to several client for reading case. */ 
     362        map<int, CArray<size_t, 1>> outLocalIndexStoreOnClient_;  
     363      public: 
     364         void computeOutLocalIndexStoreOnClient(void) ; 
     365      private: 
     366         bool computeOutLocalIndexStoreOnClient_done_ = false ;   
     367      public:    
     368         map<int, CArray<size_t, 1>>& getOutLocalIndexStoreOnClient(void)  
     369         { if (!computeOutLocalIndexStoreOnClient_done_) computeOutLocalIndexStoreOnClient(); return outLocalIndexStoreOnClient_ ; } 
     370 
     371      public: 
    358372/** Indexes calculated based on server-like distribution. 
    359373 *  They are used for writing/reading data and only calculated for server level that does the writing/reading. 
     
    370384         CArray<size_t,1> localIndexToWriteOnClient_; 
    371385 
     386      public:  
     387        bool isDataDistributed(void) ;  
    372388      private: 
    373389 
     
    376392        std::set<CContextClient*> clientsSet; 
    377393 
    378 /** Map storing received indexes on server side sent by clients. Key = sender rank, value = global index array.  
    379     Later, the global indexes received will be mapped onto local index computed with the local distribution. 
    380     outGlobalIndexFromClient_[rank] -> array of global index send by client of rank "rank" 
    381     outGlobalIndexFromClient_[rank](n) -> global index of datav n sent by client 
    382 */ 
     394      private:   
     395        /** Map storing received indexes on server side sent by clients. Key = sender rank, value = global index array.  
     396            Later, the global indexes received will be mapped onto local index computed with the local distribution. 
     397            outGlobalIndexFromClient_[rank] -> array of global index send by client of rank "rank" 
     398            outGlobalIndexFromClient_[rank](n) -> global index of datav n sent by client 
     399        */       
    383400        map<int, CArray<size_t, 1> > outGlobalIndexFromClient_; 
    384  
     401      public:   
     402        map<int, CArray<size_t, 1> >& getOutGlobalIndexFromClient() { return outGlobalIndexFromClient_ ;} 
     403 
     404      private: 
    385405        bool isChecked; 
    386406        bool isDomainAxisChecked; 
     
    393413        bool isAxisListSet, isDomListSet, isScalarListSet; 
    394414 
    395 /** Client-like distribution calculated based on the knowledge of the entire grid */ 
    396         CDistributionClient* clientDistribution_; 
    397  
    398415/** Server-like distribution calculated upon receiving indexes */ 
    399416        CDistributionServer* serverDistribution_; 
     
    416433/** Size of data to be send in case of reading. It is calculated in recvIndex(). */ 
    417434        std::map<int,size_t> connectedDataSizeRead_; 
    418  
    419         bool isDataDistributed_;         
     435       
    420436         //! True if and only if the data defined on the grid can be outputted in a compressed way 
    421437        bool isCompressible_; 
     
    424440        bool isTransformed_, isGenerated_; 
    425441        bool computedWrittenIndex_; 
     442         
    426443        std::vector<int> axisPositionInGrid_; 
     444        void computeAxisPositionInGrid(void) ; 
     445        bool computeAxisPositionInGrid_done_ = false ; 
     446        std::vector<int>& getAxisPositionInGrid(void) { if (!computeAxisPositionInGrid_done_) computeAxisPositionInGrid() ; return axisPositionInGrid_ ;} 
     447 
    427448        CGridTransformation* transformations_; 
    428449        bool hasDomainAxisBaseRef_;         
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp

    r1869 r1870  
    188188  } 
    189189 
     190  void CScalar::sendScalarToFileServer(CContextClient* client) 
     191  { 
     192    if (sendScalarToFileServer_done_.count(client)!=0) return ; 
     193    else sendScalarToFileServer_done_.insert(client) ; 
     194 
     195    StdString scalarDefRoot("scalar_definition"); 
     196    CScalarGroup* scalarPtr = CScalarGroup::get(scalarDefRoot); 
     197    this->sendAllAttributesToServer(client); 
     198  } 
    190199  /*! 
    191200    Parse children nodes of a scalar in xml file. 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp

    r1869 r1870  
    7676            void setCompleted(void) ; 
    7777            void setUncompleted(void) ; 
     78          
     79         public: 
     80            void sendScalarToFileServer(CContextClient* client) ; 
     81         private: 
     82            std::set<CContextClient*> sendScalarToFileServer_done_ ; 
    7883 
    7984         public: 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm_interpolate.cpp

    r1869 r1870  
    352352    this->transformationPosition_.resize(vecAxisValueSizeWithMask); 
    353353 
    354     const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = grid->getDistributionClient()->getGlobalLocalDataSendToServer(); 
     354    const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = grid->getClientDistribution()->getGlobalLocalDataSendToServer(); 
    355355    CDistributionClient::GlobalLocalDataMap::const_iterator itIndex, iteIndex = globalLocalIndexSendToServer.end(); 
    356356    size_t axisSrcSize = axisSrc_->index.numElements(); 
Note: See TracChangeset for help on using the changeset viewer.