Ignore:
Timestamp:
07/26/22 15:26:52 (2 years ago)
Author:
jderouillat
Message:

Set the code structure to compute the hash value of an element based on its attributs, use for now before writing an element in a file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/src/node/axis.cpp

    r2343 r2386  
    302302     bounds.reset(); 
    303303     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; 
    304343   } 
    305344 
Note: See TracChangeset for help on using the changeset viewer.