Changeset 2386 for XIOS3/trunk/src
- Timestamp:
- 07/26/22 15:26:52 (2 years ago)
- Location:
- XIOS3/trunk/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/attribute.hpp
r2146 r2386 44 44 virtual StdString dumpGraph(void) const = 0; 45 45 virtual bool isEqual(const CAttribute& ) = 0; 46 virtual int computeHash(void) = 0; 46 47 47 48 //! Returns true if and only if the attribute should be publicly exposed in the API -
XIOS3/trunk/src/attribute_array.hpp
r2146 r2386 44 44 45 45 bool isEqual(const CAttribute& attr); 46 int computeHash(void); 46 47 47 48 /// Destructeur /// -
XIOS3/trunk/src/attribute_array_impl.hpp
r2305 r2386 117 117 else return false; 118 118 } 119 120 template <typename T_numtype, int N_rank> 121 int CAttributeArray<T_numtype,N_rank>::computeHash(void) 122 { 123 ERROR("CAttributeArray::computeHash(void)", 124 << "NOT IMPLEMENTED FOR NOW !"); 125 return std::hash<string>{}( toString() ); 126 } 119 127 120 128 template <typename T_numtype, int N_rank> -
XIOS3/trunk/src/attribute_enum.hpp
r2146 r2386 52 52 53 53 bool isEqual(const CAttribute& attr ); 54 int computeHash(void); 54 55 55 56 /// Destructeur /// -
XIOS3/trunk/src/attribute_enum_impl.hpp
r2305 r2386 126 126 } 127 127 128 template <class T> 129 int CAttributeEnum<T>::computeHash(void) 130 { 131 // Basic hash computation through string 132 return std::hash<string>{}( toString() ); 133 } 134 128 135 //--------------------------------------------------------------- 129 136 -
XIOS3/trunk/src/attribute_map.cpp
r2146 r2386 269 269 } 270 270 271 /*! 272 Compute the hash value of current attribute map excluding some attributs. 273 \param [in] excludedAttrs attribute to be excluded from hash computation 274 */ 275 int CAttributeMap::computeGlobalAttributesHash(const vector<StdString>& excludedAttrs) 276 { 277 int attrs_hash( 0 ); 278 typedef std::pair<StdString, CAttribute*> StdStrAttPair; 279 280 SuperClassMap::const_iterator it = this->begin(), end = this->end(); 281 for (; it != end; it++) 282 { 283 const StdStrAttPair& el = *it; 284 if ( std::find( excludedAttrs.begin(), excludedAttrs.end(), el.first ) == excludedAttrs.end() ) 285 { 286 if (this->hasAttribute(el.first)) 287 { 288 if (!el.second->isEmpty()) 289 { 290 attrs_hash += el.second->computeHash(); 291 } 292 } 293 } 294 } 295 return attrs_hash; 296 } 297 271 298 //--------------------------------------------------------------- 272 299 /* -
XIOS3/trunk/src/attribute_map.hpp
r2146 r2386 37 37 void setAttributes(const CAttributeMap * const _parent, bool apply=true); 38 38 void duplicateAttributes(const CAttributeMap* const _parent); 39 int computeGlobalAttributesHash(const vector<StdString>& excludedAttrs); 39 40 void clearAllAttributes(void); 40 41 StdString dumpXiosAttributes(void) const; -
XIOS3/trunk/src/attribute_template.hpp
r2146 r2386 61 61 62 62 bool isEqual(const CAttribute& attr ); 63 int computeHash(void); 63 64 64 65 /// Destructeur /// -
XIOS3/trunk/src/attribute_template_impl.hpp
r2305 r2386 168 168 if (!this->isEmpty() && !attr.isEmpty()) return (this->getValue() == attr.getValue()); 169 169 else return false; 170 } 171 172 template <class T> 173 int CAttributeTemplate<T>::computeHash(void) 174 { 175 // Basic hash computation through string 176 return std::hash<string>{}( toString() ); 170 177 } 171 178 -
XIOS3/trunk/src/io/nc4_data_output.cpp
r2385 r2386 78 78 if (!domain->lonvalue.isEmpty() ) 79 79 { 80 int globalSize = domain->ni_glo.getValue()*domain->nj_glo.getValue(); 81 CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 82 shared_ptr<CGridTransformConnector> gridTransformConnector; 83 // Compute a without redundancy element FULL view to enable a consistent hash computation 84 domain->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm_file, gridTransformConnector, globalIndex ); 85 int localSize = globalIndex.numElements(); 86 87 CArray<double,1> lon_distributedValue, lat_distributedValue ; 88 gridTransformConnector->transfer(domain->lonvalue, lon_distributedValue ); 89 gridTransformConnector->transfer(domain->latvalue, lat_distributedValue ); 90 91 // Compute the distributed hash (v0) of the element 92 // it will be associated to the default element name (= map key), and to the name really written 93 int localHash = 0; 94 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc); 95 int globalHash(0); 96 MPI_Allreduce( &localHash, &globalHash, 1, MPI_INT, MPI_SUM, comm_file ); 97 80 // The hash of the element will be associated to the default element name (= map key), and to the name really written 81 int globalHash = domain->computeAttributesHash( comm_file ); // Need a MPI_Comm to distribute without redundancy some attributs (value) 82 98 83 StdString defaultNameKey = domain->getDomainOutputName(); 99 84 if ( !relDomains_.count ( defaultNameKey ) ) … … 1056 1041 if (!axis->value.isEmpty() ) 1057 1042 { 1058 int globalSize = axis->n_glo.getValue(); 1059 CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 1060 shared_ptr<CGridTransformConnector> gridTransformConnector; 1061 // Compute a without redundancy element FULL view to enable a consistent hash computation 1062 axis->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm_file, gridTransformConnector, globalIndex ); 1063 int localSize = globalIndex.numElements(); 1064 1065 CArray<double,1> distributedValue ; 1066 gridTransformConnector->transfer(axis->value, distributedValue ); 1067 1068 // Compute the distributed hash (v0) of the element 1069 // it will be associated to the default element name (= map key), and to the name really written 1070 int localHash = 0; 1071 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc); 1072 int globalHash(0); 1073 MPI_Allreduce( &localHash, &globalHash, 1, MPI_INT, MPI_SUM, comm_file ); 1043 // The hash of the element will be associated to the default element name (= map key), and to the name really written 1044 int globalHash = axis->computeAttributesHash( comm_file ); // Need a MPI_Comm to distribute without redundancy some attributs (value) 1074 1045 1075 1046 StdString defaultNameKey = axis->getAxisOutputName(); -
XIOS3/trunk/src/node/axis.cpp
r2343 r2386 302 302 bounds.reset(); 303 303 label.reset() ; 304 } 305 306 int CAxis::computeAttributesHash( MPI_Comm comm ) 307 { 308 int axis_hash = 0; 309 310 // Compute the hash of distributed attributs (value ...) 311 int globalSize = this->n_glo.getValue(); 312 CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 313 shared_ptr<CGridTransformConnector> gridTransformConnector; 314 // Compute a without redundancy element FULL view to enable a consistent hash computation (and a distributed globalIndex) 315 this->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm, gridTransformConnector, globalIndex ); 316 int localSize = globalIndex.numElements(); 317 318 CArray<double,1> distributedValue ; 319 gridTransformConnector->transfer(this->value, distributedValue ); 320 321 int localHash = 0; 322 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc); 323 int distributedHash = 0; 324 MPI_Allreduce( &localHash, &distributedHash, 1, MPI_INT, MPI_SUM, comm ); 325 326 // Compute the hash of global attributs (unit, prec ...) 327 vector<StdString> excludedAttr; 328 //excludedAttr.push_back("name"); 329 // internal attributs 330 excludedAttr.insert(excludedAttr.end(), { "index", "data_n", "data_begin", "data_index" }); 331 excludedAttr.insert(excludedAttr.end(), { "begin", "n" }); 332 excludedAttr.push_back("axis_ref"); 333 // in distributed 334 excludedAttr.push_back("value"); 335 // should be considered in distributed 336 excludedAttr.push_back("bounds"); 337 excludedAttr.push_back("label"); 338 excludedAttr.push_back("mask"); // ??? 339 340 int globalHash = this->computeGlobalAttributesHash( excludedAttr ); 341 342 return distributedHash + globalHash; 304 343 } 305 344 -
XIOS3/trunk/src/node/axis.hpp
r2326 r2386 130 130 void resetGeometricAttributes(void) ; 131 131 132 int computeAttributesHash( MPI_Comm comm ); 133 132 134 size_t getGlobalWrittenSize(void) ; 133 135 -
XIOS3/trunk/src/node/domain.cpp
r2343 r2386 1770 1770 CATCH_DUMP_ATTR 1771 1771 1772 int CDomain::computeAttributesHash( MPI_Comm comm ) 1773 { 1774 int domain_hash = 0; 1775 1776 // Compute the hash of distributed attributs (value ...) 1777 int globalSize = this->ni_glo.getValue()*this->nj_glo.getValue(); 1778 CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 1779 shared_ptr<CGridTransformConnector> gridTransformConnector; 1780 // Compute a without redundancy element FULL view to enable a consistent hash computation 1781 this->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm, gridTransformConnector, globalIndex ); 1782 int localSize = globalIndex.numElements(); 1783 1784 CArray<double,1> lon_distributedValue, lat_distributedValue ; 1785 gridTransformConnector->transfer(this->lonvalue, lon_distributedValue ); 1786 gridTransformConnector->transfer(this->latvalue, lat_distributedValue ); 1787 1788 // Compute the distributed hash (v0) of the element 1789 // it will be associated to the default element name (= map key), and to the name really written 1790 int localHash = 0; 1791 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc); 1792 int distributedHash = 0; 1793 MPI_Allreduce( &localHash, &distributedHash, 1, MPI_INT, MPI_SUM, comm ); 1794 1795 // Compute the hash of global attributs (unit, prec ...) 1796 vector<StdString> excludedAttr; 1797 //excludedAttr.push_back("name"); 1798 // internal attributs 1799 excludedAttr.insert(excludedAttr.end(), { "ibegin", "jbegin", "ni", "nj", "i_index", "j_index" }); 1800 excludedAttr.insert(excludedAttr.end(), { "data_ni", "data_nj", "data_ibegin", "data_jbegin" }); 1801 excludedAttr.insert(excludedAttr.end(), { "data_i_index", "data_j_index", "domain_ref" }); 1802 // in distributed through lonvalue and latvalue 1803 excludedAttr.insert(excludedAttr.end(), { "lonvalue_1d", "latvalue_1d", "lonvalue_2d", "latvalue_2d" }); 1804 // should be considered in distributed 1805 excludedAttr.insert(excludedAttr.end(), { "mask_1d", "mask_2d" }); // ??? 1806 excludedAttr.insert(excludedAttr.end(), { "bounds_lon_1d", "bounds_lat_1d", "bounds_lon_2d", "bounds_lat_2d" }); 1807 excludedAttr.insert(excludedAttr.end(), { "area" }); 1808 // private 1809 excludedAttr.insert(excludedAttr.end(), { "lon_start", "lon_end", "lat_start", "lat_end" }); 1810 excludedAttr.insert(excludedAttr.end(), { "bounds_lon_start", "bounds_lon_end", "bounds_lat_start", "bounds_lat_end" }); 1811 excludedAttr.insert(excludedAttr.end(), { "has_lat_in_read_file", "has_lon_in_read_file", "has_bounds_lat_in_read_file", "has_bounds_lon_in_read_file" }); 1812 excludedAttr.insert(excludedAttr.end(), { "lonvalue_rectilinear_read_from_file", "latvalue_rectilinear_read_from_file", "lonvalue_curvilinear_read_from_file", "latvalue_curvilinear_read_from_file" }); 1813 excludedAttr.insert(excludedAttr.end(), { "bounds_lonvalue_curvilinear_read_from_file", "bounds_latvalue_curvilinear_read_from_file", "lonvalue_unstructured_read_from_file", "latvalue_unstructured_read_from_file" }); 1814 excludedAttr.insert(excludedAttr.end(), { "bounds_lonvalue_unstructured_read_from_file", "bounds_latvalue_unstructured_read_from_file" }); 1815 1816 int globalHash = this->computeGlobalAttributesHash( excludedAttr ); 1817 1818 return distributedHash + globalHash; 1819 } 1772 1820 1773 1821 void CDomain::initializeLocalElement(void) -
XIOS3/trunk/src/node/domain.hpp
r2326 r2386 91 91 bool checkAttributes_done_ = false ; 92 92 93 int computeAttributesHash( MPI_Comm comm ); 93 94 94 95 //////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.