Changeset 1966
- Timestamp:
- 10/28/20 16:24:06 (4 years ago)
- Location:
- XIOS/dev/dev_oa/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_oa/src/filter/source_filter.cpp
r1963 r1966 20 20 , hasMissingValue(hasMissingValue), defaultValue(defaultValue) 21 21 , ntiles(0) 22 , storedTileData() 22 23 { 23 24 if (!grid) … … 55 56 56 57 template <int N> 57 void CSourceFilter::streamTile(CDate date, const CArray<double, N>& data, int ntile)58 void CSourceFilter::streamTile(CDate date, const CArray<double, N>& tileData, int tileId) 58 59 { 59 // TO DO 60 if (ntiles==0) 61 { 62 const double nanValue = std::numeric_limits<double>::quiet_NaN(); 63 storedTileData.resize(grid->storeIndex_client.numElements()); 64 storedTileData = nanValue; 65 } 66 grid->copyTile(tileData, storedTileData, tileId); 67 ++ntiles; 68 if (ntiles==grid->getNTiles()) 69 { 70 // Data entering workflow will be exactly of size ni*nj for a grid 2d or ni*nj*n for a grid 3d 71 streamData(date, storedTileData); 72 } 60 73 } 61 62 74 63 75 template <int N> -
XIOS/dev/dev_oa/src/filter/source_filter.hpp
r1963 r1966 79 79 const bool mask ; //!< indicates whether grid mask should be applied (true for clients, false for servers) 80 80 int ntiles ; 81 CArray<double, 1> storedTileData; 81 82 }; // class CSourceFilter 82 83 } // namespace xios -
XIOS/dev/dev_oa/src/node/domain.cpp
r1852 r1966 35 35 , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 36 36 , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 37 , isTiled_(false) 37 38 { 38 39 } … … 48 49 , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 49 50 , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 51 , isTiled_(false) 50 52 { 51 53 } … … 246 248 { 247 249 return isCompressible_; 250 } 251 CATCH 252 253 bool CDomain::isTiled(void) const 254 TRY 255 { 256 return isTiled_; 257 } 258 CATCH 259 260 int CDomain::getTileId(int i, int j) const 261 TRY 262 { 263 int tileId = 0; 264 bool stop = false; 265 while (!stop) 266 { 267 if ((i >= tile_ibegin(tileId) ) && (i < tile_ni(tileId)+tile_ibegin(tileId) ) 268 && (j >= tile_jbegin(tileId) ) && (j < tile_nj(tileId)+tile_jbegin(tileId) ) ) 269 stop = true; 270 ++tileId; 271 } 272 return (tileId - 1); 248 273 } 249 274 CATCH … … 1723 1748 CATCH_DUMP_ATTR 1724 1749 1750 //---------------------------------------------------------------- 1751 void CDomain::checkTiles() 1752 TRY 1753 { 1754 if (!ntiles.isEmpty() && ntiles.getValue() >1) isTiled_ = true; 1755 if (isTiled_) 1756 { 1757 1758 // Attributes tile_ni/nj and tile_i/jbegin are mandatory for tiled domains 1759 if (tile_ni.numElements() != ntiles || tile_ibegin.numElements() != ntiles) 1760 ERROR("CDomain::checkTiles()", 1761 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1762 << "'tile_ni' or 'tile_ibegin' are ill defined: these attributes must be specified for tiled domains and be of the size 'ntiles'." << std::endl 1763 << "The number of tiles is " << ntiles.getValue() << " while the size of 'tile_ni' is " << tile_ni.numElements() 1764 << " and the size of 'tile_ibegin' is " << tile_ibegin.numElements() << "."); 1765 1766 if (tile_nj.numElements() != ntiles || tile_jbegin.numElements() != ntiles) 1767 ERROR("CDomain::checkTiles()", 1768 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1769 << "'tile_nj' or 'tile_jbegin' are ill defined: these attributes must be specified for tiled domains and be of the size 'ntiles'." << std::endl 1770 << "The number of tiles is " << ntiles.getValue() << " while the size of 'tile_nj' is " << tile_nj.numElements() 1771 << " and the size of 'tile_jbegin' is " << tile_jbegin.numElements() << "."); 1772 1773 // Check on consistency of individual tile sizes and local domain size 1774 int sizeTiles = 0; 1775 for (int iTile = 0; iTile < ntiles.getValue(); ++iTile) 1776 { 1777 sizeTiles += tile_ni(iTile) * tile_nj(iTile); 1778 } 1779 if (sizeTiles != (ni*nj)) 1780 ERROR("CDomain::checkTiles()", 1781 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1782 << "tiles should cover the entire local domain and cannot overlap." << std::endl << "."); 1783 1784 1785 // Fill in tile_data_ni/nj and tile_data_i/jbegin if they are not specified 1786 if (tile_data_ni.numElements() == 0 || tile_data_nj.numElements() == 0) 1787 { 1788 tile_data_ni.resize(ntiles); 1789 tile_data_nj.resize(ntiles); 1790 for (int iTile = 0; iTile < ntiles.getValue(); ++iTile) 1791 { 1792 tile_data_ni(iTile) = tile_ni(iTile); 1793 tile_data_nj(iTile) = tile_nj(iTile); 1794 } 1795 } 1796 1797 if (tile_data_ibegin.numElements() == 0 || tile_data_jbegin.numElements() == 0) 1798 { 1799 tile_data_ibegin.resize(ntiles); 1800 tile_data_jbegin.resize(ntiles); 1801 tile_data_ibegin = 0; 1802 tile_data_jbegin = 0; 1803 } 1804 1805 } // isTiled_ 1806 } 1807 CATCH_DUMP_ATTR 1808 1809 //---------------------------------------------------------------- 1810 int CDomain::getTileDataISize(int tileId) const 1811 TRY 1812 { 1813 int retvalue = (tile_data_ni(tileId) > tile_ni(tileId)) ? tile_data_ni(tileId) : tile_ni(tileId); 1814 return retvalue; 1815 } 1816 CATCH_DUMP_ATTR 1817 1818 //---------------------------------------------------------------- 1819 int CDomain::getTileDataJSize(int tileId) const 1820 TRY 1821 { 1822 int retvalue = (tile_data_nj(tileId) > tile_nj(tileId)) ? tile_data_nj(tileId) : tile_nj(tileId); 1823 return retvalue; 1824 } 1825 CATCH_DUMP_ATTR 1826 1725 1827 void CDomain::checkAttributesOnClientAfterTransformation() 1726 1828 TRY … … 1756 1858 this->checkArea(); 1757 1859 this->checkLonLat(); 1860 this->checkTiles(); 1758 1861 } 1759 1862 -
XIOS/dev/dev_oa/src/node/domain.hpp
r1639 r1966 104 104 bool isDistributed(void) const; 105 105 bool isCompressible(void) const; 106 106 107 bool isTiled(void) const; 108 int getTileId(int i, int j) const; 109 int getTileDataISize(int tileId) const; 110 int getTileDataJSize(int tileId) const; 111 107 112 std::vector<int> getNbGlob(); 108 113 bool isEqual(CDomain* domain); … … 169 174 void checkArea(void); 170 175 void checkLonLat(); 176 void checkTiles(); 171 177 172 178 void setTransformations(const TransMapTypes&); … … 228 234 bool isUnstructed_; 229 235 std::unordered_map<size_t,size_t> globalLocalIndexMap_; 230 236 237 bool isTiled_; 238 231 239 private: 232 240 static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); -
XIOS/dev/dev_oa/src/node/grid.cpp
r1927 r1966 33 33 , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 34 34 , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 35 35 , isDataDistributed_(true), isCompressible_(false) 36 36 , transformations_(0), isTransformed_(false) 37 37 , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) … … 39 39 , computedWrittenIndex_(false) 40 40 , clients() 41 , nTiles_(0) 42 , isTiled_(false) 43 , storeTileIndex() 41 44 { 42 45 setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group")); … … 54 57 , writtenDataSize_(0), numberWrittenIndexes_(0), totalNumberWrittenIndexes_(0), offsetWrittenIndexes_(0) 55 58 , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() 56 59 , isDataDistributed_(true), isCompressible_(false) 57 60 , transformations_(0), isTransformed_(false) 58 61 , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) … … 60 63 , computedWrittenIndex_(false) 61 64 , clients() 65 , nTiles_(0) 66 , isTiled_(false) 67 , storeTileIndex() 62 68 { 63 69 setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group")); … … 102 108 } 103 109 CATCH 110 111 //--------------------------------------------------------------- 112 /*! 113 * Returns size of tile data 114 */ 115 116 StdSize CGrid::getTileDataSize(int tileId) 117 TRY 118 { 119 StdSize tileGridSize =1 ; 120 int numElement = axis_domain_order.numElements(); 121 122 std::vector<CAxis*> axisListP = this->getAxis(); 123 std::vector<CDomain*> domainListP = this->getDomains(); 124 125 int axisIndex = 0, domIndex = 0; 126 for (int idx = 0; idx < numElement; ++idx) 127 { 128 int eleDim = axis_domain_order(idx); 129 if (2 == eleDim) 130 { 131 tileGridSize *= domainListP[domIndex]->tile_data_ni(tileId); 132 tileGridSize *= domainListP[domIndex]->tile_data_nj(tileId); 133 ++domIndex; 134 } 135 else if (1 == eleDim) 136 { 137 tileGridSize *= axisListP[axisIndex]->n.getValue(); 138 ++axisIndex; 139 } 140 } // loop over grid elements 141 return tileGridSize; 142 } 143 CATCH 144 145 //--------------------------------------------------------------- 146 /*! 147 * Returns tile size 148 */ 149 150 StdSize CGrid::getTileSize(int tileId) 151 TRY 152 { 153 StdSize tileGridSize =1 ; 154 int numElement = axis_domain_order.numElements(); 155 156 std::vector<CAxis*> axisListP = this->getAxis(); 157 std::vector<CDomain*> domainListP = this->getDomains(); 158 159 int axisIndex = 0, domIndex = 0; 160 for (int idx = 0; idx < numElement; ++idx) 161 { 162 int eleDim = axis_domain_order(idx); 163 if (2 == eleDim) 164 { 165 tileGridSize *= domainListP[domIndex]->tile_ni(tileId); 166 tileGridSize *= domainListP[domIndex]->tile_nj(tileId); 167 ++domIndex; 168 } 169 else if (1 == eleDim)// So it's an axis 170 { 171 tileGridSize *= axisListP[axisIndex]->n.getValue(); 172 ++axisIndex; 173 } 174 } // loop over grid elements 175 return tileGridSize; 176 } 177 CATCH 178 179 //--------------------------------------------------------------- 104 180 105 181 /*! … … 561 637 if (sendAtt) domListP[i]->sendCheckedAttributes(); 562 638 else domListP[i]->checkAttributesOnClient(); 639 if (domListP[i]->isTiled()) this->isTiled_ = true; 563 640 } 564 641 } … … 902 979 { 903 980 computeClientIndex(); 981 if (this->isTiled_) computeTileIndex(); 904 982 if (context->hasClient) 905 983 { … … 1097 1175 } 1098 1176 CATCH_DUMP_ATTR 1177 1178 //--------------------------------------------------------------- 1179 1180 /* 1181 */ 1182 void CGrid::computeTileIndex() 1183 TRY 1184 { 1185 int numElement = axis_domain_order.numElements(); 1186 storeTileIndex.resize(nTiles_); 1187 1188 std::vector<CAxis*> axisListP = this->getAxis(); 1189 std::vector<CDomain*> domainListP = this->getDomains(); 1190 1191 // First, allocate storeTileIndex[0..ntiles] 1192 for (int iTile = 0; iTile < nTiles_; ++iTile) 1193 { 1194 int tileGridSize = 1; 1195 int axisIndex = 0, domIndex = 0; 1196 for (int idx = 0; idx < numElement; ++idx) 1197 { 1198 int eleDim = axis_domain_order(idx); 1199 if (2 == eleDim) 1200 { 1201 tileGridSize *= domainListP[domIndex]->getTileDataISize(iTile); 1202 tileGridSize *= domainListP[domIndex]->getTileDataJSize(iTile); 1203 ++domIndex; 1204 } 1205 else if (1 == eleDim)// So it's an axis 1206 { 1207 tileGridSize *= axisListP[axisIndex]->n.getValue(); 1208 ++axisIndex; 1209 } 1210 } // loop over grid elements 1211 storeTileIndex[iTile].resize(tileGridSize); 1212 storeTileIndex[iTile] = -1; 1213 } // loop over tiles 1214 1215 // Now fill in storeTileIndex 1216 // Currently assuming two possible situations : (1) domain x axis or (2) domain 1217 std::vector<int> tileIndexCount (nTiles_,0); 1218 int axisSize = 1; 1219 if (axisListP.size() != 0) axisSize = axisListP[0]->n.getValue(); 1220 int ni = domainListP[0]->ni.getValue(); 1221 int nj = domainListP[0]->nj.getValue(); 1222 1223 for (int idxAxis = 0; idxAxis < axisSize; ++idxAxis) 1224 { 1225 for (int jIdxDom = 0; jIdxDom < nj; ++jIdxDom) 1226 { 1227 for (int iIdxDom = 0; iIdxDom < ni; ++iIdxDom) 1228 { 1229 int tile = domainListP[0]->getTileId(iIdxDom, jIdxDom); 1230 int tileOffset = domainListP[0]->tile_data_ibegin(tile); // only sign of offset matters 1231 1232 // case 1: data size corresponds to tile size 1233 if (tileOffset == 0) 1234 { 1235 storeTileIndex[tile](tileIndexCount[tile]) = idxAxis*nj*ni + jIdxDom * ni + iIdxDom; 1236 ++tileIndexCount[tile]; 1237 } 1238 // case 2: masked data 1239 else if (tileOffset > 0) 1240 { 1241 int iBegin = domainListP[0]->tile_ibegin(tile) + domainListP[0]->tile_data_ibegin(tile); // tile data relative to domain 1242 int jBegin = domainListP[0]->tile_jbegin(tile) + domainListP[0]->tile_data_jbegin(tile); // tile data relative to domain 1243 int iEnd = iBegin + domainListP[0]->tile_data_ni(tile); 1244 int jEnd = jBegin + domainListP[0]->tile_data_nj(tile); 1245 if ((jIdxDom >= jBegin) && (jIdxDom < jEnd) && (iIdxDom >= iBegin) && (iIdxDom < iEnd)) 1246 { 1247 storeTileIndex[tile](tileIndexCount[tile]) = idxAxis*nj*ni + jIdxDom * ni + iIdxDom; 1248 } 1249 ++tileIndexCount[tile]; 1250 } 1251 // case 3: ghost zones 1252 else 1253 { 1254 int tileDataNi = domainListP[0]->tile_data_ni(tile); 1255 int tileDataNj = domainListP[0]->tile_data_nj(tile); 1256 int tileDomSize = tileDataNi * tileDataNj; 1257 int tileNi = domainListP[0]->tile_ni(tile); 1258 int iBegin = domainListP[0]->tile_data_ibegin(tile); 1259 int jBegin = domainListP[0]->tile_data_jbegin(tile); 1260 1261 // add the ghost zone at the beginning of a domain tile 1262 if (tileIndexCount[tile] % tileDomSize == 0) 1263 tileIndexCount[tile] += (abs(jBegin)*tileDataNi + abs(iBegin)); 1264 1265 storeTileIndex[tile](tileIndexCount[tile]) = idxAxis*nj*ni + jIdxDom*ni + iIdxDom; 1266 1267 // add two ghost zones at the right end of a tile 1268 if ( (iIdxDom+1) % tileNi == 0 ) 1269 tileIndexCount[tile] += (2*abs(iBegin)); 1270 1271 // add ghost zone at the end of a domain tile 1272 if ((tileIndexCount[tile] + abs(jBegin)*tileDataNi-abs(iBegin) + 1) % tileDomSize == 0) 1273 tileIndexCount[tile] += (abs(jBegin)*tileDataNi -abs(iBegin)); 1274 1275 ++tileIndexCount[tile]; 1276 } 1277 } // loop over domain first dimension 1278 } // loop over domain second dimension 1279 } // loop over axis dimension 1280 1281 } 1282 CATCH_DUMP_ATTR 1283 1099 1284 //---------------------------------------------------------------- 1100 1285 … … 1359 1544 1360 1545 void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) const 1546 TRY 1361 1547 { 1362 1548 const StdSize size = storeIndex_client.numElements(); … … 1369 1555 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 1370 1556 } 1557 CATCH 1558 1559 void CGrid::copyTile_arr(const double* const tileData, CArray<double, 1>& stored, int tileId) 1560 TRY 1561 { 1562 StdSize tileSize = this->getTileSize(tileId); 1563 const StdSize tileDataSize = this->getTileDataSize(tileId); 1564 1565 // case 1: data correspond in size to a tile 1566 if (tileSize == tileDataSize) 1567 { 1568 for(StdSize i = 0; i < tileDataSize; i++) 1569 stored(storeTileIndex[tileId](i)) = tileData[i]; 1570 } 1571 // case 2: masked data 1572 else if (tileSize > tileDataSize) 1573 { 1574 int tileDataCount = 0; 1575 for(StdSize i = 0; i < tileSize; i++) 1576 if (storeTileIndex[tileId](i) >= 0) 1577 { 1578 stored(storeTileIndex[tileId](i)) = tileData[tileDataCount]; 1579 ++tileDataCount; 1580 } 1581 } 1582 // case 3: ghost zones 1583 else 1584 { 1585 for(StdSize i = 0; i < tileDataSize; i++) 1586 if (storeTileIndex[tileId](i) >= 0) 1587 { 1588 stored(storeTileIndex[tileId](i)) = tileData[i]; 1589 } 1590 1591 } 1592 } 1593 CATCH 1371 1594 1372 1595 void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const … … 2253 2476 pDom->solveRefInheritance(apply); 2254 2477 pDom->solveInheritanceTransformation(); 2478 if (!pDom->ntiles.isEmpty() && pDom->ntiles.getValue()>0) nTiles_=pDom->ntiles.getValue(); 2255 2479 } 2256 2480 } … … 2279 2503 } 2280 2504 } 2505 } 2506 CATCH_DUMP_ATTR 2507 2508 int CGrid::getNTiles() 2509 TRY 2510 { 2511 return nTiles_; 2281 2512 } 2282 2513 CATCH_DUMP_ATTR -
XIOS/dev/dev_oa/src/node/grid.hpp
r1927 r1966 91 91 StdSize getDataSize(void) const; 92 92 93 StdSize getTileDataSize(int tileId); 94 95 StdSize getTileSize(int tileId); 96 93 97 /// Entrees-sorties de champs 94 98 template <int n> … … 100 104 template <int n> 101 105 void uncompressField(const CArray<double,n>& data, CArray<double,1>& outData) const; 106 template <int n> 107 void copyTile(const CArray<double,n>& tileData, CArray<double, 1>& stored, int tileId); 102 108 103 109 virtual void parse(xml::CXMLNode& node); … … 256 262 const CArray<int,1>& axisDomainOrder); 257 263 264 int getNTiles(); 265 258 266 private: 259 267 template<int N> … … 273 281 void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const; 274 282 void maskField_arr(const double* const data, CArray<double, 1>& stored) const; 283 void copyTile_arr(const double* const tileData, CArray<double, 1>& stored, int tileId); 275 284 276 285 void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); … … 303 312 void computeConnectedClientsScalarGrid(); 304 313 314 void computeTileIndex(); 315 305 316 private: 306 317 … … 312 323 bool isDomainAxisChecked; 313 324 bool isIndexSent; 325 326 int nTiles_; 327 bool isTiled_; 328 /** Vector containing local domain indexes for each tile */ 329 std::vector<CArray<int,1> > storeTileIndex; 314 330 315 331 CDomainGroup* vDomainGroup_; … … 387 403 388 404 template <int n> 405 void CGrid::copyTile(const CArray<double,n>& tileData, CArray<double,1>& storedData, int tileId) 406 { 407 this->copyTile_arr(tileData.dataFirst(), storedData, tileId); 408 } 409 410 template <int n> 389 411 void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const 390 412 { 391 413 //#ifdef __XIOS_DEBUG 392 414 if (this->getDataSize() != field.numElements()) 393 ERROR("void CGrid:: inputField(const CArray<double,n>& field, CArray<double,1>& stored) const",415 ERROR("void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const", 394 416 << "[ Awaiting data of size = " << this->getDataSize() << ", " 395 417 << "Received data size = " << field.numElements() << " ] "
Note: See TracChangeset
for help on using the changeset viewer.