Changeset 2385


Ignore:
Timestamp:
07/26/22 09:50:48 (23 months ago)
Author:
jderouillat
Message:

Move in a new method of CLocalView the management of a without redundancy full view connector (used in hash computation of elements)

Location:
XIOS3/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • XIOS3/trunk/src/distribution/local_view.cpp

    r2267 r2385  
    33#include "array_new.hpp" 
    44#include "remote_connector.hpp" 
     5#include "grid_transform_connector.hpp" 
    56 
    67namespace xios 
     
    3839    connector->transferToServer(ind, client, event, message) ; 
    3940  } 
     41   
     42  void CLocalView::createWithoutRedundancyFullViewConnector( int globalSize, MPI_Comm comm_file, shared_ptr<CGridTransformConnector>& gridTransformConnector, CArray<size_t,1>& globalIndex ) 
     43  { 
     44    int comm_file_rank(0); 
     45    MPI_Comm_rank( comm_file, &comm_file_rank ); 
     46    int comm_file_size(1); 
     47    MPI_Comm_size( comm_file, &comm_file_size ); 
    4048 
     49    vector<shared_ptr<CLocalView>> srcViews; 
     50    shared_ptr<CLocalView> srcView = shared_from_this(); 
     51    srcViews.push_back( srcView ); 
     52           
     53    // Compute a without redundancy element FULL view to enable a consistent hash computation 
     54    vector<shared_ptr<CLocalView>> remoteViews; 
     55    shared_ptr<CLocalView> remoteView; 
     56    // define the remote view without redundancy (naive distribution of the remote view) 
     57    int localSize = globalSize/comm_file_size; 
     58    if ( (comm_file_rank==comm_file_size-1) && (localSize*comm_file_size != globalSize ) ) 
     59      localSize += globalSize-localSize*comm_file_size; 
     60    globalIndex.resize( localSize ); 
     61    CArray<int,1> index( localSize ); 
     62    for (int iloc=0; iloc<localSize ; iloc++ ) 
     63      { 
     64        globalIndex(iloc) = comm_file_rank*(globalSize/comm_file_size) + iloc; 
     65        index(iloc) = iloc; 
     66      } 
     67    shared_ptr<CLocalElement> localElement = make_shared<CLocalElement>(comm_file_rank, globalSize, globalIndex) ; 
     68    localElement->addView(CElementView::FULL, index) ; 
     69    remoteView = localElement->getView(CElementView::FULL) ; 
     70    remoteViews.push_back( remoteView ); 
     71         
     72    // Compute the connector between current and without redundancy FULL views 
     73    gridTransformConnector = make_shared<CGridTransformConnector>(srcViews, remoteViews, comm_file ) ; 
     74    gridTransformConnector->computeConnector(true) ; // eliminateRedondant = true 
     75 
     76  } 
    4177 
    4278} 
  • XIOS3/trunk/src/distribution/local_view.hpp

    r2267 r2385  
    1212  class CLocalElement ; 
    1313  class CRemoteConnector ; 
     14  class CGridTransformConnector; 
    1415 
    15   class CLocalView : public CDistributedView 
     16  class CLocalView : public CDistributedView, public std::enable_shared_from_this<CLocalView> 
    1617  { 
    1718    public: 
     
    5354    } 
    5455 
     56    void createWithoutRedundancyFullViewConnector( int globalSize, MPI_Comm comm_file, shared_ptr<CGridTransformConnector>& gridTransformConnector, CArray<size_t,1>& globalIndex ); 
    5557 
    5658    int getLocalSize(void) {return localSize_ ;} 
  • XIOS3/trunk/src/io/nc4_data_output.cpp

    r2384 r2385  
    7878         if (!domain->lonvalue.isEmpty() ) 
    7979         { 
    80            int comm_file_rank(0); 
    81            MPI_Comm_rank( comm_file, &comm_file_rank ); 
    82            int comm_file_size(1); 
    83            MPI_Comm_size( comm_file, &comm_file_size ); 
    84           
    85            // Get element current FULL view 
    86            shared_ptr<CLocalView> srcView = domain->getLocalView(CElementView::FULL) ; 
    87            vector<shared_ptr<CLocalView>> srcViews; 
    88            srcViews.push_back( srcView ); 
    89           
     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; 
    9083           // Compute a without redundancy element FULL view to enable a consistent hash computation 
    91            vector<shared_ptr<CLocalView>> remoteViews; 
    92            shared_ptr<CLocalView> remoteView; 
    93            // define the remote view without redundancy (naive distribution of the remote view) 
    94            int globalSize = domain->ni_glo.getValue()*domain->nj_glo.getValue(); 
    95            int localSize = globalSize/comm_file_size; 
    96            if ( (comm_file_rank==comm_file_size-1) && (localSize*comm_file_size != globalSize ) ) 
    97              localSize += globalSize-localSize*comm_file_size; 
    98            CArray<size_t,1> globalIndex( localSize ); 
    99            CArray<int,1> index( localSize ); 
    100            for (int iloc=0; iloc<localSize ; iloc++ ) 
    101            { 
    102              globalIndex(iloc) = comm_file_rank*(globalSize/comm_file_size) + iloc; 
    103              index(iloc) = iloc; 
    104            } 
    105            shared_ptr<CLocalElement> localElement = make_shared<CLocalElement>(comm_file_rank, globalSize, globalIndex) ; 
    106            localElement->addView(CElementView::FULL, index) ; 
    107            remoteView = localElement->getView(CElementView::FULL) ; 
    108            remoteViews.push_back( remoteView ); 
    109           
    110            // Compute the connector between current and without redundancy FULL views 
    111            shared_ptr<CGridTransformConnector> gridTransformConnector = make_shared<CGridTransformConnector>(srcViews, remoteViews, comm_file ) ; 
    112            gridTransformConnector->computeConnector(true) ; // eliminateRedondant = true 
     84           domain->getLocalView(CElementView::FULL)->createWithoutRedundancyFullViewConnector( globalSize, comm_file, gridTransformConnector, globalIndex ); 
     85           int localSize = globalIndex.numElements(); 
     86            
    11387           CArray<double,1> lon_distributedValue, lat_distributedValue ; 
    11488           gridTransformConnector->transfer(domain->lonvalue, lon_distributedValue ); 
     
    12094           for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc); 
    12195           int globalHash(0); 
    122            globalHash = localHash; 
    12396           MPI_Allreduce( &localHash, &globalHash, 1, MPI_INT, MPI_SUM, comm_file  ); 
    12497          
     
    10831056        if (!axis->value.isEmpty() ) 
    10841057        { 
    1085           int comm_file_rank(0); 
    1086           MPI_Comm_rank( comm_file, &comm_file_rank ); 
    1087           int comm_file_size(1); 
    1088           MPI_Comm_size( comm_file, &comm_file_size ); 
    1089  
    1090           // Get element current FULL view 
    1091           shared_ptr<CLocalView> srcView = axis->getLocalView(CElementView::FULL) ; 
    1092           vector<shared_ptr<CLocalView>> srcViews; 
    1093           srcViews.push_back( srcView ); 
    1094            
    1095           // Compute a without redundancy element FULL view to enable a consistent hash computation 
    1096           vector<shared_ptr<CLocalView>> remoteViews; 
    1097           shared_ptr<CLocalView> remoteView; 
    1098           // define the remote view without redundancy (naive distribution of the remote view) 
    1099           int globalSize = axis->n_glo.getValue(); 
    1100           int localSize = globalSize/comm_file_size; 
    1101           if ( (comm_file_rank==comm_file_size-1) && (localSize*comm_file_size != globalSize ) ) 
    1102             localSize += globalSize-localSize*comm_file_size; 
    1103           CArray<size_t,1> globalIndex( localSize ); 
    1104           CArray<int,1> index( localSize ); 
    1105           for (int iloc=0; iloc<localSize ; iloc++ ) 
    1106           { 
    1107             globalIndex(iloc) = comm_file_rank*(globalSize/comm_file_size) + iloc; 
    1108             index(iloc) = iloc; 
    1109           } 
    1110           shared_ptr<CLocalElement> localElement = make_shared<CLocalElement>(comm_file_rank, globalSize, globalIndex) ; 
    1111           localElement->addView(CElementView::FULL, index) ; 
    1112           remoteView = localElement->getView(CElementView::FULL) ; 
    1113           remoteViews.push_back( remoteView ); 
    1114          
    1115           // Compute the connector between current and without redundancy FULL views 
    1116           shared_ptr<CGridTransformConnector> gridTransformConnector = make_shared<CGridTransformConnector>(srcViews, remoteViews, comm_file ) ; 
    1117           gridTransformConnector->computeConnector(true) ; // eliminateRedondant = true 
     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 
    11181065          CArray<double,1> distributedValue ; 
    11191066          gridTransformConnector->transfer(axis->value, distributedValue ); 
     
    11241071          for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc); 
    11251072          int globalHash(0); 
    1126           globalHash = localHash; 
    11271073          MPI_Allreduce( &localHash, &globalHash, 1, MPI_INT, MPI_SUM, comm_file  ); 
    11281074 
Note: See TracChangeset for help on using the changeset viewer.