Changeset 1637 for XIOS/trunk/src/distribution_client.cpp
- Timestamp:
- 01/14/19 13:33:48 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/distribution_client.cpp
r1593 r1637 15 15 , axisDomainOrder_() 16 16 , nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_() 17 , dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_() , domainMasks_(), axisMasks_()17 , dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_() 18 18 , gridMask_(), indexMap_() 19 19 , isDataDistributed_(true), axisNum_(0), domainNum_(0) … … 36 36 GlobalLocalMap void2 ; 37 37 std::vector<int> void3 ; 38 std::vector< int> void4 ;38 std::vector<bool> void4 ; 39 39 40 40 globalLocalDataSendToServerMap_.swap(void1) ; … … 61 61 // Then check mask of grid 62 62 int gridDim = domList.size() * 2 + axisList.size(); 63 grid->checkMask();64 63 switch (gridDim) { 65 64 case 0: … … 117 116 axisDomainOrder_ = axisDomainOrder; 118 117 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 }133 134 118 // Because domain and axis can be in any order (axis1, domain1, axis2, axis3, ) 135 119 // their position should be specified. In axisDomainOrder, domain == true, axis == false … … 282 266 283 267 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]]))) 268 (jIdx >= nBeginLocal_[indexMap_[i]+1]) && (jIdx < nLocal_[indexMap_[i]+1])) 286 269 { 287 270 ++count; … … 325 308 elementIndexData_[i].resize(dataNIndex_[i]); 326 309 elementIndexData_[i] = false; 327 int iIdx = 0, count = 0 , localIndex = 0;310 int iIdx = 0, count = 0; 328 311 for (int j = 0; j < dataNIndex_[i]; ++j) 329 312 { 330 313 iIdx = getAxisIndex((dataIndex_[indexMap_[i]])(j), dataBegin_[indexMap_[i]], nLocal_[indexMap_[i]]); 331 314 if ((iIdx >= nBeginLocal_[indexMap_[i]]) && 332 (iIdx < nLocal_[indexMap_[i]]) && (axisMasks_[idxAxis](iIdx)))315 (iIdx < nLocal_[indexMap_[i]]) )//&& (axisMasks_[idxAxis](iIdx))) 333 316 { 334 317 ++count; … … 413 396 414 397 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 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 // If defined, iterate on grid mask 441 if (!gridMask_.isEmpty()) 442 { 443 for (int k = 0; k < this->numElement_; ++k) 444 { 445 gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 446 } 447 if (gridMask_(gridMaskIndex)) ++indexLocalDataOnClientCount; 448 } 449 // If grid mask is not defined, iterate on elements' mask 450 else 451 { 452 bool maskTmp = true; 453 int idxDomain = 0, idxAxis = 0; 454 for (int elem = 0; elem < numElement_; ++elem) 455 { 456 if (2 == axisDomainOrder_(elem)) 457 { 458 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 459 ++idxDomain; 460 } 461 else if (1 == axisDomainOrder_(elem)) 462 { 463 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 464 ++idxAxis; 465 } 466 } 467 if (maskTmp) ++indexLocalDataOnClientCount; 468 } 469 470 } 471 idxLoop[0] += innerLoopSize; 472 idx += innerLoopSize; 473 } 474 475 // Now allocate these arrays 476 localDataIndex_.resize(indexLocalDataOnClientCount); 477 localMaskIndex_.resize(indexLocalDataOnClientCount); 478 localMaskedDataIndex_.resize(indexLocalDataOnClientCount); 479 globalDataIndex_.rehash(std::ceil(indexLocalDataOnClientCount/globalDataIndex_.max_load_factor())); 480 globalLocalDataSendToServerMap_.rehash(std::ceil(indexLocalDataOnClientCount/globalLocalDataSendToServerMap_.max_load_factor())); 398 399 localDataIndex_.resize(ssize); 400 if (!gridMask_.isEmpty()) localMaskIndex_.resize(ssize); 401 localMaskedDataIndex_.resize(ssize); 402 globalDataIndex_.rehash(std::ceil(ssize/globalDataIndex_.max_load_factor())); 403 globalLocalDataSendToServerMap_.rehash(std::ceil(ssize/globalLocalDataSendToServerMap_.max_load_factor())); 404 481 405 482 406 // We need to loop with data index … … 535 459 if (isCurrentIndexDataCorrect) 536 460 { 537 int gridMaskIndex = 0; 538 for (int k = 0; k < this->numElement_; ++k) 461 bool maskTmp = true; 462 bool maskGridTmp = true; 463 size_t globalIndex = 0; 464 for (int k = 0; k < numElement_; ++k) 539 465 { 540 g ridMaskIndex += (currentIndex[k])*elementNLocal_[k];466 globalIndex += (currentGlobalIndex[k])*elementNGlobal_[k]; 541 467 } 542 543 bool maskTmp = true; 544 // If defined, apply grid mask 545 if (!gridMask_.isEmpty()) 468 globalDataIndex_[globalIndex] = indexLocalDataOnClientCount; 469 localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 470 globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount; 471 localMaskedDataIndex_[indexLocalDataOnClientCount] = indexLocalDataOnClientCount; 472 473 // Grid mask: unmasked values will be replaces by NaN and then all values will be sent 474 if (!gridMask_.isEmpty()) 546 475 { 547 maskTmp = gridMask_(gridMaskIndex); 476 int gridMaskIndex = 0; 477 for (int k = 0; k < this->numElement_; ++k) 478 { 479 gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 480 } 481 maskGridTmp = gridMask_(gridMaskIndex); 482 if (maskGridTmp) 483 localMaskIndex_[indexLocalDataOnClientCount] = true; 484 else 485 localMaskIndex_[indexLocalDataOnClientCount] = false; 548 486 } 549 // If grid mask is not defined, apply elements' mask 550 else 551 { 552 int idxDomain = 0, idxAxis = 0; 553 for (int elem = 0; elem < numElement_; ++elem) 554 { 555 if (2 == axisDomainOrder_(elem)) 556 { 557 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 558 ++idxDomain; 559 } 560 else if (1 == axisDomainOrder_(elem)) 561 { 562 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 563 ++idxAxis; 564 } 565 } 566 } 567 568 if (maskTmp) 569 { 570 size_t globalIndex = 0; 571 for (int k = 0; k < numElement_; ++k) 572 { 573 globalIndex += (currentGlobalIndex[k])*elementNGlobal_[k]; 574 } 575 globalDataIndex_[globalIndex] = indexLocalDataOnClientCount; 576 localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 577 globalLocalDataSendToServerMap_[globalIndex] = indexLocalDataOnClientCount; 578 localMaskIndex_[indexLocalDataOnClientCount] = gridMaskIndex; 579 localMaskedDataIndex_[indexLocalDataOnClientCount] = indexLocalDataOnClientCount; 580 ++indexLocalDataOnClientCount; 581 } 487 488 ++indexLocalDataOnClientCount; 489 582 490 } 583 491 ++countLocalData; … … 586 494 } 587 495 else countLocalData+=innerLoopSize ; 588 496 589 497 idxLoop[0] += innerLoopSize; 590 498 idx += innerLoopSize; … … 614 522 const int& dataDim, const int& ni, int& j) 615 523 { 524 int i; 616 525 int tempI = dataIIndex + dataIBegin, 617 526 tempJ = (dataJIndex + dataJBegin); 618 527 if (ni == 0) 619 528 { 620 i nt i = 0;621 j = 0;529 i = -1; 530 j = -1; 622 531 return i; 623 532 } 624 int i = (dataDim == 1) ? (tempI) % ni 625 : (tempI) ; 626 j = (dataDim == 1) ? (tempI) / ni 627 : (tempJ) ; 628 533 if ((tempI < 0) || (tempJ < 0)) 534 { 535 i = -1; 536 j = -1; 537 return i; 538 } 539 else 540 { 541 i = (dataDim == 1) ? (tempI) % ni : (tempI) ; 542 j = (dataDim == 1) ? (tempI) / ni : (tempJ) ; 543 } 629 544 return i; 630 545 } … … 643 558 return -1; 644 559 } 645 int tempI = dataIndex + dataBegin;560 int tempI = dataIndex; 646 561 if ((tempI < 0) || (tempI > ni)) 647 562 return -1; … … 677 592 Return local mask index of client 678 593 */ 679 const std::vector< int>& CDistributionClient::getLocalMaskIndexOnClient()594 const std::vector<bool>& CDistributionClient::getLocalMaskIndexOnClient() 680 595 { 681 596 if (!isComputed_) createGlobalIndexSendToServer();
Note: See TracChangeset
for help on using the changeset viewer.