Changeset 1570
- Timestamp:
- 08/31/18 14:15:54 (6 years ago)
- Location:
- XIOS/dev/dev_olga/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/distribution_client.cpp
r1568 r1570 15 15 , axisDomainOrder_() 16 16 , nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_() 17 , dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_() , domainMasks_(), axisMasks_()17 , dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_()//, domainMasks_()//, axisMasks_() 18 18 , gridMask_(), indexMap_() 19 19 , isDataDistributed_(true), axisNum_(0), domainNum_(0) … … 117 117 axisDomainOrder_ = axisDomainOrder; 118 118 119 // Each domain or axis has its mask, of course120 domainMasks_.resize(domainNum_);121 for (int i = 0; i < domainNum_;++i)122 {123 domainMasks_[i].resize(domList[i]->domainMask.numElements());124 domainMasks_[i] = domList[i]->domainMask;125 }126 127 axisMasks_.resize(axisNum_);128 for (int i = 0; i < axisNum_; ++i)129 {130 axisMasks_[i].resize(axisList[i]->mask.numElements());131 axisMasks_[i] = axisList[i]->mask;132 }119 // // Each domain or axis has its mask, of course 120 // domainMasks_.resize(domainNum_); 121 // for (int i = 0; i < domainNum_;++i) 122 // { 123 // domainMasks_[i].resize(domList[i]->domainMask.numElements()); 124 // domainMasks_[i] = domList[i]->domainMask; 125 // } 126 127 // axisMasks_.resize(axisNum_); 128 // for (int i = 0; i < axisNum_; ++i) 129 // { 130 // axisMasks_[i].resize(axisList[i]->mask.numElements()); 131 // axisMasks_[i] = axisList[i]->mask; 132 // } 133 133 134 134 // Because domain and axis can be in any order (axis1, domain1, axis2, axis3, ) … … 282 282 283 283 if ((iIdx >= nBeginLocal_[indexMap_[i]]) && (iIdx < nLocal_[indexMap_[i]]) && 284 (jIdx >= nBeginLocal_[indexMap_[i]+1]) && (jIdx < nLocal_[indexMap_[i]+1]) 285 && (domainMasks_[idxDomain](iIdx + jIdx*nLocal_[indexMap_[i]])))284 (jIdx >= nBeginLocal_[indexMap_[i]+1]) && (jIdx < nLocal_[indexMap_[i]+1])) 285 // && (domainMasks_[idxDomain](iIdx + jIdx*nLocal_[indexMap_[i]]))) 286 286 { 287 287 ++count; … … 330 330 iIdx = getAxisIndex((dataIndex_[indexMap_[i]])(j), dataBegin_[indexMap_[i]], nLocal_[indexMap_[i]]); 331 331 if ((iIdx >= nBeginLocal_[indexMap_[i]]) && 332 (iIdx < nLocal_[indexMap_[i]]) && (axisMasks_[idxAxis](iIdx)))332 (iIdx < nLocal_[indexMap_[i]]) )//&& (axisMasks_[idxAxis](iIdx))) 333 333 { 334 334 ++count; … … 413 413 414 414 for (int i = 0; i < numElement_; ++i) ssize *= eachElementSize[i]; 415 while (idx < ssize)416 {417 for (int i = 0; i < numElement_-1; ++i)418 {419 if (idxLoop[i] == eachElementSize[i])420 {421 idxLoop[i] = 0;422 ++idxLoop[i+1];423 }424 }425 426 // Find out outer index427 // Depending the inner-most element is axis or domain,428 // The outer loop index begins correspondingly at one (1) or zero (0)429 for (int i = 1; i < numElement_; ++i)430 {431 currentIndex[i] = elementLocalIndex_[i](idxLoop[i]);432 }433 434 // Inner most index435 for (int i = 0; i < innerLoopSize; ++i)436 {437 int gridMaskIndex = 0;438 currentIndex[0] = elementLocalIndex_[0](i);439 440 bool maskTmp = true;441 int idxDomain = 0, idxAxis = 0;442 for (int elem = 0; elem < numElement_; ++elem)443 {444 if (2 == axisDomainOrder_(elem))445 {446 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]);447 ++idxDomain;448 }449 else if (1 == axisDomainOrder_(elem))450 {451 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]);452 ++idxAxis;453 }454 }455 if (maskTmp) ++indexLocalDataOnClientCount;456 }457 idxLoop[0] += innerLoopSize;458 idx += innerLoopSize;459 }415 // while (idx < ssize) 416 // { 417 // for (int i = 0; i < numElement_-1; ++i) 418 // { 419 // if (idxLoop[i] == eachElementSize[i]) 420 // { 421 // idxLoop[i] = 0; 422 // ++idxLoop[i+1]; 423 // } 424 // } 425 // 426 // // Find out outer index 427 // // Depending the inner-most element is axis or domain, 428 // // The outer loop index begins correspondingly at one (1) or zero (0) 429 // for (int i = 1; i < numElement_; ++i) 430 // { 431 // currentIndex[i] = elementLocalIndex_[i](idxLoop[i]); 432 // } 433 // 434 // // Inner most index 435 // for (int i = 0; i < innerLoopSize; ++i) 436 // { 437 // int gridMaskIndex = 0; 438 // currentIndex[0] = elementLocalIndex_[0](i); 439 // 440 // bool maskTmp = true; 441 // int idxDomain = 0, idxAxis = 0; 442 // for (int elem = 0; elem < numElement_; ++elem) 443 // { 444 // if (2 == axisDomainOrder_(elem)) 445 // { 446 // maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 447 // ++idxDomain; 448 // } 449 // else if (1 == axisDomainOrder_(elem)) 450 // { 451 // maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 452 // ++idxAxis; 453 // } 454 // } 455 // if (maskTmp) ++indexLocalDataOnClientCount; 456 // } 457 // idxLoop[0] += innerLoopSize; 458 // idx += innerLoopSize; 459 // } 460 460 461 461 // Now allocate these arrays 462 localDataIndex_.resize(indexLocalDataOnClientCount); 463 localMaskIndex_.resize(indexLocalDataOnClientCount); 464 localMaskedDataIndex_.resize(indexLocalDataOnClientCount); 465 globalDataIndex_.rehash(std::ceil(indexLocalDataOnClientCount/globalDataIndex_.max_load_factor())); 466 globalLocalDataSendToServerMap_.rehash(std::ceil(indexLocalDataOnClientCount/globalLocalDataSendToServerMap_.max_load_factor())); 462 // localDataIndex_.resize(indexLocalDataOnClientCount); 463 // localMaskIndex_.resize(indexLocalDataOnClientCount); 464 // localMaskedDataIndex_.resize(indexLocalDataOnClientCount); 465 // globalDataIndex_.rehash(std::ceil(indexLocalDataOnClientCount/globalDataIndex_.max_load_factor())); 466 // globalLocalDataSendToServerMap_.rehash(std::ceil(indexLocalDataOnClientCount/globalLocalDataSendToServerMap_.max_load_factor())); 467 468 localDataIndex_.resize(ssize); 469 if (!gridMask_.isEmpty()) localMaskIndex_.resize(ssize); 470 localMaskedDataIndex_.resize(ssize); 471 globalDataIndex_.rehash(std::ceil(ssize/globalDataIndex_.max_load_factor())); 472 globalLocalDataSendToServerMap_.rehash(std::ceil(ssize/globalLocalDataSendToServerMap_.max_load_factor())); 473 467 474 468 475 // We need to loop with data index … … 524 531 bool maskGridTmp = true; 525 532 526 // Domain or axis mask: only unmasked values will be sent 527 int idxDomain = 0, idxAxis = 0; 528 for (int elem = 0; elem < numElement_; ++elem) 529 { 530 if (2 == axisDomainOrder_(elem)) 533 // // Domain or axis mask: only unmasked values will be sent 534 // int idxDomain = 0, idxAxis = 0; 535 // for (int elem = 0; elem < numElement_; ++elem) 536 // { 537 // if (2 == axisDomainOrder_(elem)) 538 // { 539 // maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 540 // ++idxDomain; 541 // } 542 // else if (1 == axisDomainOrder_(elem)) 543 // { 544 // maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 545 // ++idxAxis; 546 // } 547 // } 548 549 // if (maskTmp) 550 // { 551 size_t globalIndex = 0; 552 for (int k = 0; k < numElement_; ++k) 531 553 { 532 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 533 ++idxDomain; 554 globalIndex += (currentGlobalIndex[k])*elementNGlobal_[k]; 534 555 } 535 else if (1 == axisDomainOrder_(elem)) 536 { 537 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 538 ++idxAxis; 539 } 540 } 556 globalDataIndex_[globalIndex] = indexLocalDataOnClientCount; 557 localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 558 globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount; 559 localMaskedDataIndex_[indexLocalDataOnClientCount] = indexLocalDataOnClientCount; 560 // } 541 561 542 562 // Grid mask: unmasked values will be replaces by NaN and then all values will be sent … … 549 569 } 550 570 maskGridTmp = gridMask_(gridMaskIndex); 551 }552 553 if (maskTmp)554 {555 size_t globalIndex = 0;556 for (int k = 0; k < numElement_; ++k)557 {558 globalIndex += (currentGlobalIndex[k])*elementNGlobal_[k];559 }560 globalDataIndex_[globalIndex] = indexLocalDataOnClientCount;561 localDataIndex_[indexLocalDataOnClientCount] = countLocalData;562 571 if (maskGridTmp) 563 572 localMaskIndex_[indexLocalDataOnClientCount] = true; 564 573 else 565 574 localMaskIndex_[indexLocalDataOnClientCount] = false; 566 globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount;567 localMaskedDataIndex_[indexLocalDataOnClientCount] = indexLocalDataOnClientCount;568 ++indexLocalDataOnClientCount;569 575 } 576 577 ++indexLocalDataOnClientCount; 578 570 579 } 571 580 ++countLocalData; … … 600 609 const int& dataDim, const int& ni, int& j) 601 610 { 611 int i; 602 612 int tempI = dataIIndex + dataIBegin, 603 613 tempJ = (dataJIndex + dataJBegin); 604 614 if (ni == 0) 605 615 { 606 i nt i = 0;607 j = 0;616 i = -1; 617 j = -1; 608 618 return i; 609 619 } 610 int i = (dataDim == 1) ? (tempI) % ni 611 : (tempI) ; 612 j = (dataDim == 1) ? (tempI) / ni 613 : (tempJ) ; 614 620 if ((tempI < 0) || (tempJ < 0)) 621 { 622 i = -1; 623 j = -1; 624 return i; 625 } 626 else 627 { 628 i = (dataDim == 1) ? (tempI) % ni : (tempI) ; 629 j = (dataDim == 1) ? (tempI) / ni : (tempJ) ; 630 } 615 631 return i; 616 632 } … … 629 645 return -1; 630 646 } 631 int tempI = dataIndex; //+ dataBegin;647 int tempI = dataIndex; 632 648 if ((tempI < 0) || (tempI > ni)) 633 649 return -1; -
XIOS/dev/dev_olga/src/distribution_client.hpp
r1568 r1570 93 93 std::vector<int> localDataIndex_; 94 94 95 /*! Array holding grid mask. 95 /*! Array holding grid mask. If grid mask is not defined, its size is zero. 96 96 * It is used by source filter of client for replacing unmasked data by NaN. 97 97 */ … … 118 118 std::vector<CArray<int,1> > infoIndex_; //!< i_index, j_index 119 119 120 std::vector<CArray<bool,1> > domainMasks_; //!< Domain mask121 std::vector<CArray<bool,1> > axisMasks_; //!< Axis mask120 // std::vector<CArray<bool,1> > domainMasks_; //!< Domain mask 121 // std::vector<CArray<bool,1> > axisMasks_; //!< Axis mask 122 122 123 123 std::vector<int> indexMap_; //!< Mapping element index to dimension index -
XIOS/dev/dev_olga/src/node/axis.cpp
r1568 r1570 300 300 if (context->hasClient) 301 301 { 302 this->checkMask(); 302 303 this->checkData(); 303 this->checkMask();304 304 this->checkLabel(); 305 305 } … … 307 307 308 308 /*! 309 Check the validity of data and fill in values if any.309 Check the validity of data, fill in values if any, and apply mask. 310 310 */ 311 311 … … 331 331 { 332 332 if ((i+data_begin) >= 0 && (i+data_begin<n)) 333 data_index(i) = i+data_begin; 333 { 334 if (mask(i+data_begin)) 335 data_index(i) = i+data_begin; 336 else 337 data_index(i) = -1; 338 } 334 339 else 335 340 data_index(i) = -1; … … 344 349 << "The size of data_index = "<< data_index.numElements() << "is not equal to the data size data_n = " << data_n.getValue() << ")."); 345 350 } 346 data_index.resize(data_n);347 351 for (int i = 0; i < data_n; ++i) 348 352 { 349 if ((i+data_begin) >= 0 && (i+data_begin<n)) 350 data_index(i) = data_index(i); 351 else 353 if ((i+data_begin) >= 0 && (i+data_begin<n) && !mask(i+data_begin)) 352 354 data_index(i) = -1; 353 355 } … … 1070 1072 ind = globalLocalIndexMap_[idx]; 1071 1073 dataIndi(n) = dataIndex(ind); 1072 maskIndi(n) = mask(ind);1074 // maskIndi(n) = mask(ind); 1073 1075 1074 1076 if (hasValue) … … 1094 1096 listData.push_back(CMessage()); 1095 1097 listData.back() << this->getId() 1096 << list_indi.back() << list_dataInd.back() 1098 << list_indi.back() << list_dataInd.back(); //<< list_mask.back(); 1097 1099 1098 1100 listData.back() << hasValue; … … 1155 1157 buffer >> vec_indi[idx]; 1156 1158 buffer >> vec_dataInd[idx]; 1157 buffer >> vec_mask[idx];1159 // buffer >> vec_mask[idx]; 1158 1160 1159 1161 buffer >> hasValue; … … 1206 1208 CArray<int,1> nonCompressedData(nbData); 1207 1209 nonCompressedData = -1; 1208 mask.resize(nbData); 1209 mask = true; 1210 // mask.resize(nbData); 1211 // mask = true; 1212 // Mask is incorporated into data_index and is not sent/received anymore 1213 mask.resize(0); 1210 1214 if (hasValue) 1211 1215 value.resize(nbData); … … 1220 1224 CArray<int,1>& indi = vec_indi[idx]; 1221 1225 CArray<int,1>& dataIndi = vec_dataInd[idx]; 1222 CArray<bool,1>& maskIndi = vec_mask[idx];1226 // CArray<bool,1>& maskIndi = vec_mask[idx]; 1223 1227 int nb = indi.numElements(); 1224 1228 for (int n = 0; n < nb; ++n) … … 1228 1232 nonCompressedData(locInd) = (-1 == nonCompressedData(locInd)) ? dataIndi(n) : nonCompressedData(locInd); 1229 1233 1230 if (!mask(locInd)) // Only rewrite mask if it's not true1231 mask(locInd) = maskIndi(n);1234 // if (!mask(locInd)) // Only rewrite mask if it's not true 1235 // mask(locInd) = maskIndi(n); 1232 1236 1233 1237 if (hasValue) -
XIOS/dev/dev_olga/src/node/domain.cpp
r1568 r1570 1081 1081 void CDomain::checkCompression(void) 1082 1082 { 1083 int i,j,ind; 1083 1084 if (!data_i_index.isEmpty()) 1084 1085 { … … 1101 1102 << "'data_j_index' must be defined when 'data_i_index' is set and 'data_dim' is 2."); 1102 1103 } 1104 for (int k=0; k<data_i_index.numElements(); ++k) 1105 { 1106 i = data_i_index(k)+data_ibegin ; 1107 j = data_j_index(k)+data_jbegin ; 1108 if (i>=0 && i<ni && j>=0 && j<nj) 1109 { 1110 ind=j*ni+i ; 1111 if (!domainMask(ind)) 1112 { 1113 data_i_index(k) = -1; 1114 data_j_index(k) = -1; 1115 } 1116 } 1117 else 1118 { 1119 data_i_index(k) = -1; 1120 data_j_index(k) = -1; 1121 } 1122 } 1103 1123 } 1104 1124 else // (1 == data_dim) … … 1107 1127 { 1108 1128 data_j_index.resize(data_ni); 1109 for (int j = 0; j < data_ni; ++j) data_j_index(j) = 0; 1129 data_j_index(j) = 0; 1130 } 1131 for (int k=0; k<data_i_index.numElements(); ++k) 1132 { 1133 i=data_i_index(k)+data_ibegin ; 1134 if (i>=0 && i < domainMask.size()) 1135 { 1136 if (!domainMask(i)) data_i_index(k) = -1; 1137 } 1138 else 1139 data_i_index(k) = -1; 1140 1141 if (!domainMask(i)) data_i_index(k) = -1; 1110 1142 } 1111 1143 } … … 1122 1154 data_i_index.resize(data_ni); 1123 1155 data_j_index.resize(data_ni); 1124 1125 for (int i = 0; i < data_ni; ++i) 1156 data_j_index = 0; 1157 1158 for (int k = 0; k < data_ni; ++k) 1126 1159 { 1127 data_i_index(i) = i; 1128 data_j_index(i) = 0; 1160 i=k+data_ibegin ; 1161 if (i>=0 && i < domainMask.size()) 1162 { 1163 if (domainMask(i)) 1164 data_i_index(k) = k; 1165 else 1166 data_i_index(k) = -1; 1167 } 1168 else 1169 data_i_index(k) = -1; 1129 1170 } 1130 1171 } … … 1135 1176 data_j_index.resize(dsize); 1136 1177 1137 for(int count = 0, j = 0; j < data_nj; ++j)1178 for(int count = 0, kj = 0; kj < data_nj; ++kj) 1138 1179 { 1139 for(int i = 0; i < data_ni; ++i, ++count)1180 for(int ki = 0; ki < data_ni; ++ki, ++count) 1140 1181 { 1141 data_i_index(count) = i; 1142 data_j_index(count) = j; 1182 i = ki + data_ibegin; 1183 j = kj + data_jbegin; 1184 ind=j*ni+i ; 1185 if (i>=0 && i<ni && j>=0 && j<nj) 1186 { 1187 if (domainMask(ind)) 1188 { 1189 data_i_index(count) = ki; 1190 data_j_index(count) = kj; 1191 } 1192 else 1193 { 1194 data_i_index(count) = -1; 1195 data_j_index(count) = -1; 1196 } 1197 } 1198 else 1199 { 1200 data_i_index(count) = -1; 1201 data_j_index(count) = -1; 1202 } 1143 1203 } 1144 1204 } … … 1976 2036 sendDistributionAttributes(); 1977 2037 sendIndex(); 1978 sendMask();2038 // sendMask(); 1979 2039 sendLonLat(); 1980 2040 sendArea(); … … 2447 2507 { 2448 2508 iIndex = (index%ni_glo)-ibegin; 2449 iIndex = (iIndex < 0) ? 0 : iIndex; // ??2509 iIndex = (iIndex < 0) ? 0 : iIndex; 2450 2510 jIndex = (index/ni_glo)-jbegin; 2451 jIndex = (jIndex < 0) ? 0 : jIndex; // ??2511 jIndex = (jIndex < 0) ? 0 : jIndex; 2452 2512 nbIndLoc = iIndex + ni * jIndex; 2453 if (nbIndLoc < nbIndexGlobMax) 2513 // if (nbIndLoc < nbIndexGlobMax) // THIS CONDITION IMPEDES THE CASE OF A HOLE 2454 2514 { 2455 2515 i_index(nbIndLoc) = index % ni_glo; … … 2476 2536 j_index.resizeAndPreserve(nbIndGlob); 2477 2537 } 2538 2539 domainMask.resize(0); // Mask is not defined anymore on servers 2478 2540 } 2479 2541 … … 2896 2958 buffer >> recvDataJIndex[i]; 2897 2959 } 2898 2960 2899 2961 int nbIndex = i_index.numElements(); 2900 2962 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 2901 2963 dataIIndex = -1; dataJIndex = -1; 2902 2964 2903 2965 nbIndex = 0; 2904 2966 for (i = 0; i < nbReceived; ++i) … … 2918 2980 dataJIndex(lInd) = (-1 == dataJIndex(lInd)) ? tmpJ(ind) : dataJIndex(lInd); 2919 2981 2920 if (!domainMask(lInd)) // Include mask info into data index on the RECEIVE getServerDimensionSizes2921 {2922 dataIIndex(lInd) = dataJIndex(lInd) = -1;2923 }2982 // if (!domainMask(lInd)) // Include mask info into data index on the RECEIVE getServerDimensionSizes 2983 // { 2984 // dataIIndex(lInd) = dataJIndex(lInd) = -1; 2985 // } 2924 2986 } 2925 2987 } -
XIOS/dev/dev_olga/src/node/grid.cpp
r1568 r1570 693 693 CContext* context = CContext::getCurrent(); 694 694 695 CContextClient* client = context->client; // Here it's not important which contextClient to recuperate695 CContextClient* client = context->client; 696 696 int rank = client->clientRank; 697 697 … … 699 699 // Get local data index on client 700 700 int nbStoreIndex = clientDistribution_->getLocalDataIndexOnClient().size(); 701 int nbStoreGridMask = clientDistribution_->getLocalMaskIndexOnClient().size(); 702 // nbStoreGridMask = nbStoreIndex if grid mask is defined, and 0 otherwise 701 703 storeIndex_client.resize(nbStoreIndex); 702 storeMask_client.resize(nbStoreIndex); 703 for (int idx = 0; idx < nbStoreIndex; ++idx) 704 { 705 storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 706 storeMask_client(idx) = (clientDistribution_->getLocalMaskIndexOnClient())[idx]; 707 } 704 storeMask_client.resize(nbStoreGridMask); 705 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndex_client(idx) = (clientDistribution_->getLocalDataIndexOnClient())[idx]; 706 for (int idx = 0; idx < nbStoreGridMask; ++idx) storeMask_client(idx) = (clientDistribution_->getLocalMaskIndexOnClient())[idx]; 708 707 709 708 if (0 == serverDistribution_) isDataDistributed_= clientDistribution_->isDataDistributed(); … … 1302 1301 const StdSize size = storeIndex_client.numElements(); 1303 1302 stored.resize(size); 1304 1305 1303 const double nanValue = std::numeric_limits<double>::quiet_NaN(); 1306 for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue; 1304 1305 if (storeMask_client.numElements() != 0) 1306 for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client(i)) ? data[storeIndex_client(i)] : nanValue; 1307 else 1308 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 1307 1309 } 1308 1310
Note: See TracChangeset
for help on using the changeset viewer.