Ignore:
Timestamp:
01/29/24 10:38:53 (5 months ago)
Author:
jderouillat
Message:

Compute the GridTransformConnector? (and the associated GridRemoteConnector?) only in a distributed context for the identification of templated elements

File:
1 edited

Legend:

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

    r2546 r2606  
    308308   size_t CAxis::computeAttributesHash( MPI_Comm comm ) 
    309309   { 
    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 ); 
    323312     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     } 
    325339 
    326340     // Compute the hash of global attributs (unit, prec ...) 
Note: See TracChangeset for help on using the changeset viewer.