Changeset 2131 for XIOS/trunk/src/node
- Timestamp:
- 04/23/21 15:00:35 (3 years ago)
- Location:
- XIOS/trunk/src/node
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/domain.cpp
r1972 r2131 35 35 , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 36 36 , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 37 , isTiled_(false), isTiledOnly_(false) 37 38 { 38 39 } … … 48 49 , clients(), hasLatInReadFile_(false), hasBoundsLatInReadFile_(false) 49 50 , hasLonInReadFile_(false), hasBoundsLonInReadFile_(false) 51 , isTiled_(false), isTiledOnly_(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 bool CDomain::isTiledOnly(void) const 261 TRY 262 { 263 return isTiledOnly_; 264 } 265 CATCH 266 267 int CDomain::getTileId(int i, int j) const 268 TRY 269 { 270 int tileId = 0; 271 bool stop = false; 272 while (!stop) 273 { 274 if ((i >= tile_ibegin(tileId) ) && (i < tile_ni(tileId)+tile_ibegin(tileId) ) 275 && (j >= tile_jbegin(tileId) ) && (j < tile_nj(tileId)+tile_jbegin(tileId) ) ) 276 stop = true; 277 ++tileId; 278 } 279 return (tileId - 1); 248 280 } 249 281 CATCH … … 1260 1292 } 1261 1293 } 1294 } 1295 CATCH_DUMP_ATTR 1296 1297 //---------------------------------------------------------------- 1298 1299 /*! 1300 * For tiled domains, data_i/j_index should not take into 1301 * account parameters defining data (data_ni/nj, data_i/jbegin...) 1302 * \param [out] dataIndexI 1303 * \param [out] dataIndexJ 1304 * \param [out] infoIndexI 1305 * \param [out] infoIndexJ 1306 */ 1307 1308 void CDomain::computeCompressionTiled(CArray<int,1>& dataIndexI, CArray<int,1>& dataIndexJ, 1309 CArray<int,1>& infoIndexI, CArray<int,1>& infoIndexJ) 1310 TRY 1311 { 1312 const int dsize = ni * nj; 1313 dataIndexI.resize(dsize); 1314 dataIndexJ.resize(dsize); 1315 1316 dataIndexJ = 0; 1317 for (int k = 0; k < ni * nj; ++k) 1318 dataIndexI(k) = k; 1319 1320 infoIndexI.resize(ni*nj); 1321 for (int j = 0; j < nj; ++j) 1322 for (int i = 0; i < ni; ++i) infoIndexI(i+j*ni) = i+ibegin; 1323 1324 infoIndexJ.resize(ni*nj); 1325 for (int j = 0; j < nj; ++j) 1326 for (int i = 0; i < ni; ++i) infoIndexJ(i+j*ni) = j+jbegin; 1262 1327 } 1263 1328 CATCH_DUMP_ATTR … … 1723 1788 CATCH_DUMP_ATTR 1724 1789 1790 //---------------------------------------------------------------- 1791 void CDomain::checkTiles() 1792 TRY 1793 { 1794 if (!ntiles.isEmpty() && ntiles.getValue() >=1) isTiled_ = true; 1795 if (!tile_only.isEmpty() && tile_only.getValue() == true) { 1796 isTiled_ = true; 1797 isTiledOnly_ = true; 1798 } 1799 1800 if (isTiled_) 1801 { 1802 1803 // Attributes tile_ni/nj and tile_i/jbegin are mandatory for tiled domains 1804 if (tile_ni.numElements() != ntiles || tile_ibegin.numElements() != ntiles) 1805 ERROR("CDomain::checkTiles()", 1806 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1807 << "'tile_ni' or 'tile_ibegin' are ill defined: these attributes must be specified for tiled domains and be of the size 'ntiles'." << std::endl 1808 << "The number of tiles is " << ntiles.getValue() << " while the size of 'tile_ni' is " << tile_ni.numElements() 1809 << " and the size of 'tile_ibegin' is " << tile_ibegin.numElements() << "."); 1810 1811 if (tile_nj.numElements() != ntiles || tile_jbegin.numElements() != ntiles) 1812 ERROR("CDomain::checkTiles()", 1813 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1814 << "'tile_nj' or 'tile_jbegin' are ill defined: these attributes must be specified for tiled domains and be of the size 'ntiles'." << std::endl 1815 << "The number of tiles is " << ntiles.getValue() << " while the size of 'tile_nj' is " << tile_nj.numElements() 1816 << " and the size of 'tile_jbegin' is " << tile_jbegin.numElements() << "."); 1817 1818 // Check on consistency of individual tile sizes and local domain size 1819 int sizeTiles = 0; 1820 for (int iTile = 0; iTile < ntiles.getValue(); ++iTile) 1821 { 1822 sizeTiles += tile_ni(iTile) * tile_nj(iTile); 1823 } 1824 if (sizeTiles != (ni*nj)) 1825 ERROR("CDomain::checkTiles()", 1826 << "[ id = " << this->getId() << " , context = '" << CObjectFactory::GetCurrentContextId() << " ] " 1827 << "tiles should cover the entire local domain and cannot overlap." << std::endl << "."); 1828 1829 1830 // Fill in tile_data_ni/nj and tile_data_i/jbegin if they are not specified 1831 if (tile_data_ni.numElements() == 0 || tile_data_nj.numElements() == 0) 1832 { 1833 tile_data_ni.resize(ntiles); 1834 tile_data_nj.resize(ntiles); 1835 for (int iTile = 0; iTile < ntiles.getValue(); ++iTile) 1836 { 1837 tile_data_ni(iTile) = tile_ni(iTile); 1838 tile_data_nj(iTile) = tile_nj(iTile); 1839 } 1840 } 1841 1842 if (tile_data_ibegin.numElements() == 0 || tile_data_jbegin.numElements() == 0) 1843 { 1844 tile_data_ibegin.resize(ntiles); 1845 tile_data_jbegin.resize(ntiles); 1846 tile_data_ibegin = 0; 1847 tile_data_jbegin = 0; 1848 } 1849 1850 } // isTiled_ 1851 } 1852 CATCH_DUMP_ATTR 1853 1854 //---------------------------------------------------------------- 1855 int CDomain::getTileDataISize(int tileId) const 1856 TRY 1857 { 1858 int retvalue = (tile_data_ni(tileId) > tile_ni(tileId)) ? tile_data_ni(tileId) : tile_ni(tileId); 1859 return retvalue; 1860 } 1861 CATCH_DUMP_ATTR 1862 1863 //---------------------------------------------------------------- 1864 int CDomain::getTileDataJSize(int tileId) const 1865 TRY 1866 { 1867 int retvalue = (tile_data_nj(tileId) > tile_nj(tileId)) ? tile_data_nj(tileId) : tile_nj(tileId); 1868 return retvalue; 1869 } 1870 CATCH_DUMP_ATTR 1871 1725 1872 void CDomain::checkAttributesOnClientAfterTransformation() 1726 1873 TRY … … 1756 1903 this->checkArea(); 1757 1904 this->checkLonLat(); 1905 this->checkTiles(); 1758 1906 } 1759 1907 -
XIOS/trunk/src/node/domain.hpp
r1972 r2131 104 104 bool isDistributed(void) const; 105 105 bool isCompressible(void) const; 106 106 107 bool isTiled(void) const; 108 bool isTiledOnly(void) const; 109 int getTileId(int i, int j) const; 110 int getTileDataISize(int tileId) const; 111 int getTileDataJSize(int tileId) const; 112 void computeCompressionTiled(CArray<int,1>& dataIndexI, CArray<int,1>& dataIndexJ, 113 CArray<int,1>& infoIndexI, CArray<int,1>& infoIndexJ); 114 107 115 std::vector<int> getNbGlob(); 108 116 bool isEqual(CDomain* domain); … … 170 178 void checkArea(void); 171 179 void checkLonLat(); 180 void checkTiles(); 172 181 173 182 void setTransformations(const TransMapTypes&); … … 223 232 std::map<int, std::vector<int> > connectedServerRank_; 224 233 225 234 //! True if and only if the data defined on the domain can be outputted in a compressed way 226 235 bool isCompressible_; 227 236 bool isRedistributed_; … … 229 238 bool isUnstructed_; 230 239 std::unordered_map<size_t,size_t> globalLocalIndexMap_; 231 240 241 //! True if tiled data is defined on the domain 242 bool isTiled_; 243 //! True if ONLY tiled data is defined on the domain 244 bool isTiledOnly_; 245 232 246 private: 233 247 static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); -
XIOS/trunk/src/node/field.cpp
r2024 r2131 2059 2059 { 2060 2060 //if(file->output_freq.getValue() < freq_op.getValue()) 2061 if((isFieldRead || isFieldWrite) && (f req_op.getValue() > file->output_freq.getValue()))2061 if((isFieldRead || isFieldWrite) && (file!=nullptr) && (freq_op.getValue() > file->output_freq.getValue() )) 2062 2062 { 2063 2063 ERROR("void CField::checkTimeAttributes(void)", -
XIOS/trunk/src/node/field.hpp
r1704 r2131 160 160 static ENodeType GetType(void); 161 161 162 template <int N> void setData(const CArray<double, N>& _data );162 template <int N> void setData(const CArray<double, N>& _data, int ntile = -1); 163 163 static bool dispatchEvent(CEventServer& event); 164 164 void sendAllAttributesToServer(CContextClient* client) ; -
XIOS/trunk/src/node/field_decl.cpp
r932 r2131 3 3 namespace xios 4 4 { 5 template void CField::setData<1>(const CArray<double, 1>& _data );6 template void CField::setData<2>(const CArray<double, 2>& _data );7 template void CField::setData<3>(const CArray<double, 3>& _data );8 template void CField::setData<4>(const CArray<double, 4>& _data );9 template void CField::setData<5>(const CArray<double, 5>& _data );10 template void CField::setData<6>(const CArray<double, 6>& _data );11 template void CField::setData<7>(const CArray<double, 7>& _data );5 template void CField::setData<1>(const CArray<double, 1>& _data, int ntile); 6 template void CField::setData<2>(const CArray<double, 2>& _data, int ntile); 7 template void CField::setData<3>(const CArray<double, 3>& _data, int ntile); 8 template void CField::setData<4>(const CArray<double, 4>& _data, int ntile); 9 template void CField::setData<5>(const CArray<double, 5>& _data, int ntile); 10 template void CField::setData<6>(const CArray<double, 6>& _data, int ntile); 11 template void CField::setData<7>(const CArray<double, 7>& _data, int ntile); 12 12 13 13 template void CField::getData<1>(CArray<double, 1>& _data) const; -
XIOS/trunk/src/node/field_impl.hpp
r1622 r2131 16 16 17 17 template <int N> 18 void CField::setData(const CArray<double, N>& _data )18 void CField::setData(const CArray<double, N>& _data, int tileid) 19 19 TRY 20 20 { … … 22 22 { 23 23 if (check_if_active.isEmpty() || (!check_if_active.isEmpty() && (!check_if_active) || isActive(true))) 24 clientSourceFilter->streamData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data); 24 if (tileid > -1) 25 clientSourceFilter->streamTile(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data, tileid); // tiled domain 26 else 27 clientSourceFilter->streamData(CContext::getCurrent()->getCalendar()->getCurrentDate(), _data); 25 28 } 26 29 else if (instantDataFilter) -
XIOS/trunk/src/node/grid.cpp
r1927 r2131 39 39 , computedWrittenIndex_(false) 40 40 , clients() 41 , nTiles_(0) 42 , isTiled_(false), isTiledOnly_(false) 43 , storeTileIndex() 41 44 { 42 45 setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group")); … … 60 63 , computedWrittenIndex_(false) 61 64 , clients() 65 , nTiles_(0) 66 , isTiled_(false), isTiledOnly_(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; 640 if (domListP[i]->isTiledOnly()) this->isTiledOnly_ = true; 563 641 } 564 642 } … … 725 803 outLocalIndexStoreOnClient.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 726 804 CArray<size_t,1>& localIndex = outLocalIndexStoreOnClient[rank]; 805 size_t nbIndex = 0; 806 807 // Keep this code for this moment but it should be removed (or moved to DEBUG) to improve performance 808 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 809 { 810 if (itGloe != globalDataIndex.find(globalIndex(idx))) 811 { 812 ++nbIndex; 813 } 814 } 815 816 if (doGridHaveDataDistributed(client) && (nbIndex != localIndex.numElements())) 817 ERROR("void CGrid::computeClientIndex()", 818 << "Number of local index on client is different from number of received global index" 819 << "Rank of sent client " << rank <<"." 820 << "Number of local index " << nbIndex << ". " 821 << "Number of received global index " << localIndex.numElements() << "."); 822 823 nbIndex = 0; 824 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 825 { 826 if (itGloe != globalDataIndex.find(globalIndex(idx))) 827 { 828 localIndex(idx) = globalDataIndex[globalIndex(idx)]; 829 } 830 } 831 } 832 } 833 } 834 CATCH_DUMP_ATTR 835 836 //--------------------------------------------------------------- 837 838 /* 839 Compute the global index and its local index taking account mask and data index. 840 These global indexes will be used to compute the connection of this client (sender) to its servers (receivers) 841 (via function computeConnectedClient) 842 These global indexes also correspond to data sent to servers (if any) 843 */ 844 void CGrid::computeClientIndexTiled() 845 TRY 846 { 847 CContext* context = CContext::getCurrent(); 848 849 CContextClient* client = context->client; 850 int rank = client->clientRank; 851 852 clientDistributionTiled_ = new CDistributionClient(rank, this, true); 853 // Get local data index on client 854 int nbStoreIndex = clientDistributionTiled_->getLocalDataIndexOnClient().size(); 855 int nbStoreGridMask = clientDistributionTiled_->getLocalMaskIndexOnClient().size(); 856 // nbStoreGridMask = nbStoreIndex if grid mask is defined, and 0 otherwise 857 storeIndexTiled_client.resize(nbStoreIndex); 858 storeMaskTiled_client.resize(nbStoreGridMask); 859 for (int idx = 0; idx < nbStoreIndex; ++idx) storeIndexTiled_client(idx) = (clientDistributionTiled_->getLocalDataIndexOnClient())[idx]; 860 for (int idx = 0; idx < nbStoreGridMask; ++idx) storeMaskTiled_client(idx) = (clientDistributionTiled_->getLocalMaskIndexOnClient())[idx]; 861 862 if (0 == serverDistribution_) isDataDistributed_= clientDistributionTiled_->isDataDistributed(); 863 else 864 { 865 // Mapping global index received from clients to the storeIndex_client 866 CDistributionClient::GlobalLocalDataMap& globalDataIndex = clientDistributionTiled_->getGlobalDataIndexOnClient(); 867 CDistributionClient::GlobalLocalDataMap::const_iterator itGloe = globalDataIndex.end(); 868 map<int, CArray<size_t, 1> >::iterator itb = outGlobalIndexFromClientTiled.begin(), 869 ite = outGlobalIndexFromClientTiled.end(), it; 870 871 for (it = itb; it != ite; ++it) 872 { 873 int rank = it->first; 874 CArray<size_t,1>& globalIndex = outGlobalIndexFromClientTiled[rank]; 875 outLocalIndexStoreOnClientTiled.insert(make_pair(rank, CArray<size_t,1>(globalIndex.numElements()))); 876 CArray<size_t,1>& localIndex = outLocalIndexStoreOnClientTiled[rank]; 727 877 size_t nbIndex = 0; 728 878 … … 901 1051 else 902 1052 { 903 computeClientIndex(); 1053 if (this->isTiled_) 1054 { 1055 computeClientIndexTiled(); 1056 if (!this->isTiledOnly_) 1057 computeClientIndex(); 1058 } 1059 else 1060 computeClientIndex(); 1061 1062 if (this->isTiled_) computeTileIndex(); 904 1063 if (context->hasClient) 905 1064 { … … 1097 1256 } 1098 1257 CATCH_DUMP_ATTR 1258 1259 //--------------------------------------------------------------- 1260 1261 /* 1262 */ 1263 void CGrid::computeTileIndex() 1264 TRY 1265 { 1266 int numElement = axis_domain_order.numElements(); 1267 storeTileIndex.resize(nTiles_); 1268 1269 std::vector<CAxis*> axisListP = this->getAxis(); 1270 std::vector<CDomain*> domainListP = this->getDomains(); 1271 1272 // First, allocate storeTileIndex[0..ntiles] 1273 for (int iTile = 0; iTile < nTiles_; ++iTile) 1274 { 1275 int tileGridSize = 1; 1276 int axisIndex = 0, domIndex = 0; 1277 for (int idx = 0; idx < numElement; ++idx) 1278 { 1279 int eleDim = axis_domain_order(idx); 1280 if (2 == eleDim) 1281 { 1282 tileGridSize *= domainListP[domIndex]->getTileDataISize(iTile); 1283 tileGridSize *= domainListP[domIndex]->getTileDataJSize(iTile); 1284 ++domIndex; 1285 } 1286 else if (1 == eleDim)// So it's an axis 1287 { 1288 tileGridSize *= axisListP[axisIndex]->n.getValue(); 1289 ++axisIndex; 1290 } 1291 } // loop over grid elements 1292 storeTileIndex[iTile].resize(tileGridSize); 1293 storeTileIndex[iTile] = -1; 1294 } // loop over tiles 1295 1296 // Now fill in storeTileIndex 1297 // Currently assuming two possible situations : (1) domain x axis or (2) domain 1298 std::vector<int> tileIndexCount (nTiles_,0); 1299 int axisSize = 1; 1300 if (axisListP.size() != 0) axisSize = axisListP[0]->n.getValue(); 1301 int ni = domainListP[0]->ni.getValue(); 1302 int nj = domainListP[0]->nj.getValue(); 1303 1304 for (int idxAxis = 0; idxAxis < axisSize; ++idxAxis) 1305 { 1306 for (int jIdxDom = 0; jIdxDom < nj; ++jIdxDom) 1307 { 1308 for (int iIdxDom = 0; iIdxDom < ni; ++iIdxDom) 1309 { 1310 int tile = domainListP[0]->getTileId(iIdxDom, jIdxDom); 1311 int tileOffset = domainListP[0]->tile_data_ibegin(tile); // only sign of offset matters 1312 1313 // case 1: data size corresponds to tile size 1314 if (tileOffset == 0) 1315 { 1316 storeTileIndex[tile](tileIndexCount[tile]) = idxAxis*nj*ni + jIdxDom * ni + iIdxDom; 1317 ++tileIndexCount[tile]; 1318 } 1319 // case 2: masked data 1320 else if (tileOffset > 0) 1321 { 1322 int iBegin = domainListP[0]->tile_ibegin(tile) + domainListP[0]->tile_data_ibegin(tile); // tile data relative to domain 1323 int jBegin = domainListP[0]->tile_jbegin(tile) + domainListP[0]->tile_data_jbegin(tile); // tile data relative to domain 1324 int iEnd = iBegin + domainListP[0]->tile_data_ni(tile); 1325 int jEnd = jBegin + domainListP[0]->tile_data_nj(tile); 1326 if ((jIdxDom >= jBegin) && (jIdxDom < jEnd) && (iIdxDom >= iBegin) && (iIdxDom < iEnd)) 1327 { 1328 storeTileIndex[tile](tileIndexCount[tile]) = idxAxis*nj*ni + jIdxDom * ni + iIdxDom; 1329 } 1330 ++tileIndexCount[tile]; 1331 } 1332 // case 3: ghost zones 1333 else 1334 { 1335 int tileDataNi = domainListP[0]->tile_data_ni(tile); 1336 int tileDataNj = domainListP[0]->tile_data_nj(tile); 1337 int tileDomSize = tileDataNi * tileDataNj; 1338 int tileNi = domainListP[0]->tile_ni(tile); 1339 int iBegin = domainListP[0]->tile_data_ibegin(tile); 1340 int jBegin = domainListP[0]->tile_data_jbegin(tile); 1341 1342 // add the ghost zone at the beginning of a domain tile 1343 if (tileIndexCount[tile] % tileDomSize == 0) 1344 tileIndexCount[tile] += (abs(jBegin)*tileDataNi + abs(iBegin)); 1345 1346 storeTileIndex[tile](tileIndexCount[tile]) = idxAxis*nj*ni + jIdxDom*ni + iIdxDom; 1347 1348 // add two ghost zones at the right end of a tile 1349 if ( (iIdxDom+1) % tileNi == 0 ) 1350 tileIndexCount[tile] += (2*abs(iBegin)); 1351 1352 // add ghost zone at the end of a domain tile 1353 if ((tileIndexCount[tile] + abs(jBegin)*tileDataNi-abs(iBegin) + 1) % tileDomSize == 0) 1354 tileIndexCount[tile] += (abs(jBegin)*tileDataNi -abs(iBegin)); 1355 1356 ++tileIndexCount[tile]; 1357 } 1358 } // loop over domain first dimension 1359 } // loop over domain second dimension 1360 } // loop over axis dimension 1361 1362 } 1363 CATCH_DUMP_ATTR 1364 1099 1365 //---------------------------------------------------------------- 1100 1366 … … 1358 1624 CATCH 1359 1625 1360 void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored) const 1361 { 1362 const StdSize size = storeIndex_client.numElements(); 1626 void CGrid::maskField_arr(const double* const data, CArray<double, 1>& stored, bool isTiled) const 1627 TRY 1628 { 1629 const CArray<int, 1>& storeIndex_clientP = isTiled ? storeIndexTiled_client : storeIndex_client; 1630 const CArray<bool, 1>& storeMask_clientP = isTiled ? storeMaskTiled_client : storeMask_client; 1631 const StdSize size = storeIndex_clientP.numElements(); 1363 1632 stored.resize(size); 1364 1633 const double nanValue = std::numeric_limits<double>::quiet_NaN(); 1365 1634 1366 if (storeMask_client .numElements() != 0)1367 for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_client (i)) ? data[storeIndex_client(i)] : nanValue;1635 if (storeMask_clientP.numElements() != 0) 1636 for(StdSize i = 0; i < size; i++) stored(i) = (storeMask_clientP(i)) ? data[storeIndex_clientP(i)] : nanValue; 1368 1637 else 1369 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_client(i)]; 1370 } 1638 for(StdSize i = 0; i < size; i++) stored(i) = data[storeIndex_clientP(i)]; 1639 } 1640 CATCH 1641 1642 void CGrid::copyTile_arr(const double* const tileData, CArray<double, 1>& stored, int tileId) 1643 TRY 1644 { 1645 StdSize tileSize = this->getTileSize(tileId); 1646 const StdSize tileDataSize = this->getTileDataSize(tileId); 1647 1648 // case 1: data correspond in size to a tile 1649 if (tileSize == tileDataSize) 1650 { 1651 for(StdSize i = 0; i < tileDataSize; i++) 1652 stored(storeTileIndex[tileId](i)) = tileData[i]; 1653 } 1654 // case 2: masked data 1655 else if (tileSize > tileDataSize) 1656 { 1657 int tileDataCount = 0; 1658 for(StdSize i = 0; i < tileSize; i++) 1659 if (storeTileIndex[tileId](i) >= 0) 1660 { 1661 stored(storeTileIndex[tileId](i)) = tileData[tileDataCount]; 1662 ++tileDataCount; 1663 } 1664 } 1665 // case 3: ghost zones 1666 else 1667 { 1668 for(StdSize i = 0; i < tileDataSize; i++) 1669 if (storeTileIndex[tileId](i) >= 0) 1670 { 1671 stored(storeTileIndex[tileId](i)) = tileData[i]; 1672 } 1673 1674 } 1675 } 1676 CATCH 1371 1677 1372 1678 void CGrid::uncompressField_arr(const double* const data, CArray<double, 1>& out) const … … 2253 2559 pDom->solveRefInheritance(apply); 2254 2560 pDom->solveInheritanceTransformation(); 2561 if (!pDom->ntiles.isEmpty() && pDom->ntiles.getValue()>0) nTiles_=pDom->ntiles.getValue(); 2255 2562 } 2256 2563 } … … 2281 2588 } 2282 2589 CATCH_DUMP_ATTR 2590 2591 int CGrid::getNTiles() 2592 TRY 2593 { 2594 return nTiles_; 2595 } 2596 CATCH_DUMP_ATTR 2597 2598 bool CGrid::isTiled(void) const 2599 TRY 2600 { 2601 return isTiled_; 2602 } 2603 CATCH 2604 2605 bool CGrid::isTiledOnly(void) const 2606 TRY 2607 { 2608 return isTiledOnly_; 2609 } 2610 CATCH 2283 2611 2284 2612 bool CGrid::isTransformed() -
XIOS/trunk/src/node/grid.hpp
r1927 r2131 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> 95 99 void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; 96 100 template <int n> 97 void maskField(const CArray<double,n>& field, CArray<double,1>& stored ) const;101 void maskField(const CArray<double,n>& field, CArray<double,1>& stored, bool isTiled = false) const; 98 102 template <int n> 99 103 void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const; 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); … … 205 211 public: 206 212 CArray<int, 1> storeIndex_client; 213 CArray<int, 1> storeIndexTiled_client; 207 214 CArray<bool, 1> storeMask_client; 215 CArray<bool, 1> storeMaskTiled_client; 208 216 209 217 /** Map containing indexes that will be sent in sendIndex(). */ … … 223 231 /** Map storing received indexes. Key = sender rank, value = index array. */ 224 232 map<int, CArray<size_t, 1> > outGlobalIndexFromClient; 233 234 /** Map storing received indexes. Key = sender rank, value = index array for tiled domains */ 235 map<int, CArray<size_t, 1> > outGlobalIndexFromClientTiled; 225 236 226 237 // Manh Ha's comment: " A client receives global index from other clients (via recvIndex) … … 232 243 * The map is created in CGrid::computeClientIndex and filled upon receiving data in CField::recvUpdateData() */ 233 244 map<int, CArray<size_t, 1> > outLocalIndexStoreOnClient; 245 246 /** Map storing received data. Key = sender rank, value = data array. 247 * The map is created in CGrid::computeClientIndex and filled upon receiving data in CField::recvUpdateData() */ 248 map<int, CArray<size_t, 1> > outLocalIndexStoreOnClientTiled; 249 234 250 235 251 /** Indexes calculated based on server-like distribution. … … 255 271 const std::vector<CScalar*>& scalars, 256 272 const CArray<int,1>& axisDomainOrder); 273 274 int getNTiles(); 275 bool isTiled(void) const; 276 bool isTiledOnly(void) const; 257 277 258 278 private: … … 272 292 void restoreField_arr(const CArray<double, 1>& stored, double* const data) const; 273 293 void uncompressField_arr(const double* const data, CArray<double, 1>& outData) const; 274 void maskField_arr(const double* const data, CArray<double, 1>& stored) const; 294 void maskField_arr(const double* const data, CArray<double, 1>& stored, bool isTiled = false) const; 295 void copyTile_arr(const double* const tileData, CArray<double, 1>& stored, int tileId); 275 296 276 297 void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); … … 299 320 300 321 void computeClientIndex(); 322 void computeClientIndexTiled(); 301 323 void computeConnectedClients(); 302 324 void computeClientIndexScalarGrid(); 303 325 void computeConnectedClientsScalarGrid(); 304 326 327 void computeTileIndex(); 328 305 329 private: 306 330 … … 312 336 bool isDomainAxisChecked; 313 337 bool isIndexSent; 338 339 int nTiles_; 340 /** True if tiled data is defined on the grid */ 341 bool isTiled_; 342 /** True if ONLY tiled data is defined on the grid */ 343 bool isTiledOnly_; 344 345 /** Vector containing local domain indexes for each tile */ 346 std::vector<CArray<int,1> > storeTileIndex; 314 347 315 348 CDomainGroup* vDomainGroup_; … … 321 354 /** Client-like distribution calculated based on the knowledge of the entire grid */ 322 355 CDistributionClient* clientDistribution_; 356 357 /** Client-like distribution calculated based on the knowledge of the entire grid in case of a tiled domain */ 358 CDistributionClient* clientDistributionTiled_; 359 323 360 324 361 /** Server-like distribution calculated upon receiving indexes */ … … 387 424 388 425 template <int n> 389 void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const 426 void CGrid::copyTile(const CArray<double,n>& tileData, CArray<double,1>& storedData, int tileId) 427 { 428 this->copyTile_arr(tileData.dataFirst(), storedData, tileId); 429 } 430 431 template <int n> 432 void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored, bool isTiled) const 390 433 { 391 434 //#ifdef __XIOS_DEBUG 392 435 if (this->getDataSize() != field.numElements()) 393 ERROR("void CGrid:: inputField(const CArray<double,n>& field, CArray<double,1>& stored) const",436 ERROR("void CGrid::maskField(const CArray<double,n>& field, CArray<double,1>& stored) const", 394 437 << "[ Awaiting data of size = " << this->getDataSize() << ", " 395 438 << "Received data size = " << field.numElements() << " ] " … … 397 440 << "Grid = " << this->getId()) 398 441 //#endif 399 this->maskField_arr(field.dataFirst(), stored );442 this->maskField_arr(field.dataFirst(), stored, isTiled); 400 443 } 401 444
Note: See TracChangeset
for help on using the changeset viewer.