Changeset 1637 for XIOS/trunk/src/node/axis.cpp
- Timestamp:
- 01/14/19 13:33:48 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/axis.cpp
r1622 r1637 274 274 TRY 275 275 { 276 if (this->n_glo.isEmpty()) 276 CContext* context=CContext::getCurrent(); 277 278 if (this->n_glo.isEmpty()) 277 279 ERROR("CAxis::checkAttributes(void)", 278 280 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " … … 314 316 } 315 317 316 // Remove this check because it doesn't make sense in case of a hole or overlapping axes317 318 if (!this->value.isEmpty()) 318 319 { 319 // StdSize true_size = value.numElements(); 320 // if (this->n.getValue() != true_size) 321 // ERROR("CAxis::checkAttributes(void)", 322 // << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 323 // << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 320 // Avoid this check at writing because it fails in case of a hole 321 if (context->hasClient) 322 { 323 StdSize true_size = value.numElements(); 324 if (this->n.getValue() != true_size) 325 ERROR("CAxis::checkAttributes(void)", 326 << "[ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] " 327 << "The axis is wrongly defined, attribute 'value' has a different size (" << true_size 328 << ") than the one defined by the \'size\' attribute (" << n.getValue() << ")."); 329 } 324 330 this->hasValue = true; 325 331 } … … 327 333 this->checkBounds(); 328 334 329 CContext* context=CContext::getCurrent();330 335 if (context->hasClient) 331 336 { 337 this->checkMask(); 332 338 this->checkData(); 333 this->checkMask();334 339 this->checkLabel(); 335 340 } … … 338 343 339 344 /*! 340 Check the validity of data and fill in values if any.345 Check the validity of data, fill in values if any, and apply mask. 341 346 */ 342 347 void CAxis::checkData() … … 359 364 { 360 365 data_index.resize(data_n); 361 for (int i = 0; i < data_n; ++i) data_index(i) = i; 362 } 366 for (int i = 0; i < data_n; ++i) 367 { 368 if ((i+data_begin) >= 0 && (i+data_begin<n)) 369 { 370 if (mask(i+data_begin)) 371 data_index(i) = i+data_begin; 372 else 373 data_index(i) = -1; 374 } 375 else 376 data_index(i) = -1; 377 } 378 } 379 else 380 { 381 if (data_index.numElements() != data_n) 382 { 383 ERROR("CAxis::checkData(void)", 384 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 385 << "The size of data_index = "<< data_index.numElements() << "is not equal to the data size data_n = " << data_n.getValue() << ")."); 386 } 387 for (int i = 0; i < data_n; ++i) 388 { 389 if ((i+data_begin) >= 0 && (i+data_begin<n) && !mask(i+data_begin)) 390 data_index(i) = -1; 391 } 392 } 393 363 394 } 364 395 CATCH_DUMP_ATTR … … 377 408 if (!mask.isEmpty()) 378 409 { 379 if (mask.extent(0) != n) 380 ERROR("CAxis::checkMask(void)", 381 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 382 << "The mask does not have the same size as the local domain." << std::endl 383 << "Local size is " << n.getValue() << "." << std::endl 384 << "Mask size is " << mask.extent(0) << "."); 385 } 386 else // (mask.isEmpty()) 387 { // If no mask was defined, we create a default one without any masked point. 388 mask.resize(n); 389 for (int i = 0; i < n; ++i) 390 { 391 mask(i) = true; 392 } 410 if (mask.extent(0) != n) 411 { 412 ERROR("CAxis::checkMask(void)", 413 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 414 << "The mask does not have the same size as the local domain." << std::endl 415 << "Local size is " << n.getValue() << "." << std::endl 416 << "Mask size is " << mask.extent(0) << "."); 417 } 418 } 419 else 420 { 421 mask.resize(n); 422 mask = true; 393 423 } 394 424 } … … 598 628 599 629 // Calculate the compressed index if any 600 std::set<int> writtenInd;601 if (isCompressible_)602 {603 for (int idx = 0; idx < data_index.numElements(); ++idx)604 {605 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni);606 607 if (ind >= 0 && ind < ni && mask(ind))608 {609 ind += ibegin;610 writtenInd.insert(ind);611 }612 }613 }630 // std::set<int> writtenInd; 631 // if (isCompressible_) 632 // { 633 // for (int idx = 0; idx < data_index.numElements(); ++idx) 634 // { 635 // int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 636 // 637 // if (ind >= 0 && ind < ni && mask(ind)) 638 // { 639 // ind += ibegin; 640 // writtenInd.insert(ind); 641 // } 642 // } 643 // } 614 644 615 645 // Compute the global index of the current client (process) hold … … 680 710 connectedServerRank_[nbServer].push_back(client->clientRank % client->serverSize); 681 711 682 712 nbSenders[nbServer] = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_[nbServer]); 683 713 684 714 delete clientServerMap; … … 718 748 CArray<size_t,1>::const_iterator itSrvb = writtenGlobalIndex.begin(), 719 749 itSrve = writtenGlobalIndex.end(), itSrv; 750 751 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements()); 752 nbWritten = 0; 720 753 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv) 721 754 { … … 723 756 if (ite != globalLocalIndexMap_.find(indGlo)) 724 757 { 725 ++nbWritten;726 }727 }728 729 localIndexToWriteOnServer.resize(writtenGlobalIndex.numElements());730 // localIndexToWriteOnServer.resize(nbWritten);731 732 nbWritten = 0;733 for (itSrv = itSrvb; itSrv != itSrve; ++itSrv)734 {735 indGlo = *itSrv;736 if (ite != globalLocalIndexMap_.find(indGlo))737 {738 758 localIndexToWriteOnServer(nbWritten) = globalLocalIndexMap_[indGlo]; 739 ++nbWritten; 740 } 741 } 759 } 760 else 761 { 762 localIndexToWriteOnServer(nbWritten) = -1; 763 } 764 ++nbWritten; 765 } 766 742 767 } 743 768 CATCH_DUMP_ATTR … … 780 805 } 781 806 } 807 // 808 // nbWritten = 0; 809 // for (int idx = 0; idx < data_index.numElements(); ++idx) 810 // { 811 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 812 // { 813 // ++nbWritten; 814 // } 815 // } 816 // 817 // compressedIndexToWriteOnServer[writtenCommSize].resize(nbWritten); 818 // nbWritten = 0; 819 // for (int idx = 0; idx < data_index.numElements(); ++idx) 820 // { 821 // if (localGlobalIndexMap.end() != localGlobalIndexMap.find(data_index(idx))) 822 // { 823 // compressedIndexToWriteOnServer[writtenCommSize](nbWritten) = localGlobalIndexMap[data_index(idx)]; 824 // ++nbWritten; 825 // } 826 // } 782 827 783 828 nbWritten = 0; … … 1027 1072 1028 1073 /* 1029 Send a ttributes of axis from a group of client to other group of clients/servers1030 onsupposing that these attributes are distributed among the clients of the sending group1031 In thefuture, if new attributes are added, they should also be processed in this function1074 Send axis attributes from a group of clients to another group of clients/servers 1075 supposing that these attributes are distributed among the clients of the sending group 1076 In future, if new attributes are added, they should also be processed in this function 1032 1077 */ 1033 1078 void CAxis::sendDistributedAttributes(void) 1034 1079 TRY 1035 1080 { 1036 int ns, n, i, j, ind, nv, idx;1081 int ind, idx; 1037 1082 std::list<CContextClient*>::iterator it; 1038 1083 … … 1046 1091 list<CMessage> listData; 1047 1092 list<CArray<int,1> > list_indi, list_dataInd; 1048 list<CArray<bool,1> > list_mask;1049 1093 list<CArray<double,1> > list_val; 1050 1094 list<CArray<double,2> > list_bounds; 1051 1095 list<CArray<string,1> > list_label; 1052 1096 1097 // Cut off the ghost points 1053 1098 int nbIndex = index.numElements(); 1054 1099 CArray<int,1> dataIndex(nbIndex); … … 1057 1102 { 1058 1103 if (0 <= data_index(idx) && data_index(idx) < nbIndex) 1059 dataIndex( idx) = 1;1104 dataIndex(data_index(idx)) = 1; 1060 1105 } 1061 1106 … … 1064 1109 for (int k = 0; k < connectedServerRank_[nbServer].size(); ++k) 1065 1110 { 1066 int nbData = 0 ;1111 int nbData = 0, nbDataCount = 0; 1067 1112 int rank = connectedServerRank_[nbServer][k]; 1068 1113 it = indSrv_[nbServer].find(rank); … … 1071 1116 1072 1117 list_indi.push_back(CArray<int,1>(nbData)); 1073 list_dataInd.push_back(CArray<int,1>(nbData)); 1074 list_mask.push_back(CArray<bool,1>(nbData)); 1118 list_dataInd.push_back(CArray<int,1>(nbData)); 1075 1119 1076 1120 if (hasValue) … … 1084 1128 1085 1129 CArray<int,1>& indi = list_indi.back(); 1086 CArray<int,1>& dataIndi = list_dataInd.back(); 1087 CArray<bool,1>& maskIndi = list_mask.back();1088 1089 for ( n = 0; n < nbData; ++n)1130 CArray<int,1>& dataIndi = list_dataInd.back(); 1131 dataIndi = -1; 1132 1133 for (int n = 0; n < nbData; ++n) 1090 1134 { 1091 1135 idx = static_cast<int>(it->second[n]); … … 1094 1138 ind = globalLocalIndexMap_[idx]; 1095 1139 dataIndi(n) = dataIndex(ind); 1096 maskIndi(n) = mask(ind);1097 1140 1098 1141 if (hasValue) … … 1118 1161 listData.push_back(CMessage()); 1119 1162 listData.back() << this->getId() 1120 << list_indi.back() << list_dataInd.back() << list_mask.back();1163 << list_indi.back() << list_dataInd.back(); 1121 1164 1122 1165 listData.back() << hasValue; … … 1173 1216 int nbReceived = ranks.size(), idx, ind, gloInd, locInd; 1174 1217 vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived); 1175 vector<CArray<bool,1> > vec_mask(nbReceived);1176 1218 vector<CArray<double,1> > vec_val(nbReceived); 1177 1219 vector<CArray<double,2> > vec_bounds(nbReceived); … … 1183 1225 buffer >> vec_indi[idx]; 1184 1226 buffer >> vec_dataInd[idx]; 1185 buffer >> vec_mask[idx];1186 1227 1187 1228 buffer >> hasValue; … … 1220 1261 if (0 == globalLocalIndexMap_.count(gloInd)) 1221 1262 { 1222 index(nbInd Loc) = gloInd % n_glo;1223 globalLocalIndexMap_[gloInd] = nbInd Loc;1263 index(nbIndexGlob) = gloInd % n_glo; 1264 globalLocalIndexMap_[gloInd] = nbIndexGlob; 1224 1265 ++nbIndexGlob; 1225 1266 } … … 1234 1275 CArray<int,1> nonCompressedData(nbData); 1235 1276 nonCompressedData = -1; 1236 mask.resize(nbData); 1277 // Mask is incorporated into data_index and is not sent/received anymore 1278 mask.resize(0); 1237 1279 if (hasValue) 1238 1280 value.resize(nbData); … … 1247 1289 CArray<int,1>& indi = vec_indi[idx]; 1248 1290 CArray<int,1>& dataIndi = vec_dataInd[idx]; 1249 CArray<bool,1>& maskIndi = vec_mask[idx];1250 1291 int nb = indi.numElements(); 1251 1292 for (int n = 0; n < nb; ++n) … … 1255 1296 nonCompressedData(locInd) = (-1 == nonCompressedData(locInd)) ? dataIndi(n) : nonCompressedData(locInd); 1256 1297 1257 if (!mask(locInd)) // Only rewrite mask if it's not true1258 mask(locInd) = maskIndi(n);1259 1260 1298 if (hasValue) 1261 1299 value(locInd) = vec_val[idx](n); … … 1272 1310 } 1273 1311 1274 int nbCompressedData = 0; 1312 int nbCompressedData = 0; 1275 1313 for (idx = 0; idx < nonCompressedData.numElements(); ++idx) 1276 1314 { 1277 1315 if (0 <= nonCompressedData(idx)) 1278 ++nbCompressedData; 1316 ++nbCompressedData; 1279 1317 } 1280 1318 … … 1286 1324 { 1287 1325 data_index(nbCompressedData) = idx % n; 1288 ++nbCompressedData; 1326 ++nbCompressedData; 1289 1327 } 1290 1328 } 1291 1329 1292 1330 data_begin.setValue(0); 1331 data_n.setValue(data_index.numElements()); 1293 1332 } 1294 1333 CATCH_DUMP_ATTR
Note: See TracChangeset
for help on using the changeset viewer.