Changeset 1870
- Timestamp:
- 04/17/20 18:55:28 (5 years ago)
- 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 546 546 547 547 */ 548 //ym obsolete : to be removed 548 549 void CAxis::sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 549 550 CServerDistributionDescription::ServerDistributionType distType) … … 555 556 556 557 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)*/; 558 559 559 560 this->isChecked = true; 560 561 } 561 562 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 } 562 576 563 577 /*! … … 566 580 \param[in] order 567 581 */ 568 void CAxis::sendAttributes( const std::vector<int>& globalDim, int orderPositionInGrid,582 void CAxis::sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 569 583 CServerDistributionDescription::ServerDistributionType distType) 570 584 TRY 571 585 { 572 sendDistributionAttribute( globalDim, orderPositionInGrid, distType);586 sendDistributionAttribute(client, globalDim, orderPositionInGrid, distType); 573 587 574 588 // if (index.numElements() == n_glo.getValue()) … … 576 590 || (index.numElements() != n_glo)) 577 591 { 578 sendDistributedAttributes( );592 sendDistributedAttributes(client); 579 593 } 580 594 else 581 595 { 582 sendNonDistributedAttributes( );596 sendNonDistributedAttributes(client); 583 597 } 584 598 } … … 874 888 \param [in] distType distribution type of the server. For now, we only have band distribution. 875 889 */ 876 void CAxis::sendDistributionAttribute( const std::vector<int>& globalDim, int orderPositionInGrid,890 void CAxis::sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, 877 891 CServerDistributionDescription::ServerDistributionType distType) 878 892 TRY 879 893 { 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); 916 925 } 917 926 CATCH_DUMP_ATTR … … 953 962 In the future, if new attributes are added, they should also be processed in this function 954 963 */ 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); 1009 1012 } 1010 1013 CATCH_DUMP_ATTR … … 1083 1086 In future, if new attributes are added, they should also be processed in this function 1084 1087 */ 1085 void CAxis::sendDistributedAttributes( void)1088 void CAxis::sendDistributedAttributes(CContextClient* client) 1086 1089 TRY 1087 1090 { 1088 1091 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); 1126 1145 1127 1146 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 } 1132 1158 1133 1159 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); 1189 1186 } 1190 1187 CATCH_DUMP_ATTR -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp
r1869 r1870 145 145 void checkBounds(); 146 146 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, 148 154 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, 150 156 CServerDistributionDescription::ServerDistributionType distType); 151 157 152 158 153 void sendNonDistributedAttributes( void);154 void sendDistributedAttributes( void);159 void sendNonDistributedAttributes(CContextClient* client); 160 void sendDistributedAttributes(CContextClient* client); 155 161 156 162 static void recvNonDistributedAttributes(CEventServer& event); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp
r1869 r1870 271 271 272 272 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 273 332 /*! 274 333 Sets client buffers. … … 277 336 This flag is only true for client and server-1 for communication with server-2 278 337 */ 338 // ym obsolete to be removed 279 339 void CContext::setClientServerBuffer(CContextClient* contextClient, bool bufferForWriting) 280 340 TRY … … 327 387 } 328 388 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 329 481 330 482 //! Verify whether a context is initialized … … 899 1051 900 1052 // Find all enabled fields of each file 901 constvector<CField*>&& fileOutField = findAllEnabledFieldsInFileOut(this->enabledWriteModeFiles);902 constvector<CField*>&& fileInField = findAllEnabledFieldsInFileIn(this->enabledReadModeFiles);903 constvector<CField*>&& CouplerOutField = findAllEnabledFieldsCouplerOut(this->enabledCouplerOut);904 constvector<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); 905 1057 findFieldsWithReadAccess(); 906 const vector<CField*>& fieldWithReadAccess = fieldsWithReadAccess_ ; 1058 vector<CField*>& fieldWithReadAccess = fieldsWithReadAccess_ ; 1059 vector<CField*> fieldModelIn ; // fields potentially from model 907 1060 908 1061 // find all field potentially at workflow end … … 915 1068 for(auto endWorkflowField : endWorkflowFields) endWorkflowField->buildWorkflowGraph(garbageCollector) ; 916 1069 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 918 1074 if (serviceType_==CServicesManager::GATHERER) distributeFiles(this->enabledWriteModeFiles); 919 1075 else if (serviceType_==CServicesManager::CLIENT) for(auto file : this->enabledWriteModeFiles) file->setContextClient(client) ; 920 1076 1077 1078 // workflow endpoint => sent to IO/SERVER 921 1079 if (serviceType_==CServicesManager::CLIENT || serviceType_==CServicesManager::GATHERER) 922 1080 { … … 926 1084 field->computeGridIndexToFileServer() ; // compute grid index for transfer to the server context 927 1085 } 1086 setClientServerBuffer(fileOutField, true) ; // set context 1087 for(auto field : fileOutField) field->sendFieldToFileServer() ; 928 1088 } 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 ; 934 1105 // For now, only read files with client and only one level server 935 1106 // if (hasClient && !hasServer) findEnabledReadModeFiles(); … … 1057 1228 CATCH_DUMP_ATTR 1058 1229 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 1060 1244 void CContext::closeDefinition_old(void) 1061 1245 TRY … … 2068 2252 CATCH_DUMP_ATTR 2069 2253 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) 2161 2256 void CContext::sendEnabledFiles(const std::vector<CFile*>& activeFiles) 2162 2257 TRY -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp
r1869 r1870 159 159 std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize, CContextClient* contextClient, bool bufferForWriting = false); 160 160 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) ; 162 163 163 164 // Distribute files (in write mode) among secondary-server pools according to the estimated data flux … … 181 182 void sendRegistry(void) ; 182 183 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: 184 191 std::string getContextId() {return contextId_;} 185 192 -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp
r1869 r1870 2085 2085 CATCH_DUMP_ATTR 2086 2086 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 2087 2103 /*! 2088 2104 Send all attributes from client to connected clients 2089 2105 The attributes will be rebuilt on receiving side 2090 2106 */ 2107 // ym obsolete to be removed 2091 2108 void CDomain::sendAttributes() 2092 2109 TRY 2093 2110 { 2094 sendDistributionAttributes();2095 sendIndex();2096 sendLonLat();2097 sendArea();2098 sendDataIndex();2111 //sendDistributionAttributes(); 2112 //sendIndex(); 2113 //sendLonLat(); 2114 //sendArea(); 2115 //sendDataIndex(); 2099 2116 } 2100 2117 CATCH … … 2102 2119 Send global index from client to connected client(s) 2103 2120 */ 2104 void CDomain::sendIndex( )2121 void CDomain::sendIndex(CContextClient* client) 2105 2122 TRY 2106 2123 { 2107 2124 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) 2110 2135 { 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(); 2141 2151 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); 2147 2155 } 2148 2156 CATCH_DUMP_ATTR … … 2153 2161 it calculates this distribution then sends it to the corresponding clients on the next level 2154 2162 */ 2155 void CDomain::sendDistributionAttributes( void)2163 void CDomain::sendDistributionAttributes(CContextClient* client) 2156 2164 TRY 2157 2165 { 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()) 2160 2180 { 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); 2202 2205 } 2203 2206 CATCH_DUMP_ATTR … … 2206 2209 Send area from client to connected client(s) 2207 2210 */ 2208 void CDomain::sendArea( )2211 void CDomain::sendArea(CContextClient* client) 2209 2212 TRY 2210 2213 { … … 2212 2215 2213 2216 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) 2217 2228 { 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); 2252 2249 } 2253 2250 CATCH_DUMP_ATTR … … 2258 2255 Because longitude and latitude are optional, this function only called if latitude and longitude exist 2259 2256 */ 2260 void CDomain::sendLonLat( )2257 void CDomain::sendLonLat(CContextClient* client) 2261 2258 TRY 2262 2259 { … … 2264 2261 2265 2262 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) 2268 2276 { 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); 2292 2301 2293 2302 if (hasBounds) 2294 2303 { 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) 2310 2308 { 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); 2319 2311 } 2320 2312 } 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); 2349 2341 } 2350 2342 CATCH_DUMP_ATTR … … 2356 2348 The compressed index are represented with 1 and others are represented with -1 2357 2349 */ 2358 void CDomain::sendDataIndex( )2350 void CDomain::sendDataIndex(CContextClient* client) 2359 2351 TRY 2360 2352 { 2361 2353 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) 2364 2375 { 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); 2427 2413 } 2428 2414 CATCH -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp
r1869 r1870 184 184 void setTransformations(const TransMapTypes&); 185 185 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); 192 199 void convertLonLatValue(); 193 200 void fillInRectilinearLonLat(); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp
r1869 r1870 246 246 if (opeDate <= currDate) 247 247 { 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) 249 250 { 250 251 CArray<double,1> tmp; 251 252 CArray<size_t,1>& indexTmp = it->second; 252 253 *(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); 257 255 } 258 256 } … … 436 434 else 437 435 { 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) 440 438 { 441 439 CArray<size_t,1>& indexTmp = it->second; … … 1025 1023 CATCH_DUMP_ATTR 1026 1024 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 1027 1069 std::map<int, StdSize> CField::getGridAttributesBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 1028 1070 TRY … … 1032 1074 CATCH_DUMP_ATTR 1033 1075 1076 // ym obsolete to be removed 1034 1077 std::map<int, StdSize> CField::getGridDataBufferSize(CContextClient* client, bool bufferForWriting /*= "false"*/) 1035 1078 TRY … … 1038 1081 } 1039 1082 CATCH_DUMP_ATTR 1083 1084 1040 1085 1041 1086 size_t CField::getGlobalWrittenSize() … … 1172 1217 } 1173 1218 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 */ 1175 1224 void CField::connectToFileServer(CGarbageCollector& gc) 1176 1225 { … … 1181 1230 } 1182 1231 1232 /*! 1233 * Compute grid index needed to send grid and data to server 1234 */ 1183 1235 void CField::computeGridIndexToFileServer(void) 1184 1236 { … … 1186 1238 } 1187 1239 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 /*! 1189 1254 * Transform the grid_path attribut into vector of grid. 1190 1255 * \return the vector CGrid* containing the list of grid path for tranformation … … 1231 1296 * read by the client or/and written to a file 1232 1297 */ 1233 1298 // ym obselete : to be removed later.... 1234 1299 void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput) 1235 1300 TRY … … 1888 1953 CATCH 1889 1954 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 1890 1965 void CField::sendAddAllVariables(CContextClient* client) 1891 1966 TRY … … 1916 1991 grid_ref=grid_->getId() ; 1917 1992 SuperClass::sendAllAttributesToServer(client) ; 1993 domain_ref.reset() ; 1994 axis_ref.reset() ; 1995 scalar_ref.reset() ; 1918 1996 grid_ref.reset(); 1919 1997 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp
r1869 r1870 142 142 void sendGridOfEnabledFields(); 143 143 void sendGridComponentOfEnabledFields(); 144 145 void sendFieldToFileServer(void) ; 144 146 145 147 /// Vérifications /// … … 224 226 225 227 void connectToFileServer(CGarbageCollector& gc) ; 228 void connectToModelInput(CGarbageCollector& gc) ; 226 229 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) ; 227 237 private: 228 238 std::vector<CGrid*> getGridPath(void) ; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/file.cpp
r1869 r1870 1345 1345 CATCH_DUMP_ATTR 1346 1346 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 1347 1367 /*! 1348 1368 \brief Dispatch event received from client -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/file.hpp
r1784 r1870 142 142 void sendAddVariableGroup(const string& id, CContextClient* client); 143 143 void sendAddAllVariables(CContextClient* client); 144 144 public: 145 void sendFileToFileServer(CContextClient* client) ; 146 private: 147 std::set<CContextClient*> sendFileToFileServer_done_ ; 148 149 public: 145 150 // Receive info from client 146 151 static void recvAddField(CEventServer& event); -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp
r1869 r1870 33 33 , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 34 34 , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 35 , isDataDistributed_(true), isCompressible_(false)35 , isCompressible_(false) 36 36 , transformations_(0), isTransformed_(false) 37 37 , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) … … 54 54 , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 55 55 , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 56 , isDataDistributed_(true), isCompressible_(false)56 , isCompressible_(false) 57 57 , transformations_(0), isTransformed_(false) 58 58 , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) … … 96 96 if (!isScalarGrid()) 97 97 { 98 std::vector<int> dataNindex = get DistributionClient()->getDataNIndex();98 std::vector<int> dataNindex = getClientDistribution()->getDataNIndex(); 99 99 for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i]; 100 100 } … … 128 128 for (size_t i = 0; i < axisList.size(); ++i) 129 129 { 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]); 131 131 for (it = axisAttBuffSize.begin(), itE = axisAttBuffSize.end(); it != itE; ++it) 132 132 { … … 202 202 CATCH_DUMP_ATTR 203 203 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 204 221 void CGrid::checkAttributesAfterTransformation() 205 222 TRY … … 207 224 setAxisList(); 208 225 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 230 229 setDomainList(); 231 230 std::vector<CDomain*> domListP = this->getDomains(); … … 568 567 if (!axisListP.empty()) 569 568 { 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 583 569 for (int i = 0; i < axisListP.size(); ++i) 584 570 { 585 571 if (sendAtt) 586 axisListP[i]->sendCheckedAttributes(getGlobalDimension(), axisPositionInGrid_[i]);572 axisListP[i]->sendCheckedAttributes(getGlobalDimension(),getAxisPositionInGrid()[i]); 587 573 else 588 574 axisListP[i]->checkAttributesOnClient(); … … 634 620 635 621 size_t nbWritten = 0, indGlo; 636 CDistributionClient::GlobalLocalDataMap& globalDataIndex = get DistributionClient()->getGlobalDataIndexOnClient();622 CDistributionClient::GlobalLocalDataMap& globalDataIndex = getClientDistribution()->getGlobalDataIndexOnClient(); 637 623 CDistributionClient::GlobalLocalDataMap::const_iterator itb = globalDataIndex.begin(), 638 624 ite = globalDataIndex.end(), it; … … 651 637 { 652 638 numberWrittenIndexes_ = nbWritten; 653 if (isDataDistributed _)639 if (isDataDistributed()) 654 640 { 655 641 CContext* context = CContext::getCurrent(); … … 688 674 void CGrid::computeGridIndexToFileServer(CContextClient* client) 689 675 { 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 701 679 // compute indices for client/server transfer for domain 702 680 for (const auto& domainId : domList_) CDomain::get(domainId)->computeConnectedClients(client); … … 705 683 // compute indices for client/server transfer for axis 706 684 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]) ; 717 686 } 718 687 //--------------------------------------------------------------- … … 740 709 else 741 710 { 742 CDistributionClient* clientDistribution = get DistributionClient() ;711 CDistributionClient* clientDistribution = getClientDistribution() ; 743 712 const std::vector<int>& localDataIndex = clientDistribution->getLocalDataIndexOnClient() ; 744 713 int nbStoreIndex = localDataIndex.size() ; … … 759 728 else 760 729 { 761 CDistributionClient* clientDistribution = get DistributionClient() ;730 CDistributionClient* clientDistribution = getClientDistribution() ; 762 731 const std::vector<bool>& localMaskIndex = clientDistribution->getLocalMaskIndexOnClient() ; 763 732 int nbMaskIndex = localMaskIndex.size() ; … … 767 736 } 768 737 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) 803 749 { 804 750 int rank = it->first; 805 CArray<size_t,1>& globalIndex = outGlobalIndexFromClient _[rank];751 CArray<size_t,1>& globalIndex = outGlobalIndexFromClient[rank]; 806 752 outLocalIndexStoreOnClient_.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 807 753 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); 834 761 } 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 } 839 801 840 802 /*! … … 845 807 { 846 808 if (computeConnectedClients_done_.count(client)!=0) return ; 809 else computeConnectedClients_done_.insert(client) ; 847 810 848 811 CContext* context = CContext::getCurrent(); … … 868 831 if (client->isServerLeader()) 869 832 { 870 size_t ssize = get DistributionClient()->getLocalDataIndexOnClient().size();833 size_t ssize = getClientDistribution()->getLocalDataIndexOnClient().size(); 871 834 const std::list<int>& ranks = client->getRanksServerLeader(); 872 835 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) … … 899 862 computeIndexByElement(indexServerOnElement, client, globalIndexOnServer_[receiverSize]); 900 863 901 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = get DistributionClient()->getGlobalLocalDataSendToServer();864 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer(); 902 865 CDistributionClient::GlobalLocalDataMap::const_iterator iteGlobalLocalIndexMap = globalLocalIndexSendToServer.end(), itGlobalLocalIndexMap; 903 866 CClientServerMapping::GlobalIndexMap::const_iterator iteGlobalMap, itbGlobalMap, itGlobalMap; … … 956 919 nbSenders_[receiverSize] = CClientServerMapping::computeConnectedClients(receiverSize, client->clientSize, client->intraComm, connectedServerRank_[receiverSize]); 957 920 } 958 computeConnectedClients_done_.insert(client) ;959 921 } 960 922 CATCH_DUMP_ATTR … … 975 937 if (isScalarGrid()) 976 938 { 977 computeClientIndexScalarGrid();939 //computeClientIndexScalarGrid(); 978 940 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 979 941 { … … 983 945 else 984 946 { 985 computeClientIndex();947 //computeClientIndex(); 986 948 if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER) 987 949 { … … 1430 1392 TRY 1431 1393 { 1432 const std::vector<int>& localMaskedDataIndex = get DistributionClient()->getLocalMaskedDataIndexOnClient();1394 const std::vector<int>& localMaskedDataIndex = getClientDistribution()->getLocalMaskedDataIndexOnClient(); 1433 1395 const int size = localMaskedDataIndex.size(); 1434 1396 for(int i = 0; i < size; ++i) out(localMaskedDataIndex[i]) = data[i]; … … 1436 1398 CATCH 1437 1399 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 1476 1401 void CGrid::computeConnectedClientsScalarGrid(CContextClient* client) 1477 1402 TRY … … 1523 1448 } 1524 1449 } 1525 isDataDistributed_ = false;1450 1526 1451 computeConnectedClientsScalarGrid_done_.insert(client) ; 1527 1452 } … … 1567 1492 1568 1493 listMsg.push_back(CMessage()); 1569 listMsg.back() << getId( )<< is DataDistributed_ << isCompressible_ << listOutIndex.back();1494 listMsg.back() << getId( )<< isCompressible_ << listOutIndex.back(); 1570 1495 1571 1496 event.push(rank, 1, listMsg.back()); … … 1611 1536 list<CMessage> listMsg; 1612 1537 list<CArray<size_t,1> > listOutIndex; 1613 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = get DistributionClient()->getGlobalLocalDataSendToServer();1538 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = getClientDistribution()->getGlobalLocalDataSendToServer(); 1614 1539 CDistributionClient::GlobalLocalDataMap::const_iterator itbIndex = globalLocalIndexSendToServer.begin(), itIndex, 1615 1540 iteIndex = globalLocalIndexSendToServer.end(); … … 1639 1564 1640 1565 listMsg.push_back(CMessage()); 1641 listMsg.back() << getId() << is DataDistributed_ << isCompressible_ << listOutIndex.back();1566 listMsg.back() << getId() << isCompressible_ << listOutIndex.back(); 1642 1567 1643 1568 event.push(*itRank, 1, listMsg.back()); … … 1707 1632 storeIndex_fromSrv_.insert(make_pair(rank, CArray<int,1>(outLocalIndexToServer))); 1708 1633 listMsg.push_back(CMessage()); 1709 listMsg.back() << getId() << isDataDistributed_<< isCompressible_ << listOutIndex.back();1634 listMsg.back() << getId() << isCompressible_ << listOutIndex.back(); 1710 1635 1711 1636 event.push(rank, nbSenders_[receiverSize][rank], listMsg.back()); … … 1766 1691 CBufferIn& buffer = *buffers[n]; 1767 1692 1768 buffer >> isDataDistributed_ >>isCompressible_;1693 buffer >> isCompressible_; 1769 1694 size_t dataSize = 0; 1770 1695 … … 2054 1979 CATCH_DUMP_ATTR 2055 1980 2056 CDistributionClient* CGrid::get DistributionClient()1981 CDistributionClient* CGrid::getClientDistribution() 2057 1982 TRY 2058 1983 { … … 2071 1996 else if (0 != client) 2072 1997 { 2073 return (isDataDistributed _|| (1 != client->clientSize) || (1 != client->serverSize));1998 return (isDataDistributed() || (1 != client->clientSize) || (1 != client->serverSize)); 2074 1999 } 2075 2000 else 2076 return isDataDistributed _;2001 return isDataDistributed(); 2077 2002 } 2078 2003 CATCH_DUMP_ATTR … … 2178 2103 CATCH_DUMP_ATTR 2179 2104 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 2180 2120 /*! 2181 2121 \brief Send a message to create a domain on server side … … 2794 2734 { 2795 2735 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); 2801 2740 } 2802 2741 } … … 2810 2749 { 2811 2750 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) 2815 2752 { 2816 2753 sendAddAxis(aList[i]->getId(),contextClient); 2817 aList[i]->sendA llAttributesToServer(contextClient);2754 aList[i]->sendAxisToFileServer(contextClient, getGlobalDimension(), getAxisPositionInGrid()[i]); 2818 2755 } 2819 2756 } … … 2827 2764 { 2828 2765 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); 2835 2770 } 2836 2771 } -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp
r1869 r1870 146 146 CAxis* addAxis(const std::string& id=StdString()); 147 147 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: 148 155 void sendAddDomain(const std::string& id,CContextClient* contextClient); 149 156 void sendAddAxis(const std::string& id,CContextClient* contextClient); … … 193 200 194 201 CDistributionServer* getDistributionServer(); 195 CDistributionClient* getDistributionClient();196 202 CGridTransformation* getTransformations(); 197 203 … … 231 237 232 238 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: 235 244 void computeClientDistribution(void) ; 245 private: 236 246 bool computeClientDistribution_done_ = false ; 237 247 public: 248 CDistributionClient* getClientDistribution(void); 249 250 private: 238 251 template<int N> 239 252 void checkGridMask(CArray<bool,N>& gridMask, … … 277 290 int getDistributedDimension(); 278 291 279 280 void computeClientIndex();281 bool computeClientIndex_done_ = false ;282 283 292 void computeConnectedClients(CContextClient* client); 284 293 set<CContextClient*> computeConnectedClients_done_ ; 285 286 void computeClientIndexScalarGrid();287 bool computeClientIndexScalarGrid_done_ = false ;288 294 289 295 void computeConnectedClientsScalarGrid(CContextClient* client); … … 346 352 // Maybe we need a flag to determine whether a client wants to write. TODO " 347 353 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: 358 372 /** Indexes calculated based on server-like distribution. 359 373 * They are used for writing/reading data and only calculated for server level that does the writing/reading. … … 370 384 CArray<size_t,1> localIndexToWriteOnClient_; 371 385 386 public: 387 bool isDataDistributed(void) ; 372 388 private: 373 389 … … 376 392 std::set<CContextClient*> clientsSet; 377 393 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 */ 383 400 map<int, CArray<size_t, 1> > outGlobalIndexFromClient_; 384 401 public: 402 map<int, CArray<size_t, 1> >& getOutGlobalIndexFromClient() { return outGlobalIndexFromClient_ ;} 403 404 private: 385 405 bool isChecked; 386 406 bool isDomainAxisChecked; … … 393 413 bool isAxisListSet, isDomListSet, isScalarListSet; 394 414 395 /** Client-like distribution calculated based on the knowledge of the entire grid */396 CDistributionClient* clientDistribution_;397 398 415 /** Server-like distribution calculated upon receiving indexes */ 399 416 CDistributionServer* serverDistribution_; … … 416 433 /** Size of data to be send in case of reading. It is calculated in recvIndex(). */ 417 434 std::map<int,size_t> connectedDataSizeRead_; 418 419 bool isDataDistributed_; 435 420 436 //! True if and only if the data defined on the grid can be outputted in a compressed way 421 437 bool isCompressible_; … … 424 440 bool isTransformed_, isGenerated_; 425 441 bool computedWrittenIndex_; 442 426 443 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 427 448 CGridTransformation* transformations_; 428 449 bool hasDomainAxisBaseRef_; -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp
r1869 r1870 188 188 } 189 189 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 } 190 199 /*! 191 200 Parse children nodes of a scalar in xml file. -
XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp
r1869 r1870 76 76 void setCompleted(void) ; 77 77 void setUncompleted(void) ; 78 79 public: 80 void sendScalarToFileServer(CContextClient* client) ; 81 private: 82 std::set<CContextClient*> sendScalarToFileServer_done_ ; 78 83 79 84 public: -
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/axis_algorithm_interpolate.cpp
r1869 r1870 352 352 this->transformationPosition_.resize(vecAxisValueSizeWithMask); 353 353 354 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = grid->get DistributionClient()->getGlobalLocalDataSendToServer();354 const CDistributionClient::GlobalLocalDataMap& globalLocalIndexSendToServer = grid->getClientDistribution()->getGlobalLocalDataSendToServer(); 355 355 CDistributionClient::GlobalLocalDataMap::const_iterator itIndex, iteIndex = globalLocalIndexSendToServer.end(); 356 356 size_t axisSrcSize = axisSrc_->index.numElements();
Note: See TracChangeset
for help on using the changeset viewer.