Changeset 2385
- Timestamp:
- 07/26/22 09:50:48 (23 months ago)
- Location:
- XIOS3/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/distribution/local_view.cpp
r2267 r2385 3 3 #include "array_new.hpp" 4 4 #include "remote_connector.hpp" 5 #include "grid_transform_connector.hpp" 5 6 6 7 namespace xios … … 38 39 connector->transferToServer(ind, client, event, message) ; 39 40 } 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 ); 40 48 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 } 41 77 42 78 } -
XIOS3/trunk/src/distribution/local_view.hpp
r2267 r2385 12 12 class CLocalElement ; 13 13 class CRemoteConnector ; 14 class CGridTransformConnector; 14 15 15 class CLocalView : public CDistributedView 16 class CLocalView : public CDistributedView, public std::enable_shared_from_this<CLocalView> 16 17 { 17 18 public: … … 53 54 } 54 55 56 void createWithoutRedundancyFullViewConnector( int globalSize, MPI_Comm comm_file, shared_ptr<CGridTransformConnector>& gridTransformConnector, CArray<size_t,1>& globalIndex ); 55 57 56 58 int getLocalSize(void) {return localSize_ ;} -
XIOS3/trunk/src/io/nc4_data_output.cpp
r2384 r2385 78 78 if (!domain->lonvalue.isEmpty() ) 79 79 { 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; 90 83 // 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 113 87 CArray<double,1> lon_distributedValue, lat_distributedValue ; 114 88 gridTransformConnector->transfer(domain->lonvalue, lon_distributedValue ); … … 120 94 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*lon_distributedValue(iloc)*lat_distributedValue(iloc); 121 95 int globalHash(0); 122 globalHash = localHash;123 96 MPI_Allreduce( &localHash, &globalHash, 1, MPI_INT, MPI_SUM, comm_file ); 124 97 … … 1083 1056 if (!axis->value.isEmpty() ) 1084 1057 { 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 1118 1065 CArray<double,1> distributedValue ; 1119 1066 gridTransformConnector->transfer(axis->value, distributedValue ); … … 1124 1071 for (int iloc=0; iloc<localSize ; iloc++ ) localHash+=globalIndex(iloc)*distributedValue(iloc); 1125 1072 int globalHash(0); 1126 globalHash = localHash;1127 1073 MPI_Allreduce( &localHash, &globalHash, 1, MPI_INT, MPI_SUM, comm_file ); 1128 1074
Note: See TracChangeset
for help on using the changeset viewer.