Changeset 2606 for XIOS3/trunk
- Timestamp:
- 01/29/24 10:38:53 (12 months ago)
- Location:
- XIOS3/trunk/src/node
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/node/axis.cpp
r2546 r2606 308 308 size_t CAxis::computeAttributesHash( MPI_Comm comm ) 309 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 size_t localHash = 0; 322 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc); 310 int sz(1); 311 MPI_Comm_size( comm, &sz ); 323 312 size_t distributedHash = 0; 324 MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm ); 313 if (sz!=1) // compute the connector only if the element is distributed 314 { 315 // Compute the hash of distributed attributs (value ...) 316 int globalSize = this->n_glo.getValue(); 317 CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 318 shared_ptr<CGridTransformConnector> gridTransformConnector; 319 // Compute a without redundancy element FULL view to enable a consistent hash computation (and a distributed globalIndex) 320 this->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm, gridTransformConnector, globalIndex ); 321 int localSize = globalIndex.numElements(); 322 323 CArray<double,1> distributedValue ; 324 gridTransformConnector->transfer(this->value, distributedValue ); 325 326 size_t localHash = 0; 327 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc); 328 distributedHash = 0; 329 MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm ); 330 } 331 else // if the element is not distributed, the local hash is valid 332 { 333 int globalSize = this->n_glo.getValue(); 334 int localSize = globalSize; 335 size_t localHash = 0; 336 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=iloc*this->value(iloc); 337 distributedHash = localHash; 338 } 325 339 326 340 // Compute the hash of global attributs (unit, prec ...) -
XIOS3/trunk/src/node/domain.cpp
r2601 r2606 1807 1807 size_t CDomain::computeAttributesHash( MPI_Comm comm ) 1808 1808 { 1809 // Compute the hash of distributed attributs (value ...) 1810 int globalSize = this->ni_glo.getValue()*this->nj_glo.getValue(); 1811 CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 1812 shared_ptr<CGridTransformConnector> gridTransformConnector; 1813 // Compute a without redundancy element FULL view to enable a consistent hash computation 1814 this->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm, gridTransformConnector, globalIndex ); 1815 int localSize = globalIndex.numElements(); 1816 1817 CArray<double,1> lon_distributedValue, lat_distributedValue ; 1818 gridTransformConnector->transfer(this->lonvalue, lon_distributedValue ); 1819 gridTransformConnector->transfer(this->latvalue, lat_distributedValue ); 1820 1821 // Compute the distributed hash (v0) of the element 1822 // it will be associated to the default element name (= map key), and to the name really written 1823 size_t localHash = 0; 1824 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc); 1809 int sz(1); 1810 MPI_Comm_size( comm, &sz ); 1825 1811 size_t distributedHash = 0; 1826 MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm ); 1827 1812 if (sz!=1) // compute the connector only if the element is distributed 1813 { 1814 // Compute the hash of distributed attributs (value ...) 1815 int globalSize = this->ni_glo.getValue()*this->nj_glo.getValue(); 1816 CArray<size_t,1> globalIndex; // No redundancy globalIndex will be computed with the connector 1817 shared_ptr<CGridTransformConnector> gridTransformConnector; 1818 // Compute a without redundancy element FULL view to enable a consistent hash computation 1819 this->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm, gridTransformConnector, globalIndex ); 1820 int localSize = globalIndex.numElements(); 1821 1822 CArray<double,1> lon_distributedValue, lat_distributedValue ; 1823 gridTransformConnector->transfer(this->lonvalue, lon_distributedValue ); 1824 gridTransformConnector->transfer(this->latvalue, lat_distributedValue ); 1825 1826 // Compute the distributed hash (v0) of the element 1827 // it will be associated to the default element name (= map key), and to the name really written 1828 size_t localHash = 0; 1829 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc); 1830 distributedHash = 0; 1831 MPI_Allreduce( &localHash, &distributedHash, 1, MPI_UNSIGNED_LONG, MPI_SUM, comm ); 1832 } 1833 else // if the element is not distributed, the local hash is valid 1834 { 1835 int globalSize = this->ni_glo.getValue()*this->nj_glo.getValue(); 1836 int localSize = globalSize; 1837 size_t localHash = 0; 1838 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=iloc*this->lonvalue(iloc)*this->latvalue(iloc); 1839 distributedHash = localHash; 1840 } 1841 1828 1842 // Compute the hash of global attributs (unit, prec ...) 1829 1843 vector<StdString> excludedAttr;
Note: See TracChangeset
for help on using the changeset viewer.