Changeset 1025
- Timestamp:
- 01/11/17 15:14:22 (8 years ago)
- Location:
- XIOS/dev/dev_olga
- Files:
-
- 17 deleted
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/inputs/iodef.xml
r987 r1025 8 8 <field_definition level="1" enabled=".TRUE."> 9 9 <field id="field_A" operation="average" freq_op="3600s" grid_ref="grid_A"/> 10 <field id="field_Axis" operation="average" freq_op="3600s" axis_ref="axis_A"/> 11 <field id="field_Domain" operation="average" freq_op="3600s" domain_ref="domain_A"/> 10 12 <field id="field_A_zoom" operation="average" freq_op="3600s" field_ref="field_A" grid_ref="grid_A_zoom"/> 11 13 </field_definition> … … 14 16 <file_definition type="one_file" par_access="collective" output_freq="1h" output_level="10" enabled=".TRUE."> 15 17 <file id="output" name="output"> 16 <field field_ref="field_ A" name="field_A" />18 <field field_ref="field_Domain" name="field_A" /> 17 19 </file> 18 20 </file_definition> -
XIOS/dev/dev_olga/src/attribute.hpp
r778 r1025 55 55 //! Returns true if and only if the attribute should be publicly exposed in the API 56 56 virtual bool isPublic() const { return true; } 57 58 //! Return true if the attribute should be sent to other clients or servers 59 virtual bool doSend() const { return true; } 57 60 58 61 virtual void generateCInterface(ostream& oss, const string& className) = 0 ; -
XIOS/dev/dev_olga/src/client_server_mapping.cpp
r843 r1025 97 97 } 98 98 99 CClientServerMapping::GlobalIndexMap& CClientServerMapping::getGlobalIndexOnServer() 100 { 101 return indexGlobalOnServer_; 102 } 103 99 104 } //namespace xios -
XIOS/dev/dev_olga/src/client_server_mapping.hpp
r843 r1025 42 42 const GlobalIndexMap& getGlobalIndexOnServer() const; 43 43 44 GlobalIndexMap& getGlobalIndexOnServer(); 45 44 46 protected: 45 47 //! Global index of data on SERVER, which are calculated by client(s) -
XIOS/dev/dev_olga/src/config/axis_attribute.conf
r817 r1025 6 6 7 7 DECLARE_ATTRIBUTE(int, n_glo) 8 DECLARE_ENUM2(positive, up, down) 8 DECLARE_ENUM2(positive, up, down) 9 9 10 10 /* GLOBAL */ -
XIOS/dev/dev_olga/src/config/axis_attribute_private.conf
r821 r1025 1 1 DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_begin) 2 2 DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_n) 3 4 /* LOCAL DATA*/ 5 DECLARE_ARRAY_PRIVATE(int , 1 , zoom_index) -
XIOS/dev/dev_olga/src/config/domain_attribute.conf
r953 r1025 9 9 10 10 /* LOCAL */ 11 DECLARE_ATTRIBUTE(int , ibegin )12 DECLARE_ATTRIBUTE(int , ni )11 DECLARE_ATTRIBUTE(int , ibegin, false) 12 DECLARE_ATTRIBUTE(int , ni, false) 13 13 14 14 /* LOCAL */ 15 DECLARE_ATTRIBUTE(int , jbegin )16 DECLARE_ATTRIBUTE(int , nj )15 DECLARE_ATTRIBUTE(int , jbegin, false) 16 DECLARE_ATTRIBUTE(int , nj, false) 17 17 18 18 19 DECLARE_ARRAY(int,1 , i_index )20 DECLARE_ARRAY(int,1 , j_index )19 DECLARE_ARRAY(int,1 , i_index, false) 20 DECLARE_ARRAY(int,1 , j_index, false) 21 21 22 22 /* LOCAL */ 23 DECLARE_ARRAY(bool, 1 , mask_1d )23 DECLARE_ARRAY(bool, 1 , mask_1d, false) 24 24 DECLARE_ARRAY(bool, 2 , mask_2d) 25 25 … … 28 28 29 29 /* LOCAL */ 30 DECLARE_ATTRIBUTE(int , data_ni )31 DECLARE_ATTRIBUTE(int , data_nj )32 DECLARE_ATTRIBUTE(int , data_ibegin )33 DECLARE_ATTRIBUTE(int , data_jbegin )30 DECLARE_ATTRIBUTE(int , data_ni, false) 31 DECLARE_ATTRIBUTE(int , data_nj, false) 32 DECLARE_ATTRIBUTE(int , data_ibegin, false) 33 DECLARE_ATTRIBUTE(int , data_jbegin, false) 34 34 35 35 /* LOCAL */ 36 DECLARE_ARRAY(int, 1 , data_i_index )37 DECLARE_ARRAY(int, 1, data_j_index )36 DECLARE_ARRAY(int, 1 , data_i_index, false) 37 DECLARE_ARRAY(int, 1, data_j_index, false) 38 38 39 39 /* LOCAL */ 40 DECLARE_ARRAY(double, 1, lonvalue_1d )41 DECLARE_ARRAY(double, 1, latvalue_1d )42 DECLARE_ARRAY(double, 2, lonvalue_2d )43 DECLARE_ARRAY(double, 2, latvalue_2d )40 DECLARE_ARRAY(double, 1, lonvalue_1d, false) 41 DECLARE_ARRAY(double, 1, latvalue_1d, false) 42 DECLARE_ARRAY(double, 2, lonvalue_2d, false) 43 DECLARE_ARRAY(double, 2, latvalue_2d, false) 44 44 45 45 DECLARE_ATTRIBUTE(int, nvertex) 46 DECLARE_ARRAY(double, 2, bounds_lon_1d )47 DECLARE_ARRAY(double, 2, bounds_lat_1d )48 DECLARE_ARRAY(double, 3, bounds_lon_2d )49 DECLARE_ARRAY(double, 3, bounds_lat_2d )46 DECLARE_ARRAY(double, 2, bounds_lon_1d, false) 47 DECLARE_ARRAY(double, 2, bounds_lat_1d, false) 48 DECLARE_ARRAY(double, 3, bounds_lon_2d, false) 49 DECLARE_ARRAY(double, 3, bounds_lat_2d, false) 50 50 51 51 DECLARE_ARRAY(double, 2, area) -
XIOS/dev/dev_olga/src/config/domain_attribute_private.conf
r821 r1025 18 18 DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_jbegin) 19 19 DECLARE_ATTRIBUTE_PRIVATE(int, global_zoom_nj) 20 21 DECLARE_ARRAY_PRIVATE(int , 1 , zoom_i_index, false) 22 DECLARE_ARRAY_PRIVATE(int , 1 , zoom_j_index, false) 23 //DECLARE_ARRAY_PRIVATE(double , 1 , areavalue, false) 24 //DECLARE_ARRAY_PRIVATE(int , 1 , lonvalue, false) 25 //DECLARE_ARRAY_PRIVATE(int , 1 , latvalue, false) 26 //DECLARE_ARRAY_PRIVATE(int , 2 , bounds_lonvalue, false) 27 //DECLARE_ARRAY_PRIVATE(int , 2 , bounds_latvalue, false) 28 -
XIOS/dev/dev_olga/src/declare_attribute.hpp
r778 r1025 3 3 4 4 /// ///////////////////////////// Macros ///////////////////////////// /// 5 #define DECLARE_ATTRIBUTE(type, name )\5 #define DECLARE_ATTRIBUTE(type, name, ...) \ 6 6 class name##_attr : public CAttributeTemplate<type> \ 7 7 { \ 8 8 public : \ 9 name##_attr(void) 9 name##_attr(void) \ 10 10 : CAttributeTemplate<type> \ 11 11 (#name, *CAttributeMap::Current) \ … … 13 13 type operator=(const type & value) \ 14 14 { return (CAttributeTemplate<type>::operator=(value)); } \ 15 virtual ~name##_attr(void) \ 15 virtual bool doSend() const { return helper(## __VA_ARGS__); } \ 16 bool helper(bool returnTrue=true) const { return returnTrue; } \ 17 virtual ~name##_attr(void) \ 16 18 { /* Ne rien faire de plus */ } \ 17 19 } name; 18 20 19 #define DECLARE_ATTRIBUTE_PRIVATE(type, name )\20 class name##_attr : public CAttributeTemplate<type> \21 #define DECLARE_ATTRIBUTE_PRIVATE(type, name, ...) \ 22 class name##_attr : public CAttributeTemplate<type> \ 21 23 { \ 22 24 public : \ 23 name##_attr(void) 25 name##_attr(void) \ 24 26 : CAttributeTemplate<type> \ 25 27 (#name, *CAttributeMap::Current) \ … … 29 31 virtual bool isPublic() const \ 30 32 { return false; } \ 33 virtual bool doSend() const { return helper(## __VA_ARGS__); } \ 34 bool helper(bool returnTrue=true) const { return returnTrue; } \ 31 35 virtual ~name##_attr(void) \ 32 36 { /* Ne rien faire de plus */ } \ 33 37 } name; 34 38 35 #define DECLARE_ARRAY(T_num, T_rank, name )\39 #define DECLARE_ARRAY(T_num, T_rank, name, ...) \ 36 40 class name##_attr : public CAttributeArray<T_num, T_rank> \ 37 41 { \ … … 39 43 using CAttributeArray<T_num, T_rank>::operator = ; \ 40 44 name##_attr(void) : CAttributeArray<T_num, T_rank> (#name, *CAttributeMap::Current) {} \ 45 virtual bool doSend() const { return helper(## __VA_ARGS__); } \ 46 bool helper(bool returnTrue=true) const { return returnTrue; } \ 41 47 virtual ~name##_attr(void) {} \ 42 48 } name; 43 49 44 #define DECLARE_ARRAY_PRIVATE(T_num, T_rank, name )\50 #define DECLARE_ARRAY_PRIVATE(T_num, T_rank, name, ...) \ 45 51 class name##_attr : public CAttributeArray<T_num, T_rank> \ 46 52 { \ … … 50 56 virtual bool isPublic() const \ 51 57 { return false; } \ 58 virtual bool doSend() const { return helper(## __VA_ARGS__); } \ 59 bool helper(bool returnTrue=true) const { return returnTrue; } \ 52 60 virtual ~name##_attr(void) {} \ 53 61 } name; 54 62 55 #define DECLARE_CLASS_ENUM(name )\56 class name##_attr : public CAttributeEnum<Enum_##name> 63 #define DECLARE_CLASS_ENUM(name, ...) \ 64 class name##_attr : public CAttributeEnum<Enum_##name> \ 57 65 { \ 58 66 public : \ 59 67 name##_attr(void) : CAttributeEnum<Enum_##name>(#name, *CAttributeMap::Current) { } \ 60 virtual ~name##_attr(void) {} \ 68 virtual bool doSend() const { return helper(## __VA_ARGS__); } \ 69 bool helper(bool returnTrue=true) const { return returnTrue; } \ 70 virtual ~name##_attr(void) {} \ 61 71 } name; 62 72 … … 71 81 DECLARE_CLASS_ENUM(name) 72 82 73 #define DECLARE_ENUM3(name,arg1,arg2,arg3) 83 #define DECLARE_ENUM3(name,arg1,arg2,arg3) \ 74 84 class Enum_##name \ 75 85 { \ 76 86 public: \ 77 enum t_enum { arg1=0, arg2, arg3} ; 87 enum t_enum { arg1=0, arg2, arg3} ; \ 78 88 const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3 } ; return enumStr ; } \ 79 89 int getSize(void) const { return 3 ; } \ … … 81 91 DECLARE_CLASS_ENUM(name) 82 92 83 #define DECLARE_ENUM4(name,arg1,arg2,arg3,arg4) 93 #define DECLARE_ENUM4(name,arg1,arg2,arg3,arg4) \ 84 94 class Enum_##name \ 85 95 { \ 86 96 public: \ 87 enum t_enum { arg1=0, arg2, arg3,arg4} ; 97 enum t_enum { arg1=0, arg2, arg3,arg4} ; \ 88 98 const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4 } ; return enumStr ; } \ 89 99 int getSize(void) const { return 4 ; } \ … … 91 101 DECLARE_CLASS_ENUM(name) 92 102 93 #define DECLARE_ENUM5(name,arg1,arg2,arg3,arg4,arg5) 103 #define DECLARE_ENUM5(name,arg1,arg2,arg3,arg4,arg5) \ 94 104 class Enum_##name \ 95 105 { \ 96 106 public: \ 97 enum t_enum { arg1=0, arg2, arg3,arg4,arg5} ; 107 enum t_enum { arg1=0, arg2, arg3,arg4,arg5} ; \ 98 108 const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5 } ; return enumStr ; } \ 99 109 int getSize(void) const { return 5 ; } \ … … 101 111 DECLARE_CLASS_ENUM(name) 102 112 103 #define DECLARE_ENUM6(name,arg1,arg2,arg3,arg4,arg5,arg6) 113 #define DECLARE_ENUM6(name,arg1,arg2,arg3,arg4,arg5,arg6) \ 104 114 class Enum_##name \ 105 115 { \ 106 116 public: \ 107 enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6} ; 117 enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6} ; \ 108 118 const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6 } ; return enumStr ; } \ 109 119 int getSize(void) const { return 6 ; } \ … … 111 121 DECLARE_CLASS_ENUM(name) 112 122 113 #define DECLARE_ENUM7(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7) 123 #define DECLARE_ENUM7(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \ 114 124 class Enum_##name \ 115 125 { \ 116 126 public: \ 117 enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7} ; 127 enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7} ; \ 118 128 const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7 } ; return enumStr ; } \ 119 129 int getSize(void) const { return 7 ; } \ … … 125 135 { \ 126 136 public: \ 127 enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8} ; 137 enum t_enum { arg1=0, arg2, arg3,arg4,arg5,arg6,arg7,arg8} ; \ 128 138 const char** getStr(void) const { static const char * enumStr[] = { #arg1, #arg2, #arg3,#arg4,#arg5,#arg6,#arg7,#arg8 } ; return enumStr ; } \ 129 139 int getSize(void) const { return 8 ; } \ -
XIOS/dev/dev_olga/src/distribution_client.cpp
r1021 r1025 11 11 namespace xios { 12 12 13 CDistributionClient::CDistributionClient(int rank, const GlobalLocalDataMap& globalLocalIndex)13 CDistributionClient::CDistributionClient(int rank, CGrid* grid, const GlobalLocalDataMap& globalLocalIndex) 14 14 : CDistribution(rank, 0) 15 15 , axisDomainOrder_() … … 34 34 ++idx; 35 35 } 36 37 std::vector<CDomain*> domList = grid->getDomains(); 38 std::vector<CAxis*> axisList = grid->getAxis(); 39 std::vector<CScalar*> scalarList = grid->getScalars(); 40 CArray<int,1> axisDomainOrder = grid->axis_domain_order; 41 42 int numElement = axisDomainOrder.numElements(); 43 // Because domain and axis can be in any order (axis1, domain1, axis2, axis3, ) 44 // their position should be specified. In axisDomainOrder, domain == true, axis == false 45 int dims = numElement; 46 idx = 0; 47 std::vector<int> indexMap(numElement); 48 for (int i = 0; i < numElement; ++i) 49 { 50 indexMap[i] = idx; 51 if (2 == axisDomainOrder(i)) 52 { 53 ++dims; 54 idx += 2; 55 } 56 else ++idx; 57 } 58 59 nGlob_.resize(dims); 60 61 // Data_n_index of domain or axis (For now, axis uses its size as data_n_index 62 dataNIndex_.resize(numElement); 63 dataDims_.resize(numElement); 64 isDataDistributed_ = false; 65 int domIndex = 0, axisIndex = 0, scalarIndex = 0; 66 for (idx = 0; idx < numElement; ++idx) 67 { 68 int eleDim = axisDomainOrder(idx); 69 70 // If this is a domain 71 if (2 == eleDim) 72 { 73 // On the j axis 74 nGlob_.at(indexMap[idx]+1) = domList[domIndex]->nj_glo.getValue(); 75 nGlob_.at(indexMap[idx]) = domList[domIndex]->ni_glo.getValue(); 76 dataNIndex_.at(idx) = domList[domIndex]->data_i_index.numElements(); 77 dataDims_.at(idx) = domList[domIndex]->data_dim.getValue(); 78 79 isDataDistributed_ |= domList[domIndex]->isDistributed(); 80 ++domIndex; 81 } 82 else if (1 == eleDim)// So it's an axis 83 { 84 nGlob_.at(indexMap[idx]) = axisList[axisIndex]->n_glo.getValue(); 85 dataNIndex_.at(idx) = axisList[axisIndex]->data_index.numElements(); 86 dataDims_.at(idx) = 1; 87 88 isDataDistributed_ |= axisList[axisIndex]->isDistributed(); 89 ++axisIndex; 90 } 91 else // scalar 92 { 93 nGlob_.at(indexMap[idx]) = 1; 94 dataNIndex_.at(idx) = 1; 95 dataDims_.at(idx) = 1; 96 97 isDataDistributed_ |= false; 98 ++scalarIndex; 99 } 100 } 101 36 102 } 37 103 … … 192 258 infoIndex_.resize(this->dims_); 193 259 194 // A trick to determine position of each domain in domainList195 int domIndex = 0, axisIndex = 0, scalarIndex = 0;196 idx = 0;197 198 260 elementLocalIndex_.resize(numElement_); 199 261 elementGlobalIndex_.resize(numElement_); … … 202 264 elementNLocal_.resize(numElement_); 203 265 elementNGlobal_.resize(numElement_); 266 204 267 elementNLocal_[0] = 1; 205 268 elementNGlobal_[0] = 1; 269 isDataDistributed_ = false; 270 206 271 size_t localSize = 1, globalSize = 1; 207 272 208 isDataDistributed_ = false; 273 // A trick to determine position of each domain in domainList 274 int domIndex = 0, axisIndex = 0, scalarIndex = 0; 275 idx = 0; 276 277 209 278 // Update all the vectors above 210 279 for (idx = 0; idx < numElement_; ++idx) -
XIOS/dev/dev_olga/src/distribution_client.hpp
r983 r1025 34 34 public: 35 35 /** Default constructor */ 36 CDistributionClient(int rank, const GlobalLocalDataMap& globalLocalIndex);36 CDistributionClient(int rank, CGrid* grid, const GlobalLocalDataMap& globalLocalIndex); 37 37 CDistributionClient(int rank, int dims, const CArray<size_t,1>& globalIndex = CArray<size_t,1>()); 38 38 CDistributionClient(int rank, CGrid* grid); -
XIOS/dev/dev_olga/src/distribution_server.cpp
r930 r1025 13 13 14 14 CDistributionServer::CDistributionServer(int rank, int dims, const CArray<size_t,1>& globalIndex) 15 : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_() 15 : CDistribution(rank, dims, globalIndex), nGlobal_(), nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_(), 16 globalIndexEachDimension_() 16 17 { 17 18 } … … 19 20 CDistributionServer::CDistributionServer(int rank, const std::vector<int>& nZoomBegin, 20 21 const std::vector<int>& nZoomSize, const std::vector<int>& nGlobal) 21 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 22 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_(), 23 globalIndexEachDimension_() 22 24 { 23 25 createGlobalIndex(); … … 29 31 const std::vector<int>& nGlobal) 30 32 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(nZoomBeginGlobal), 31 nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_() 33 nZoomSize_(nZoomSize), nZoomBegin_(nZoomBegin), globalLocalIndexMap_(), 34 globalIndexEachDimension_() 32 35 { 33 36 createGlobalIndex(); 37 } 38 39 CDistributionServer::CDistributionServer(int rank, 40 const std::vector<CArray<int,1> >& globalIndexEachDimension, 41 const std::vector<int>& nGlobal) 42 : CDistribution(rank, nGlobal.size()), nGlobal_(nGlobal), nZoomBeginGlobal_(), 43 nZoomSize_(), nZoomBegin_(), globalLocalIndexMap_(), 44 globalIndexEachDimension_(globalIndexEachDimension) 45 { 46 createGlobalIndexFromIndex(globalIndexEachDimension, nGlobal); 34 47 } 35 48 … … 88 101 } 89 102 103 void CDistributionServer::createGlobalIndexFromIndex(const std::vector<CArray<int,1> >& globalIndexOnEachDimension, 104 const std::vector<int>& nbGlobal) 105 { 106 size_t idx = 0, ssize = 1; 107 for (int i = 0; i < globalIndexOnEachDimension.size(); ++i) ssize *= globalIndexOnEachDimension[i].numElements(); 108 109 this->globalIndex_.resize(ssize); 110 size_t nbDim = nbGlobal.size(); 111 std::vector<int> idxLoop(nbDim,0); 112 std::vector<int> currentIndex(nbDim); 113 int innerLoopSize = globalIndexOnEachDimension[0].numElements(); 114 115 globalLocalIndexMap_.rehash(std::ceil(ssize/globalLocalIndexMap_.max_load_factor())); 116 while (idx<ssize) 117 { 118 for (int i = 0; i < nbDim-1; ++i) 119 { 120 if (idxLoop[i] == globalIndexOnEachDimension[i].numElements()) 121 { 122 idxLoop[i] = 0; 123 ++idxLoop[i+1]; 124 } 125 } 126 127 for (int i = 1; i < nbDim; ++i) 128 currentIndex[i] = globalIndexOnEachDimension[i](idxLoop[i]); 129 130 size_t mulDim, globalIndex; 131 for (int i = 0; i < innerLoopSize; ++i) 132 { 133 mulDim = 1; 134 globalIndex = globalIndexOnEachDimension[0](i); 135 136 for (int k = 1; k < nbDim; ++k) 137 { 138 mulDim *= nbGlobal[k-1]; 139 globalIndex += (currentIndex[k])*mulDim; 140 } 141 globalLocalIndexMap_[globalIndex] = idx; 142 this->globalIndex_(idx) = globalIndex; 143 144 ++idx; 145 } 146 idxLoop[0] += innerLoopSize; 147 } 148 149 } 150 90 151 /*! 91 152 Compute local index for writing data on server -
XIOS/dev/dev_olga/src/distribution_server.hpp
r983 r1025 30 30 const std::vector<int>& nZoomBeginGlobal, 31 31 const std::vector<int>& nGlobal); 32 CDistributionServer(int rank, 33 const std::vector<CArray<int,1> >& globalIndexEachDimension, 34 const std::vector<int>& nGlobal); 32 35 33 36 /** Default destructor */ … … 38 41 const std::vector<int>& getZoomSizeServer() const; 39 42 const GlobalLocalMap& getGlobalLocalIndex() const { return globalLocalIndexMap_; } 43 const std::vector<CArray<int,1> >& getGlobalIndexEachDimension() const; 40 44 41 45 virtual CArray<size_t,1> computeLocalIndex(const CArray<size_t,1>& globalIndex); … … 45 49 protected: 46 50 virtual void createGlobalIndex(); 51 52 void createGlobalIndexFromIndex(const std::vector<CArray<int,1> >& globalIndexOnEachDimension, 53 const std::vector<int>& nbGlobal); 47 54 48 55 protected: … … 54 61 std::vector<int> nZoomSize_; 55 62 std::vector<int> nZoomBegin_; 63 std::vector<CArray<int, 1> > globalIndexEachDimension_; 56 64 57 65 }; -
XIOS/dev/dev_olga/src/io/nc4_data_output.cpp
r1021 r1025 74 74 else setWrittenDomain(domid); 75 75 76 const std::vector<int>& local_size_write = domain->getLocalWriteSize(); 77 const std::vector<int>& global_size_write = domain->getGlobalWriteSize(); 78 const std::vector<int>& start_write = domain->getStartWriteIndex(); 79 const std::vector<int>& count_write = domain->getCountWriteIndex(); 80 int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 76 81 77 82 StdString dimXid, dimYid ; … … 135 140 bounds_latid = StdString("bounds_lat").append(appendDomid); 136 141 137 SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv);138 SuperClassWriter::addDimension(dimYid, domain->zoom_nj_srv);142 SuperClassWriter::addDimension(dimXid, local_size_write[0]); 143 SuperClassWriter::addDimension(dimYid, local_size_write[1]); 139 144 140 145 if (domain->hasBounds) … … 143 148 if (server->intraCommSize > 1) 144 149 { 145 this->writeLocalAttributes(domain->zoom_ibegin_srv, 146 domain->zoom_ni_srv, 147 domain->zoom_jbegin_srv, 148 domain->zoom_nj_srv, 150 this->writeLocalAttributes(0, count_write[0], 151 0, count_write[1], 149 152 appendDomid); 150 153 151 154 if (singleDomain) 152 155 this->writeLocalAttributes_IOIPSL(dimXid, dimYid, 153 domain->zoom_ibegin_srv, 154 domain->zoom_ni_srv, 155 domain->zoom_jbegin_srv, 156 domain->zoom_nj_srv, 156 0, count_write[0], 157 0, count_write[1], 157 158 domain->ni_glo,domain->nj_glo, 158 159 server->intraCommRank,server->intraCommSize); … … 223 224 { 224 225 case CDomain::type_attr::curvilinear : 225 SuperClassWriter::writeData(domain->latvalue _srv, latid, isCollective, 0);226 SuperClassWriter::writeData(domain->lonvalue _srv, lonid, isCollective, 0);226 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 227 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 227 228 break; 228 229 case CDomain::type_attr::rectilinear : 229 CArray<double,1> lat = domain->latvalue _srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ;230 CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,local_size_write[0])) ; 230 231 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0); 231 CArray<double,1> lon =domain->lonvalue_srv(Range(0,domain->zoom_ni_srv-1)) ;232 CArray<double,1> lon = domain->lonvalue(Range(0,local_size_write[1])) ; 232 233 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0); 233 234 break; … … 236 237 if (domain->hasBounds) 237 238 { 238 SuperClassWriter::writeData(domain->bounds_lon _srv, bounds_lonid, isCollective, 0);239 SuperClassWriter::writeData(domain->bounds_lat _srv, bounds_latid, isCollective, 0);239 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 240 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 240 241 } 241 242 } 242 243 243 244 if (domain->hasArea) 244 SuperClassWriter::writeData(domain->area _srv, areaId, isCollective, 0);245 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 245 246 246 247 SuperClassWriter::definition_start(); … … 250 251 case (ONE_FILE) : 251 252 { 252 SuperClassWriter::addDimension(dimXid, domain->global_zoom_ni);253 SuperClassWriter::addDimension(dimYid, domain->global_zoom_nj);253 SuperClassWriter::addDimension(dimXid, global_size_write[0]); 254 SuperClassWriter::addDimension(dimYid, global_size_write[1]); 254 255 255 256 if (domain->hasBounds) … … 325 326 else 326 327 { 327 start[1]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 328 start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin; 329 count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 328 // start[1]=domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 329 // start[0]=domain->zoom_jbegin_srv-domain->global_zoom_jbegin; 330 // count[1]=domain->zoom_ni_srv ; count[0]=domain->zoom_nj_srv ; 331 start[1]= start_write[0]; 332 start[0]= start_write[1]; 333 count[1]= count_write[0]; 334 count[0]= count_write[1]; 330 335 } 331 336 332 337 if (domain->hasLonLat) 333 338 { 334 SuperClassWriter::writeData(domain->latvalue _srv, latid, isCollective, 0,&start,&count);335 SuperClassWriter::writeData(domain->lonvalue _srv, lonid, isCollective, 0,&start,&count);339 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 340 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 336 341 } 337 342 break; … … 347 352 start[0]=0 ; 348 353 count[0]=0 ; 349 SuperClassWriter::writeData(domain->latvalue _srv, latid, isCollective, 0,&start,&count);350 SuperClassWriter::writeData(domain->lonvalue _srv, lonid, isCollective, 0,&start,&count);354 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 355 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 351 356 352 357 } 353 358 else 354 359 { 355 start[0]= domain->zoom_jbegin_srv-domain->global_zoom_jbegin;356 count[0]= domain->zoom_nj_srv;357 CArray<double,1> lat = domain->latvalue _srv(Range(fromStart,toEnd,domain->zoom_ni_srv)) ;360 start[0]= start_write[1]; 361 count[0]= count_write[1]; 362 CArray<double,1> lat = domain->latvalue(Range(fromStart,toEnd,count_write[0])) ; 358 363 SuperClassWriter::writeData(CArray<double,1>(lat.copy()), latid, isCollective, 0,&start,&count); 359 364 360 start[0]= domain->zoom_ibegin_srv-domain->global_zoom_ibegin;361 count[0]= domain->zoom_ni_srv;362 CArray<double,1> lon=domain->lonvalue _srv(Range(0,domain->zoom_ni_srv-1)) ;365 start[0]= start_write[0]; 366 count[0]= count_write[0]; 367 CArray<double,1> lon=domain->lonvalue(Range(0,count_write[1])) ; 363 368 SuperClassWriter::writeData(CArray<double,1>(lon.copy()), lonid, isCollective, 0,&start,&count); 364 369 } … … 380 385 { 381 386 start[2] = 0; 382 start[1] = domain->zoom_ibegin_srv - domain->global_zoom_ibegin;383 start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin;384 count[2] = domain->nvertex;385 count[1] = domain->zoom_ni_srv;386 count[0] = domain->zoom_nj_srv;387 start[1] = start_write[0]; 388 start[0] = start_write[1]; 389 count[2] = nvertex; 390 count[1] = count_write[0]; 391 count[0] = count_write[1]; 387 392 } 388 393 389 SuperClassWriter::writeData(domain->bounds_lon _srv, bounds_lonid, isCollective, 0, &start, &count);390 SuperClassWriter::writeData(domain->bounds_lat _srv, bounds_latid, isCollective, 0, &start, &count);394 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0, &start, &count); 395 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0, &start, &count); 391 396 } 392 397 … … 403 408 else 404 409 { 405 start[1] = domain->zoom_ibegin_srv - domain->global_zoom_ibegin; 406 start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin; 407 count[1] = domain->zoom_ni_srv; 408 count[0] = domain->zoom_nj_srv; 410 // start[1] = domain->zoom_ibegin_srv - domain->global_zoom_ibegin; 411 // start[0] = domain->zoom_jbegin_srv - domain->global_zoom_jbegin; 412 // count[1] = domain->zoom_ni_srv; 413 // count[0] = domain->zoom_nj_srv; 414 415 start[1]= start_write[0]; 416 start[0]= start_write[1]; 417 count[1]= count_write[0]; 418 count[0]= count_write[1]; 409 419 } 410 420 411 SuperClassWriter::writeData(domain->area _srv, areaId, isCollective, 0, &start, &count);421 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 412 422 } 413 423 … … 450 460 StdString domainName = domain->name; 451 461 domain->assignMesh(domainName, domain->nvertex); 452 domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue _srv, domain->latvalue_srv, domain->bounds_lon_srv, domain->bounds_lat_srv);462 domain->mesh->createMeshEpsilon(server->intraComm, domain->lonvalue, domain->latvalue, domain->bounds_lonvalue, domain->bounds_latvalue); 453 463 454 464 StdString node_x = domainName + "_node_x"; … … 471 481 StdString dimVertex = "n" + domainName + "_vertex"; 472 482 StdString dimTwo = "Two"; 483 484 const std::vector<int>& local_size_write = domain->getLocalWriteSize(); 485 const std::vector<int>& global_size_write = domain->getGlobalWriteSize(); 486 const std::vector<int>& start_write = domain->getStartWriteIndex(); 487 const std::vector<int>& count_write = domain->getCountWriteIndex(); 473 488 474 489 if (!SuperClassWriter::dimExist(dimTwo)) SuperClassWriter::addDimension(dimTwo, 2); … … 664 679 else 665 680 { 666 startNodes[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;667 countNodes[0] = domain->zoom_ni_srv ;681 startNodes[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 682 countNodes[0] = count_write[0]; //domain->zoom_ni_srv ; 668 683 } 669 684 … … 687 702 else 688 703 { 689 startEdges[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;690 countEdges[0] = domain->zoom_ni_srv;704 startEdges[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 705 countEdges[0] = count_write[0]; 691 706 startNodes[0] = domain->mesh->node_start; 692 707 countNodes[0] = domain->mesh->node_count; 693 startEdgeNodes[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;708 startEdgeNodes[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 694 709 startEdgeNodes[1] = 0; 695 countEdgeNodes[0] = domain->zoom_ni_srv;710 countEdgeNodes[0] = count_write[0]; //domain->zoom_ni_srv; 696 711 countEdgeNodes[1]= 2; 697 712 } … … 723 738 else 724 739 { 725 startFaces[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;726 countFaces[0] = domain->zoom_ni_srv ;740 startFaces[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 741 countFaces[0] = count_write[0]; //domain->zoom_ni_srv ; 727 742 startNodes[0] = domain->mesh->node_start; 728 743 countNodes[0] = domain->mesh->node_count; … … 737 752 countEdgeFaces[0] = domain->mesh->edge_count; 738 753 countEdgeFaces[1]= 2; 739 startFaceConctv[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;740 startFaceConctv[1] = 0; 741 countFaceConctv[0] = domain->zoom_ni_srv;754 startFaceConctv[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 755 startFaceConctv[1] = 0; //0; 756 countFaceConctv[0] = count_write[0]; //domain->zoom_ni_srv; 742 757 countFaceConctv[1] = domain->nvertex; 743 758 } … … 760 775 if (domain->nvertex == 2) 761 776 { 762 startEdges[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;763 countEdges[0] = domain->zoom_ni_srv ;764 startEdgeNodes[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;765 startEdgeNodes[1] = 0; 766 countEdgeNodes[0] = domain->zoom_ni_srv;777 startEdges[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 778 countEdges[0] = count_write[0]; //domain->zoom_ni_srv ; 779 startEdgeNodes[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 780 startEdgeNodes[1] = 0; //0; 781 countEdgeNodes[0] = count_write[0]; //domain->zoom_ni_srv; 767 782 countEdgeNodes[1]= 2; 768 783 SuperClassWriter::writeData(domain->mesh->edge_lat, edge_y, isCollective, 0, &startEdges, &countEdges); … … 785 800 SuperClassWriter::writeData(domain->mesh->edge_nodes, edge_nodes, isCollective, 0, &startEdgeNodes, &countEdgeNodes); 786 801 } 787 startFaces[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;788 countFaces[0] = domain->zoom_ni_srv;802 startFaces[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 803 countFaces[0] = count_write[0]; //domain->zoom_ni_srv; 789 804 startEdgeFaces[0] = domain->mesh->edge_start; 790 805 startEdgeFaces[1]= 0; 791 806 countEdgeFaces[0] = domain->mesh->edge_count; 792 807 countEdgeFaces[1]= 2; 793 startFaceConctv[0] = domain->zoom_ibegin_srv-domain->global_zoom_ibegin;794 startFaceConctv[1] = 0; 795 countFaceConctv[0] = domain->zoom_ni_srv;808 startFaceConctv[0] = start_write[0]; //domain->zoom_ibegin_srv-domain->global_zoom_ibegin; 809 startFaceConctv[1] = 0; //0; 810 countFaceConctv[0] = count_write[0]; //domain->zoom_ni_srv; 796 811 countFaceConctv[1]= domain->nvertex; 797 812 SuperClassWriter::writeData(domain->mesh->face_lat, face_y, isCollective, 0, &startFaces, &countFaces); … … 860 875 string areaId = "area" + appendDomid; 861 876 877 const std::vector<int>& local_size_write = domain->getLocalWriteSize(); 878 const std::vector<int>& global_size_write = domain->getGlobalWriteSize(); 879 const std::vector<int>& start_write = domain->getStartWriteIndex(); 880 const std::vector<int>& count_write = domain->getCountWriteIndex(); 881 int nvertex = (domain->nvertex.isEmpty()) ? 0 : domain->nvertex; 882 862 883 try 863 884 { … … 867 888 { 868 889 dim0.push_back(dimXid); 869 SuperClassWriter::addDimension(dimXid, domain->zoom_ni_srv);890 SuperClassWriter::addDimension(dimXid, local_size_write[0]); 870 891 871 892 lonid = StdString("lon").append(appendDomid); … … 905 926 if (domain->hasLonLat) 906 927 { 907 SuperClassWriter::writeData(domain->latvalue _srv, latid, isCollective, 0);908 SuperClassWriter::writeData(domain->lonvalue _srv, lonid, isCollective, 0);928 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0); 929 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0); 909 930 if (domain->hasBounds) 910 931 { 911 SuperClassWriter::writeData(domain->bounds_lon _srv, bounds_lonid, isCollective, 0);912 SuperClassWriter::writeData(domain->bounds_lat _srv, bounds_latid, isCollective, 0);932 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0); 933 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0); 913 934 } 914 935 } 915 936 916 937 if (domain->hasArea) 917 SuperClassWriter::writeData(domain->area _srv, areaId, isCollective, 0);938 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0); 918 939 919 940 SuperClassWriter::definition_start(); … … 928 949 bounds_latid = StdString("bounds_lat").append(appendDomid); 929 950 dim0.push_back(dimXid); 930 SuperClassWriter::addDimension(dimXid, domain->ni_glo);951 SuperClassWriter::addDimension(dimXid, global_size_write[0]); 931 952 if (domain->hasLonLat) 932 953 { … … 938 959 this->writeAxisAttributes(latid, "", "latitude", "Latitude", "degrees_north", domid); 939 960 if (domain->hasBounds) SuperClassWriter::addAttribute("bounds",bounds_latid, &latid); 940 if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, domain->nvertex);961 if (domain->hasBounds) SuperClassWriter::addDimension(dimVertId, nvertex); 941 962 } 942 963 dim0.clear(); … … 968 989 count[0]=0 ; 969 990 startBounds[1]=0 ; 970 countBounds[1]= domain->nvertex ;991 countBounds[1]=nvertex ; 971 992 startBounds[0]=0 ; 972 993 countBounds[0]=0 ; … … 974 995 else 975 996 { 976 start[0]= domain->zoom_ibegin_srv-domain->global_zoom_ibegin;977 count[0]= domain->zoom_ni_srv;978 startBounds[0]= domain->zoom_ibegin_srv-domain->global_zoom_ibegin;997 start[0]=start_write[0]; 998 count[0]=count_write[0]; 999 startBounds[0]=start_write[0]; 979 1000 startBounds[1]=0 ; 980 countBounds[0]= domain->zoom_ni_srv;981 countBounds[1]= domain->nvertex ;1001 countBounds[0]=count_write[0]; 1002 countBounds[1]=nvertex ; 982 1003 } 983 1004 984 1005 if (domain->hasLonLat) 985 1006 { 986 SuperClassWriter::writeData(domain->latvalue _srv, latid, isCollective, 0,&start,&count);987 SuperClassWriter::writeData(domain->lonvalue _srv, lonid, isCollective, 0,&start,&count);1007 SuperClassWriter::writeData(domain->latvalue, latid, isCollective, 0,&start,&count); 1008 SuperClassWriter::writeData(domain->lonvalue, lonid, isCollective, 0,&start,&count); 988 1009 if (domain->hasBounds) 989 1010 { 990 SuperClassWriter::writeData(domain->bounds_lon _srv, bounds_lonid, isCollective, 0,&startBounds,&countBounds);991 SuperClassWriter::writeData(domain->bounds_lat _srv, bounds_latid, isCollective, 0,&startBounds,&countBounds);1011 SuperClassWriter::writeData(domain->bounds_lonvalue, bounds_lonid, isCollective, 0,&startBounds,&countBounds); 1012 SuperClassWriter::writeData(domain->bounds_latvalue, bounds_latid, isCollective, 0,&startBounds,&countBounds); 992 1013 } 993 1014 } 994 1015 995 1016 if (domain->hasArea) 996 SuperClassWriter::writeData(domain->area _srv, areaId, isCollective, 0, &start, &count);1017 SuperClassWriter::writeData(domain->areavalue, areaId, isCollective, 0, &start, &count); 997 1018 998 1019 SuperClassWriter::definition_start(); … … 1021 1042 void CNc4DataOutput::writeAxis_(CAxis* axis) 1022 1043 { 1044 CContext* context = CContext::getCurrent(); 1045 CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer; 1046 1023 1047 if (axis->IsWritten(this->filename)) return; 1024 1048 axis->checkAttributes(); 1025 int zoom_size_srv = axis->zoom_size_srv; 1026 int zoom_begin_srv = axis->zoom_begin_srv; 1027 int zoom_size = (MULTI_FILE == SuperClass::type) ? zoom_size_srv 1028 : axis->global_zoom_n; 1029 int zoom_begin = (MULTI_FILE == SuperClass::type) ? zoom_begin_srv 1030 : axis->global_zoom_begin; 1031 1032 if ((0 == zoom_size_srv) && (MULTI_FILE == SuperClass::type)) return; 1049 1050 int local_size_write = axis->getLocalWriteSize(); 1051 int global_size_write = axis->getGlobalWriteSize(); 1052 int start_write = axis->getStartWriteIndex(); 1053 int count_write = axis->getCountWriteIndex(); 1054 1055 if ((0 == local_size_write) && (MULTI_FILE == SuperClass::type)) return; 1033 1056 1034 1057 std::vector<StdString> dims; … … 1039 1062 try 1040 1063 { 1041 SuperClassWriter::addDimension(axisid, zoom_size);1064 SuperClassWriter::addDimension(axisid, global_size_write); 1042 1065 if (axis->hasValue) 1043 1066 { … … 1079 1102 case MULTI_FILE: 1080 1103 { 1081 CArray<double,1> axis_value( zoom_size_srv);1082 for (int i = 0; i < zoom_size_srv; i++) axis_value(i) = axis->value_srv(i);1104 CArray<double,1> axis_value(local_size_write); 1105 for (int i = 0; i < local_size_write; i++) axis_value(i) = axis->value(i); 1083 1106 SuperClassWriter::writeData(axis_value, axisid, isCollective, 0); 1084 1107 1085 1108 if (!axis->bounds.isEmpty()) 1086 SuperClassWriter::writeData(axis->bound _srv, axisBoundsId, isCollective, 0);1109 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0); 1087 1110 1088 1111 SuperClassWriter::definition_start(); … … 1092 1115 case ONE_FILE: 1093 1116 { 1094 CArray<double,1> axis_value( zoom_size_srv);1095 axis_value = axis->value _srv;1117 CArray<double,1> axis_value(count_write); 1118 axis_value = axis->value; 1096 1119 1097 1120 std::vector<StdSize> start(1), startBounds(2) ; 1098 1121 std::vector<StdSize> count(1), countBounds(2) ; 1099 start[0] = startBounds[0] = zoom_begin_srv-axis->global_zoom_begin;1100 count[0] = countBounds[0] = zoom_size_srv;1122 start[0] = startBounds[0] = start_write; 1123 count[0] = countBounds[0] = count_write; 1101 1124 startBounds[1] = 0; 1102 1125 countBounds[1] = 2; … … 1104 1127 1105 1128 if (!axis->bounds.isEmpty()) 1106 SuperClassWriter::writeData(axis->bound _srv, axisBoundsId, isCollective, 0, &startBounds, &countBounds);1129 SuperClassWriter::writeData(axis->bounds, axisBoundsId, isCollective, 0, &startBounds, &countBounds); 1107 1130 1108 1131 SuperClassWriter::definition_start(); … … 2064 2087 case (ONE_FILE) : 2065 2088 { 2089 // const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); 2090 // const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); 2091 // const std::vector<int>& nZoomSizeServer = grid->getDistributionServer()->getZoomSizeServer(); 2092 2093 // std::vector<StdSize> start, count; 2094 2095 // if (field->getUseCompressedOutput()) 2096 // { 2097 // if (grid->isCompressible()) 2098 // { 2099 // start.push_back(grid->getOffsetWrittenIndexes()); 2100 // count.push_back(grid->getNumberWrittenIndexes()); 2101 // } 2102 // else 2103 // { 2104 // CArray<int,1> axisDomainOrder = grid->axis_domain_order; 2105 // std::vector<StdString> domainList = grid->getDomainList(); 2106 // std::vector<StdString> axisList = grid->getAxisList(); 2107 // int numElement = axisDomainOrder.numElements(); 2108 // int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 2109 // int idx = nZoomBeginGlobal.size() - 1; 2110 2111 // start.reserve(nZoomBeginGlobal.size()); 2112 // count.reserve(nZoomBeginGlobal.size()); 2113 2114 2115 // for (int i = numElement - 1; i >= 0; --i) 2116 // { 2117 // if (2 == axisDomainOrder(i)) 2118 // { 2119 // CDomain* domain = CDomain::get(domainList[idxDomain]); 2120 2121 // if (domain->isCompressible()) 2122 // { 2123 // start.push_back(domain->getOffsetWrittenIndexes()); 2124 // count.push_back(domain->getNumberWrittenIndexes()); 2125 // idx -= 2; 2126 // } 2127 // else 2128 // { 2129 // if ((domain->type) != CDomain::type_attr::unstructured) 2130 // { 2131 // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2132 // count.push_back(nZoomSizeServer[idx]); 2133 // } 2134 // --idx; 2135 // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2136 // count.push_back(nZoomSizeServer[idx]); 2137 // --idx; 2138 // } 2139 // --idxDomain; 2140 // } 2141 // else if (1 == axisDomainOrder(i)) 2142 // { 2143 // CAxis* axis = CAxis::get(axisList[idxAxis]); 2144 2145 // if (axis->isCompressible()) 2146 // { 2147 // start.push_back(axis->getOffsetWrittenIndexes()); 2148 // count.push_back(axis->getNumberWrittenIndexes()); 2149 // } 2150 // else 2151 // { 2152 // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2153 // count.push_back(nZoomSizeServer[idx]); 2154 // } 2155 2156 // --idxAxis; 2157 // --idx; 2158 // } 2159 // } 2160 // } 2066 2161 const std::vector<int>& nZoomBeginGlobal = grid->getDistributionServer()->getZoomBeginGlobal(); 2067 2162 const std::vector<int>& nZoomBeginServer = grid->getDistributionServer()->getZoomBeginServer(); … … 2135 2230 } 2136 2231 } 2137 } 2232 } 2138 2233 } 2139 2234 else 2140 2235 { 2141 2236 // CArray<int,1> axisDomainOrder = grid->axis_domain_order; 2237 // std::vector<StdString> domainList = grid->getDomainList(); 2238 // std::vector<StdString> axisList = grid->getAxisList(); 2239 // int numElement = axisDomainOrder.numElements(); 2240 // int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 2241 // int idx = nZoomBeginGlobal.size() - 1; 2242 2243 // start.reserve(nZoomBeginGlobal.size()); 2244 // count.reserve(nZoomBeginGlobal.size()); 2245 2246 // for (int i = numElement - 1; i >= 0; --i) 2247 // { 2248 // if (2 == axisDomainOrder(i)) 2249 // { 2250 // CDomain* domain = CDomain::get(domainList[idxDomain]); 2251 // if ((domain->type) != CDomain::type_attr::unstructured) 2252 // { 2253 // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2254 // count.push_back(nZoomSizeServer[idx]); 2255 // } 2256 // --idx ; 2257 // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2258 // count.push_back(nZoomSizeServer[idx]); 2259 // --idx ; 2260 // --idxDomain; 2261 // } 2262 // else if (1 == axisDomainOrder(i)) 2263 // { 2264 // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2265 // count.push_back(nZoomSizeServer[idx]); 2266 // --idx; 2267 // } 2268 // else 2269 // { 2270 // if (1 == axisDomainOrder.numElements()) 2271 // { 2272 // start.push_back(0); 2273 // count.push_back(1); 2274 // } 2275 // --idx; 2276 // } 2142 2277 CArray<int,1> axisDomainOrder = grid->axis_domain_order; 2143 2278 std::vector<StdString> domainList = grid->getDomainList(); … … 2145 2280 int numElement = axisDomainOrder.numElements(); 2146 2281 int idxDomain = domainList.size() - 1, idxAxis = axisList.size() - 1; 2147 int idx = nZoomBeginGlobal.size() - 1;2282 int idx = domainList.size() * 2 + axisList.size() - 1;// nZoomBeginGlobal.size() - 1; 2148 2283 2149 2284 start.reserve(nZoomBeginGlobal.size()); … … 2157 2292 if ((domain->type) != CDomain::type_attr::unstructured) 2158 2293 { 2159 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2160 count.push_back(nZoomSizeServer[idx]); 2294 // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2295 // count.push_back(nZoomSizeServer[idx]); 2296 start.push_back((domain->getStartWriteIndex())[idx]); 2297 count.push_back((domain->getCountWriteIndex())[idx]); 2161 2298 } 2162 2299 --idx ; 2163 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2164 count.push_back(nZoomSizeServer[idx]); 2300 // start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2301 // count.push_back(nZoomSizeServer[idx]); 2302 start.push_back((domain->getStartWriteIndex())[idx]); 2303 count.push_back((domain->getCountWriteIndex())[idx]); 2165 2304 --idx ; 2166 2305 --idxDomain; … … 2168 2307 else if (1 == axisDomainOrder(i)) 2169 2308 { 2170 start.push_back(nZoomBeginServer[idx] - nZoomBeginGlobal[idx]); 2171 count.push_back(nZoomSizeServer[idx]); 2309 CAxis* axis = CAxis::get(axisList[idxAxis]); 2310 start.push_back(axis->getStartWriteIndex()); 2311 count.push_back(axis->getCountWriteIndex()); 2172 2312 --idx; 2313 --idxAxis; 2173 2314 } 2174 2315 else -
XIOS/dev/dev_olga/src/node/axis.cpp
r1009 r1025 131 131 } 132 132 133 /*! 134 Returns the start of indexes written by each server. 135 \return the start of indexes written by each server 136 */ 137 int CAxis::getStartWriteIndex() const 138 { 139 return start_write_index_; 140 } 141 142 /*! 143 Returns the count of indexes written by each server. 144 \return the count of indexes written by each server 145 */ 146 int CAxis::getCountWriteIndex() const 147 { 148 return count_write_index_; 149 } 150 151 /*! 152 Returns the local data written by each server. 153 */ 154 int CAxis::getLocalWriteSize() const 155 { 156 return local_write_size_; 157 } 158 159 /*! 160 Returns the global data written by all server. 161 */ 162 int CAxis::getGlobalWriteSize() const 163 { 164 return global_write_size_; 165 } 166 133 167 //---------------------------------------------------------------- 134 168 … … 166 200 { 167 201 // size estimation for sendDistributedValue 168 std::map<int, std::vector<size_t> >::const_iterator it, ite = indSrv_.end();202 boost::unordered_map<int, vector<size_t> >::const_iterator it, ite = indSrv_.end(); 169 203 for (it = indSrv_.begin(); it != ite; ++it) 170 204 { … … 292 326 if (global_zoom_begin.isEmpty()) global_zoom_begin.setValue(0); 293 327 if (global_zoom_n.isEmpty()) global_zoom_n.setValue(n_glo.getValue()); 328 if (zoom_index.isEmpty()) 329 { 330 zoom_index.setValue(index.getValue()); 331 } 294 332 } 295 333 … … 342 380 switch(event.type) 343 381 { 344 case EVENT_ID_SERVER_ATTRIBUT : 345 recvServerAttribut(event); 346 return true; 347 break; 348 case EVENT_ID_INDEX: 349 recvIndex(event); 382 // case EVENT_ID_SERVER_ATTRIBUT : 383 // recvServerAttribut(event); 384 // return true; 385 // break; 386 // case EVENT_ID_INDEX: 387 // recvIndex(event); 388 // return true; 389 // break; 390 case EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES: 391 recvNonDistributedAttributes(event); 350 392 return true; 351 393 break; 352 case EVENT_ID_DISTRIBUTED_VALUE: 353 recvDistributedValue(event); 354 return true; 355 break; 356 case EVENT_ID_NON_DISTRIBUTED_VALUE: 357 recvNonDistributedValue(event); 394 case EVENT_ID_DISTRIBUTED_ATTRIBUTES: 395 recvDistributedAttributes(event); 358 396 return true; 359 397 break; … … 383 421 if (context->hasClient) 384 422 { 385 if ( n.getValue() != n_glo.getValue()) computeConnectedServer(globalDim, orderPositionInGrid, distType);423 if (index.numElements() != n_glo.getValue()) computeConnectedServer(globalDim, orderPositionInGrid, distType); 386 424 } 387 425 … … 398 436 399 437 if (this->isChecked) return; 400 if (context->hasClient) 401 { 402 sendServerAttribut(globalDim, orderPositionInGrid, distType); 403 if (hasValue) sendValue(); 404 } 438 if (context->hasClient) sendAttributes(); 405 439 406 440 this->isChecked = true; 407 441 } 408 442 409 void CAxis::send Value()410 { 411 if ( n.getValue() == n_glo.getValue())412 sendNonDistributed Value();443 void CAxis::sendAttributes() 444 { 445 if (index.numElements() == n_glo.getValue()) 446 sendNonDistributedAttributes(); 413 447 else 414 sendDistributed Value();448 sendDistributedAttributes(); 415 449 } 416 450 … … 419 453 { 420 454 CContext* context = CContext::getCurrent(); 421 CContextClient* client = context->client;455 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 422 456 int nbServer = client->serverSize; 423 457 int range, clientSize = client->clientSize; 424 458 int rank = client->clientRank; 425 459 426 size_t ni = this->n.getValue();427 size_t ibegin = this->begin.getValue();428 size_t zoom_end = global_zoom_begin+global_zoom_n-1;429 size_t nZoomCount = 0;460 // size_t ni = this->n.getValue(); 461 // size_t ibegin = this->begin.getValue(); 462 // size_t zoom_end = global_zoom_begin+global_zoom_n-1; 463 // size_t nZoomCount = 0; 430 464 size_t nbIndex = index.numElements(); 431 465 for (size_t idx = 0; idx < nbIndex; ++idx) 432 466 { 433 size_t globalIndex = index(idx); 434 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 435 } 436 437 CArray<size_t,1> globalIndexAxis(nbIndex); 438 std::vector<size_t> globalAxisZoom(nZoomCount); 439 nZoomCount = 0; 440 for (size_t idx = 0; idx < nbIndex; ++idx) 441 { 442 size_t globalIndex = index(idx); 443 globalIndexAxis(idx) = globalIndex; 444 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 445 { 446 globalAxisZoom[nZoomCount] = globalIndex; 447 ++nZoomCount; 448 } 449 } 450 451 std::set<int> writtenInd; 452 if (isCompressible_) 453 { 454 for (int idx = 0; idx < data_index.numElements(); ++idx) 455 { 456 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 457 458 if (ind >= 0 && ind < ni && mask(ind)) 459 { 460 ind += ibegin; 461 if (ind >= global_zoom_begin && ind <= zoom_end) 462 writtenInd.insert(ind); 463 } 464 } 465 } 466 467 CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer); 467 globalLocalIndexMap_[index(idx)] = idx; 468 // size_t globalIndex = index(idx); 469 // if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 470 } 471 472 // CArray<size_t,1> globalIndexAxis(nbIndex); 473 // std::vector<size_t> globalAxisZoom(nZoomCount); 474 // nZoomCount = 0; 475 // for (size_t idx = 0; idx < nbIndex; ++idx) 476 // { 477 // size_t globalIndex = index(idx); 478 // globalIndexAxis(idx) = globalIndex; 479 // if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 480 // { 481 // globalAxisZoom[nZoomCount] = globalIndex; 482 // ++nZoomCount; 483 // } 484 // } 485 486 // std::set<int> writtenInd; 487 // if (isCompressible_) 488 // { 489 // for (int idx = 0; idx < data_index.numElements(); ++idx) 490 // { 491 // int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 492 493 // if (ind >= 0 && ind < ni && mask(ind)) 494 // { 495 // ind += ibegin; 496 // if (ind >= global_zoom_begin && ind <= zoom_end) 497 // writtenInd.insert(ind); 498 // } 499 // } 500 // } 501 502 CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer, distType); 468 503 int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 469 504 CClientServerMapping::GlobalIndexMap globalIndexAxisOnServer; … … 493 528 } 494 529 530 CArray<size_t,1> globalIndex(index.numElements()); 531 for (size_t idx = 0; idx < globalIndex.numElements(); ++idx) 532 globalIndex(idx) = index(idx); 533 495 534 CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 496 535 serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 497 536 CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 498 clientServerMap->computeServerIndexMapping(globalIndex Axis);537 clientServerMap->computeServerIndexMapping(globalIndex); 499 538 globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 500 539 delete clientServerMap; … … 514 553 } 515 554 516 CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 517 ite = globalIndexAxisOnServer.end(); 518 std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 519 iteVec = (globalAxisZoom).end(); 520 indSrv_.clear(); 521 indWrittenSrv_.clear(); 522 for (; it != ite; ++it) 523 { 524 int rank = it->first; 525 const std::vector<size_t>& globalIndexTmp = it->second; 526 int nb = globalIndexTmp.size(); 527 528 for (int i = 0; i < nb; ++i) 529 { 530 if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 531 { 532 indSrv_[rank].push_back(globalIndexTmp[i]); 533 } 534 535 if (writtenInd.count(globalIndexTmp[i])) 536 { 537 indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 538 } 539 } 540 } 555 indSrv_.swap(globalIndexAxisOnServer); 556 557 // CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 558 // ite = globalIndexAxisOnServer.end(); 559 CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_.begin(), 560 ite = indSrv_.end(); 561 // std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 562 // iteVec = (globalAxisZoom).end(); 563 // indSrv_.clear(); 564 // indWrittenSrv_.clear(); 565 // for (; it != ite; ++it) 566 // { 567 // int rank = it->first; 568 // const std::vector<size_t>& globalIndexTmp = it->second; 569 // int nb = globalIndexTmp.size(); 570 571 // for (int i = 0; i < nb; ++i) 572 // { 573 // if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 574 // { 575 // indSrv_[rank].push_back(globalIndexTmp[i]); 576 // } 577 578 // if (writtenInd.count(globalIndexTmp[i])) 579 // { 580 // indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 581 // } 582 // } 583 // } 541 584 542 585 connectedServerRank_.clear(); 543 for (it = globalIndexAxisOnServer.begin(); it != ite; ++it) {586 for (it = indSrv_.begin(); it != ite; ++it) { 544 587 connectedServerRank_.push_back(it->first); 545 588 } 546 589 547 if (!indSrv_.empty())548 {549 std::map<int, vector<size_t> >::const_iterator itIndSrv = indSrv_.begin(),550 iteIndSrv = indSrv_.end();551 connectedServerRank_.clear();552 for (; itIndSrv != iteIndSrv; ++itIndSrv)553 connectedServerRank_.push_back(itIndSrv->first);554 }590 // if (!indSrv_.empty()) 591 // { 592 // std::map<int, vector<size_t> >::const_iterator itIndSrv = indSrv_.begin(), 593 // iteIndSrv = indSrv_.end(); 594 // connectedServerRank_.clear(); 595 // for (; itIndSrv != iteIndSrv; ++itIndSrv) 596 // connectedServerRank_.push_back(itIndSrv->first); 597 // } 555 598 nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 556 599 } 557 600 558 void CAxis::sendNonDistributedValue() 601 602 // void CAxis::computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 603 // CServerDistributionDescription::ServerDistributionType distType) 604 // { 605 // CContext* context = CContext::getCurrent(); 606 // CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 607 // int nbServer = client->serverSize; 608 // int range, clientSize = client->clientSize; 609 // int rank = client->clientRank; 610 611 // size_t ni = this->n.getValue(); 612 // size_t ibegin = this->begin.getValue(); 613 // size_t zoom_end = global_zoom_begin+global_zoom_n-1; 614 // size_t nZoomCount = 0; 615 // size_t nbIndex = index.numElements(); 616 // for (size_t idx = 0; idx < nbIndex; ++idx) 617 // { 618 // size_t globalIndex = index(idx); 619 // if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 620 // } 621 622 // CArray<size_t,1> globalIndexAxis(nbIndex); 623 // std::vector<size_t> globalAxisZoom(nZoomCount); 624 // nZoomCount = 0; 625 // for (size_t idx = 0; idx < nbIndex; ++idx) 626 // { 627 // size_t globalIndex = index(idx); 628 // globalIndexAxis(idx) = globalIndex; 629 // if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 630 // { 631 // globalAxisZoom[nZoomCount] = globalIndex; 632 // ++nZoomCount; 633 // } 634 // } 635 636 // std::set<int> writtenInd; 637 // if (isCompressible_) 638 // { 639 // for (int idx = 0; idx < data_index.numElements(); ++idx) 640 // { 641 // int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 642 643 // if (ind >= 0 && ind < ni && mask(ind)) 644 // { 645 // ind += ibegin; 646 // if (ind >= global_zoom_begin && ind <= zoom_end) 647 // writtenInd.insert(ind); 648 // } 649 // } 650 // } 651 652 // CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer); 653 // int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 654 // CClientServerMapping::GlobalIndexMap globalIndexAxisOnServer; 655 // if (distributedDimensionOnServer == orderPositionInGrid) // So we have distributed axis on client side and also on server side* 656 // { 657 // std::vector<int> nGlobAxis(1); 658 // nGlobAxis[0] = n_glo.getValue(); 659 660 // size_t globalSizeIndex = 1, indexBegin, indexEnd; 661 // for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 662 // indexBegin = 0; 663 // if (globalSizeIndex <= clientSize) 664 // { 665 // indexBegin = rank%globalSizeIndex; 666 // indexEnd = indexBegin; 667 // } 668 // else 669 // { 670 // for (int i = 0; i < clientSize; ++i) 671 // { 672 // range = globalSizeIndex / clientSize; 673 // if (i < (globalSizeIndex%clientSize)) ++range; 674 // if (i == client->clientRank) break; 675 // indexBegin += range; 676 // } 677 // indexEnd = indexBegin + range - 1; 678 // } 679 680 // CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 681 // serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 682 // CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 683 // clientServerMap->computeServerIndexMapping(globalIndexAxis); 684 // globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 685 // delete clientServerMap; 686 // } 687 // else 688 // { 689 // std::vector<size_t> globalIndexServer(n_glo.getValue()); 690 // for (size_t idx = 0; idx < n_glo.getValue(); ++idx) 691 // { 692 // globalIndexServer[idx] = idx; 693 // } 694 695 // for (int idx = 0; idx < nbServer; ++idx) 696 // { 697 // globalIndexAxisOnServer[idx] = globalIndexServer; 698 // } 699 // } 700 701 // CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 702 // ite = globalIndexAxisOnServer.end(); 703 // std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 704 // iteVec = (globalAxisZoom).end(); 705 // indSrv_.clear(); 706 // indWrittenSrv_.clear(); 707 // for (; it != ite; ++it) 708 // { 709 // int rank = it->first; 710 // const std::vector<size_t>& globalIndexTmp = it->second; 711 // int nb = globalIndexTmp.size(); 712 713 // for (int i = 0; i < nb; ++i) 714 // { 715 // if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 716 // { 717 // indSrv_[rank].push_back(globalIndexTmp[i]); 718 // } 719 720 // if (writtenInd.count(globalIndexTmp[i])) 721 // { 722 // indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 723 // } 724 // } 725 // } 726 727 // connectedServerRank_.clear(); 728 // for (it = globalIndexAxisOnServer.begin(); it != ite; ++it) { 729 // connectedServerRank_.push_back(it->first); 730 // } 731 732 // if (!indSrv_.empty()) 733 // { 734 // std::map<int, vector<size_t> >::const_iterator itIndSrv = indSrv_.begin(), 735 // iteIndSrv = indSrv_.end(); 736 // connectedServerRank_.clear(); 737 // for (; itIndSrv != iteIndSrv; ++itIndSrv) 738 // connectedServerRank_.push_back(itIndSrv->first); 739 // } 740 // nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 741 // } 742 743 void CAxis::sendNonDistributedAttributes() 559 744 { 560 745 CContext* context = CContext::getCurrent(); 561 CContextClient* client = context->client; 562 CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_VALUE); 563 564 int zoom_end = global_zoom_begin + global_zoom_n - 1; 565 int nb = 0; 566 for (size_t idx = 0; idx < n; ++idx) 567 { 568 size_t globalIndex = begin + idx; 569 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nb; 570 } 571 572 int nbWritten = 0; 573 if (isCompressible_) 574 { 575 for (int idx = 0; idx < data_index.numElements(); ++idx) 576 { 577 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, n); 578 579 if (ind >= 0 && ind < n && mask(ind)) 580 { 581 ind += begin; 582 if (ind >= global_zoom_begin && ind <= zoom_end) 583 ++nbWritten; 584 } 585 } 586 } 587 588 CArray<double,1> val(nb); 589 nb = 0; 590 for (size_t idx = 0; idx < n; ++idx) 591 { 592 size_t globalIndex = begin + idx; 593 if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 594 { 595 val(nb) = value(idx); 596 ++nb; 597 } 598 } 599 600 CArray<int, 1> writtenInd(nbWritten); 601 nbWritten = 0; 602 if (isCompressible_) 603 { 604 for (int idx = 0; idx < data_index.numElements(); ++idx) 605 { 606 int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, n); 607 608 if (ind >= 0 && ind < n && mask(ind)) 609 { 610 ind += begin; 611 if (ind >= global_zoom_begin && ind <= zoom_end) 612 { 613 writtenInd(nbWritten) = ind; 614 ++nbWritten; 615 } 616 } 617 } 746 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 747 748 CEventClient event(getType(), EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES); 749 size_t nbIndex = index.numElements(); 750 size_t nbDataIndex = 0; 751 752 for (int idx = 0; idx < data_index.numElements(); ++idx) 753 { 754 int ind = data_index(idx); 755 if (ind >= 0 && ind < nbIndex) ++nbDataIndex; 756 } 757 758 CArray<int,1> dataIndex(nbDataIndex); 759 nbDataIndex = 0; 760 for (int idx = 0; idx < data_index.numElements(); ++idx) 761 { 762 int ind = data_index(idx); 763 if (ind >= 0 && ind < nbIndex) 764 { 765 dataIndex(nbDataIndex) = ind; 766 ++nbDataIndex; 767 } 618 768 } 619 769 620 770 if (client->isServerLeader()) 621 { 771 { 622 772 std::list<CMessage> msgs; 623 773 … … 628 778 CMessage& msg = msgs.back(); 629 779 msg << this->getId(); 630 msg << val; 631 if (isCompressible_) 632 msg << writtenInd; 780 msg << index.getValue() << dataIndex << zoom_index.getValue() << mask.getValue(); 781 msg << hasValue; 782 if (hasValue) msg << value.getValue(); 783 784 msg << hasBounds_; 785 if (hasBounds_) msg << bounds.getValue(); 786 633 787 event.push(*itRank, 1, msg); 634 788 } … … 638 792 } 639 793 640 void CAxis::sendDistributedValue(void) 794 void CAxis::recvNonDistributedAttributes(CEventServer& event) 795 { 796 list<CEventServer::SSubEvent>::iterator it; 797 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 798 { 799 CBufferIn* buffer = it->buffer; 800 string axisId; 801 *buffer >> axisId; 802 get(axisId)->recvNonDistributedAttributes(it->rank, *buffer); 803 } 804 } 805 806 void CAxis::recvNonDistributedAttributes(int rank, CBufferIn& buffer) 807 { 808 CArray<int,1> tmp_index, tmp_data_index, tmp_zoom_index; 809 CArray<bool,1> tmp_mask; 810 CArray<double,1> tmp_val; 811 CArray<double,2> tmp_bnds; 812 813 buffer >> tmp_index; 814 index.reference(tmp_index); 815 buffer >> tmp_data_index; 816 data_index.reference(tmp_data_index); 817 buffer >> tmp_zoom_index; 818 zoom_index.reference(tmp_zoom_index); 819 buffer >> tmp_mask; 820 mask.reference(tmp_mask); 821 buffer >> hasValue; 822 if (hasValue) 823 { 824 buffer >> tmp_val; 825 value.reference(tmp_val); 826 } 827 828 buffer >> hasBounds_; 829 if (hasBounds_) 830 { 831 buffer >> tmp_bnds; 832 bounds.reference(tmp_bnds); 833 } 834 835 { 836 count_write_index_ = zoom_index.numElements(); 837 start_write_index_ = 0; 838 local_write_size_ = count_write_index_; 839 global_write_size_ = count_write_index_; 840 } 841 } 842 843 void CAxis::sendDistributedAttributes(void) 641 844 { 642 845 int ns, n, i, j, ind, nv, idx; 643 846 CContext* context = CContext::getCurrent(); 644 CContextClient* client=context->client; 645 646 // send value for each connected server 647 CEventClient eventIndex(getType(), EVENT_ID_INDEX); 648 CEventClient eventVal(getType(), EVENT_ID_DISTRIBUTED_VALUE); 649 650 list<CMessage> list_msgsIndex, list_msgsVal; 651 list<CArray<int,1> > list_indi; 652 list<CArray<int,1> > list_writtenInd; 847 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 848 849 CEventClient eventData(getType(), EVENT_ID_DISTRIBUTED_ATTRIBUTES); 850 851 list<CMessage> listData; 852 list<CArray<int,1> > list_indi, list_dataInd, list_zoomInd; 853 list<CArray<bool,1> > list_mask; 653 854 list<CArray<double,1> > list_val; 654 855 list<CArray<double,2> > list_bounds; 655 856 656 std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 857 int nbIndex = index.numElements(); 858 CArray<int,1> dataIndex(nbIndex); 859 dataIndex = -1; 860 for (int idx = 0; idx < data_index.numElements(); ++idx) 861 { 862 if (0 <= data_index(idx) && data_index(idx) < nbIndex) 863 dataIndex(idx) = data_index(idx); 864 } 865 866 boost::unordered_map<int, std::vector<size_t> >::const_iterator it, iteMap; 657 867 iteMap = indSrv_.end(); 658 868 for (int k = 0; k < connectedServerRank_.size(); ++k) … … 660 870 int nbData = 0; 661 871 int rank = connectedServerRank_[k]; 872 int nbSendingClient = nbConnectedClients_[rank]; 662 873 it = indSrv_.find(rank); 663 874 if (iteMap != it) … … 665 876 666 877 list_indi.push_back(CArray<int,1>(nbData)); 667 list_val.push_back(CArray<double,1>(nbData)); 878 list_dataInd.push_back(CArray<int,1>(nbData)); 879 list_zoomInd.push_back(CArray<int,1>(nbData)); 880 list_mask.push_back(CArray<bool,1>(nbData)); 881 882 883 if (hasValue) 884 list_val.push_back(CArray<double,1>(nbData)); 668 885 669 886 if (hasBounds_) … … 673 890 674 891 CArray<int,1>& indi = list_indi.back(); 675 CArray<double,1>& val = list_val.back(); 892 CArray<int,1>& dataIndi = list_dataInd.back(); 893 CArray<int,1>& zoomIndi = list_zoomInd.back(); 894 CArray<bool,1>& maskIndi = list_mask.back(); 676 895 677 896 for (n = 0; n < nbData; ++n) 678 897 { 679 898 idx = static_cast<int>(it->second[n]); 680 ind = idx - begin;681 682 val(n) = value(ind);683 899 indi(n) = idx; 900 901 ind = globalLocalIndexMap_[idx]; 902 dataIndi(n) = dataIndex(ind); 903 maskIndi(n) = mask(ind); 904 zoomIndi(n) = zoom_index(ind); 905 906 if (hasValue) 907 { 908 CArray<double,1>& val = list_val.back(); 909 val(n) = value(ind); 910 } 684 911 685 912 if (hasBounds_) … … 691 918 } 692 919 693 list_msgsIndex.push_back(CMessage()); 694 list_msgsIndex.back() << this->getId() << list_indi.back(); 695 696 if (isCompressible_) 697 { 698 std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 699 list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 700 CArray<int,1>& writtenInd = list_writtenInd.back(); 701 702 for (n = 0; n < writtenInd.numElements(); ++n) 703 writtenInd(n) = writtenIndSrc[n]; 704 705 list_msgsIndex.back() << writtenInd; 706 } 707 708 list_msgsVal.push_back(CMessage()); 709 list_msgsVal.back() << this->getId() << list_val.back(); 710 920 listData.push_back(CMessage()); 921 listData.back() << this->getId() 922 << list_indi.back() << list_dataInd.back() << list_zoomInd.back() << list_mask.back() 923 << hasValue; 924 if (hasValue) 925 listData.back() << list_val.back(); 926 listData.back() << hasBounds_; 711 927 if (hasBounds_) 712 { 713 list_msgsVal.back() << list_bounds.back(); 714 } 715 716 eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 717 eventVal.push(rank, nbConnectedClients_[rank], list_msgsVal.back()); 718 } 719 720 client->sendEvent(eventIndex); 721 client->sendEvent(eventVal); 722 } 723 724 void CAxis::recvIndex(CEventServer& event) 725 { 726 CAxis* axis; 928 listData.back() << list_bounds.back(); 929 930 eventData.push(rank, nbConnectedClients_[rank], listData.back()); 931 } 932 933 client->sendEvent(eventData); 934 } 935 936 void CAxis::recvDistributedAttributes(CEventServer& event) 937 { 938 string axisId; 939 vector<int> ranks; 940 vector<CBufferIn*> buffers; 727 941 728 942 list<CEventServer::SSubEvent>::iterator it; 729 943 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 730 944 { 945 ranks.push_back(it->rank); 731 946 CBufferIn* buffer = it->buffer; 732 string axisId;733 947 *buffer >> axisId; 734 axis = get(axisId); 735 axis->recvIndex(it->rank, *buffer); 736 } 737 738 if (axis->isCompressible_) 739 { 740 std::sort(axis->indexesToWrite.begin(), axis->indexesToWrite.end()); 741 948 buffers.push_back(buffer); 949 } 950 get(axisId)->recvDistributedAttributes(ranks, buffers); 951 } 952 953 void CAxis::recvDistributedAttributes(vector<int>& ranks, vector<CBufferIn*> buffers) 954 { 955 int nbReceived = ranks.size(); 956 vector<CArray<int,1> > vec_indi(nbReceived), vec_dataInd(nbReceived), vec_zoomInd(nbReceived); 957 vector<CArray<bool,1> > vec_mask(nbReceived); 958 vector<CArray<double,1> > vec_val(nbReceived); 959 vector<CArray<double,2> > vec_bounds(nbReceived); 960 961 for (int idx = 0; idx < nbReceived; ++idx) 962 { 963 CBufferIn& buffer = *buffers[idx]; 964 buffer >> vec_indi[idx]; 965 buffer >> vec_dataInd[idx]; 966 buffer >> vec_zoomInd[idx]; 967 buffer >> vec_mask[idx]; 968 969 buffer >> hasValue; 970 if (hasValue) 971 buffer >> vec_val[idx]; 972 buffer >> hasBounds_; 973 if (hasBounds_) 974 buffer >> vec_bounds[idx]; 975 } 976 977 int nbData = 0; 978 for (int idx = 0; idx < nbReceived; ++idx) 979 { 980 nbData += vec_indi[idx].numElements(); 981 } 982 983 index.resize(nbData); 984 CArray<int,1> nonCompressedData(nbData); 985 mask.resize(nbData); 986 if (hasValue) 987 value.resize(nbData); 988 if (hasBounds_) 989 bounds.resize(2,nbData); 990 991 nbData = 0; 992 for (int idx = 0; idx < nbReceived; ++idx) 993 { 994 CArray<int,1>& indi = vec_indi[idx]; 995 CArray<int,1>& dataIndi = vec_dataInd[idx]; 996 CArray<bool,1>& maskIndi = vec_mask[idx]; 997 int nb = indi.numElements(); 998 for (int n = 0; n < nb; ++n) 999 { 1000 index(nbData) = indi(n); 1001 nonCompressedData(nbData) = (0 <= dataIndi(n)) ? nbData : -1; 1002 mask(nbData) = maskIndi(n); 1003 if (hasValue) 1004 value(nbData) = vec_val[idx](n); 1005 if (hasBounds_) 1006 { 1007 bounds(0,nbData) = vec_bounds[idx](0,n); 1008 bounds(1,nbData) = vec_bounds[idx](1,n); 1009 } 1010 ++nbData; 1011 } 1012 } 1013 1014 int nbIndex = index.numElements(); 1015 int nbCompressedData = 0; 1016 for (int idx = 0; idx < nonCompressedData.numElements(); ++idx) 1017 { 1018 if (0 <= nonCompressedData(idx) && nonCompressedData(idx) < nbIndex) 1019 ++nbCompressedData; 1020 } 1021 1022 data_index.resize(nbCompressedData); 1023 nbCompressedData = 0; 1024 for (int idx = 0; idx < nonCompressedData.numElements(); ++idx) 1025 { 1026 if (0 <= nonCompressedData(idx) && nonCompressedData(idx) < nbIndex) 1027 { 1028 data_index(nbCompressedData) = nonCompressedData(idx); 1029 ++nbCompressedData; 1030 } 1031 } 1032 1033 int nbZoomIndex = 0; 1034 for (int idx = 0; idx < nbReceived; ++idx) 1035 { 1036 nbZoomIndex += vec_zoomInd[idx].numElements(); 1037 } 1038 1039 zoom_index.resize(nbZoomIndex); 1040 nbZoomIndex = 0; 1041 CArray<int,1>& zoom_Index_Tmp = this->zoom_index; 1042 for (int idx = 0; idx < nbReceived; ++idx) 1043 { 1044 CArray<int,1> tmp = zoom_Index_Tmp(Range(nbZoomIndex, nbZoomIndex + vec_zoomInd[idx].numElements()-1)); 1045 tmp = vec_zoomInd[idx]; 1046 1047 nbZoomIndex += vec_zoomInd[idx].numElements(); 1048 } 1049 1050 1051 { 742 1052 CContextServer* server = CContext::getCurrent()->server; 743 axis->numberWrittenIndexes_ = axis->indexesToWrite.size(); 744 MPI_Allreduce(&axis->numberWrittenIndexes_, &axis->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 745 MPI_Scan(&axis->numberWrittenIndexes_, &axis->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 746 axis->offsetWrittenIndexes_ -= axis->numberWrittenIndexes_; 747 } 748 } 749 750 void CAxis::recvIndex(int rank, CBufferIn& buffer) 751 { 752 buffer >> indiSrv_[rank]; 753 754 if (isCompressible_) 755 { 756 CArray<int, 1> writtenIndexes; 757 buffer >> writtenIndexes; 758 indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 759 for (int i = 0; i < writtenIndexes.numElements(); ++i) 760 indexesToWrite.push_back(writtenIndexes(i)); 761 } 762 } 763 764 void CAxis::recvDistributedValue(CEventServer& event) 765 { 766 list<CEventServer::SSubEvent>::iterator it; 767 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 768 { 769 CBufferIn* buffer = it->buffer; 770 string axisId; 771 *buffer >> axisId; 772 get(axisId)->recvDistributedValue(it->rank, *buffer); 773 } 774 } 775 776 void CAxis::recvDistributedValue(int rank, CBufferIn& buffer) 777 { 778 CArray<int,1> &indi = indiSrv_[rank]; 779 CArray<double,1> val; 780 CArray<double,2> boundsVal; 781 782 buffer >> val; 783 if (hasBounds_) buffer >> boundsVal; 784 785 int i, j, ind_srv; 786 for (int ind = 0; ind < indi.numElements(); ++ind) 787 { 788 i = indi(ind); 789 ind_srv = i - zoom_begin_srv; 790 value_srv(ind_srv) = val(ind); 791 if (hasBounds_) 792 { 793 bound_srv(0,ind_srv) = boundsVal(0, ind); 794 bound_srv(1,ind_srv) = boundsVal(1, ind); 795 } 796 } 797 } 798 799 void CAxis::recvNonDistributedValue(CEventServer& event) 800 { 801 CAxis* axis; 802 803 list<CEventServer::SSubEvent>::iterator it; 804 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 805 { 806 CBufferIn* buffer = it->buffer; 807 string axisId; 808 *buffer >> axisId; 809 axis = get(axisId); 810 axis->recvNonDistributedValue(it->rank, *buffer); 811 } 812 813 if (axis->isCompressible_) 814 { 815 std::sort(axis->indexesToWrite.begin(), axis->indexesToWrite.end()); 816 817 axis->numberWrittenIndexes_ = axis->totalNumberWrittenIndexes_ = axis->indexesToWrite.size(); 818 axis->offsetWrittenIndexes_ = 0; 819 } 820 } 821 822 void CAxis::recvNonDistributedValue(int rank, CBufferIn& buffer) 823 { 824 CArray<double,1> val; 825 buffer >> val; 826 827 for (int ind = 0; ind < val.numElements(); ++ind) 828 { 829 value_srv(ind) = val(ind); 830 if (hasBounds_) 831 { 832 bound_srv(0,ind) = bounds(0,ind); 833 bound_srv(1,ind) = bounds(1,ind); 834 } 835 } 836 837 if (isCompressible_) 838 { 839 CArray<int, 1> writtenIndexes; 840 buffer >> writtenIndexes; 841 indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 842 for (int i = 0; i < writtenIndexes.numElements(); ++i) 843 indexesToWrite.push_back(writtenIndexes(i)); 1053 count_write_index_ = zoom_index.numElements(); 1054 MPI_Scan(&count_write_index_, &start_write_index_, 1, MPI_INT, MPI_SUM, server->intraComm); 1055 global_write_size_ = start_write_index_; 1056 start_write_index_ -= count_write_index_; 1057 local_write_size_ = count_write_index_; 844 1058 } 845 1059 } … … 849 1063 // { 850 1064 // CContext* context = CContext::getCurrent(); 851 // CContextClient* client = context->client; 852 // int nbServer = client->serverSize; 1065 1066 // CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer 1067 // : context->client; 1068 1069 1070 // int nbServer = contextClientTmp->serverSize; 853 1071 854 1072 // CServerDistributionDescription serverDescription(globalDim, nbServer); … … 858 1076 // std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 859 1077 1078 // globalDimGrid.resize(globalDim.size()); 1079 // for (int idx = 0; idx < globalDim.size(); ++idx) globalDimGrid(idx) = globalDim[idx]; 1080 860 1081 // CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 861 // if (c lient->isServerLeader())1082 // if (contextClientTmp->isServerLeader()) 862 1083 // { 863 1084 // std::list<CMessage> msgs; 864 1085 865 // const std::list<int>& ranks = c lient->getRanksServerLeader();1086 // const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 866 1087 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 867 1088 // { … … 877 1098 // msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 878 1099 // msg << isCompressible_; 1100 // msg << orderPositionInGrid; 1101 // msg << globalDimGrid; 879 1102 880 1103 // event.push(*itRank,1,msg); 881 1104 // } 882 // c lient->sendEvent(event);1105 // contextClientTmp->sendEvent(event); 883 1106 // } 884 // else c lient->sendEvent(event);1107 // else contextClientTmp->sendEvent(event); 885 1108 // } 886 1109 887 void CAxis::sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid,888 CServerDistributionDescription::ServerDistributionType distType)889 {890 CContext* context = CContext::getCurrent();891 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;892 for (int i = 0; i < nbSrvPools; ++i)1110 // void CAxis::recvServerAttribut(CEventServer& event) 1111 // { 1112 // CBufferIn* buffer = event.subEvents.begin()->buffer; 1113 // string axisId; 1114 // *buffer >> axisId; 1115 // get(axisId)->recvServerAttribut(*buffer); 893 1116 { 894 1117 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] 895 : context->client; 896 int nbServer = contextClientTmp->serverSize; 897 898 CServerDistributionDescription serverDescription(globalDim, nbServer); 899 serverDescription.computeServerDistribution(); 900 901 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 902 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 903 904 globalDimGrid.resize(globalDim.size()); 905 for (int idx = 0; idx < globalDim.size(); ++idx) globalDimGrid(idx) = globalDim[idx]; 906 907 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 908 if (contextClientTmp->isServerLeader()) 909 { 910 std::list<CMessage> msgs; 911 912 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 913 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 914 { 915 // Use const int to ensure CMessage holds a copy of the value instead of just a reference 916 const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 917 const int ni = serverDimensionSizes[*itRank][orderPositionInGrid]; 918 const int end = begin + ni - 1; 919 920 msgs.push_back(CMessage()); 921 CMessage& msg = msgs.back(); 922 msg << this->getId(); 923 msg << ni << begin << end; 924 msg << global_zoom_begin.getValue() << global_zoom_n.getValue(); 925 msg << isCompressible_; 926 msg << orderPositionInGrid; 927 msg << globalDimGrid; 928 929 event.push(*itRank,1,msg); 930 } 931 contextClientTmp->sendEvent(event); 932 } 933 else contextClientTmp->sendEvent(event); 934 } 935 } 936 937 void CAxis::recvServerAttribut(CEventServer& event) 938 { 939 CBufferIn* buffer = event.subEvents.begin()->buffer; 940 string axisId; 941 *buffer >> axisId; 942 get(axisId)->recvServerAttribut(*buffer); 943 944 CContext* context = CContext::getCurrent(); 945 if (context->hasClient && context->hasServer) 946 { 947 std::vector<int> globalDim(get(axisId)->globalDimGrid.numElements()); 948 for (int idx = 0; idx < globalDim.size(); ++idx) globalDim[idx] = get(axisId)->globalDimGrid(idx); 949 get(axisId)->sendServerAttribut(globalDim, get(axisId)->orderPosInGrid, 950 CServerDistributionDescription::BAND_DISTRIBUTION); 951 } 952 } 953 954 void CAxis::recvServerAttribut(CBufferIn& buffer) 955 { 956 int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_n_tmp; 957 958 buffer >> ni_srv >> begin_srv >> end_srv; 959 buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp; 960 buffer >> isCompressible_; 961 buffer >> orderPosInGrid; 962 buffer >> globalDimGrid; 963 964 global_zoom_begin = global_zoom_begin_tmp; 965 global_zoom_n = global_zoom_n_tmp; 966 int global_zoom_end = global_zoom_begin + global_zoom_n - 1; 967 968 zoom_begin_srv = global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 969 zoom_end_srv = global_zoom_end < end_srv ? global_zoom_end : end_srv ; 970 zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 971 972 if (zoom_size_srv<=0) 973 { 974 zoom_begin_srv = 0; zoom_end_srv = 0; zoom_size_srv = 0; 975 } 976 977 if (n_glo == n) 978 { 979 zoom_begin_srv = global_zoom_begin; 980 zoom_end_srv = global_zoom_end; //zoom_end; 981 zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 982 } 983 if (hasValue) 984 { 985 value_srv.resize(zoom_size_srv); 986 if (hasBounds_) bound_srv.resize(2,zoom_size_srv); 987 } 988 } 1118 } 1119 1120 // CContext* context = CContext::getCurrent(); 1121 // if (context->hasClient && context->hasServer) 1122 // { 1123 // std::vector<int> globalDim(get(axisId)->globalDimGrid.numElements()); 1124 // for (int idx = 0; idx < globalDim.size(); ++idx) globalDim[idx] = get(axisId)->globalDimGrid(idx); 1125 // get(axisId)->sendServerAttribut(globalDim, get(axisId)->orderPosInGrid, 1126 // CServerDistributionDescription::BAND_DISTRIBUTION); 1127 // } 1128 // } 1129 1130 // void CAxis::recvServerAttribut(CBufferIn& buffer) 1131 // { 1132 // int ni_srv, begin_srv, end_srv, global_zoom_begin_tmp, global_zoom_n_tmp; 1133 1134 // buffer >> ni_srv >> begin_srv >> end_srv; 1135 // buffer >> global_zoom_begin_tmp >> global_zoom_n_tmp; 1136 // buffer >> isCompressible_; 1137 // buffer >> orderPosInGrid; 1138 // buffer >> globalDimGrid; 1139 1140 // global_zoom_begin = global_zoom_begin_tmp; 1141 // global_zoom_n = global_zoom_n_tmp; 1142 // int global_zoom_end = global_zoom_begin + global_zoom_n - 1; 1143 1144 // zoom_begin_srv = global_zoom_begin > begin_srv ? global_zoom_begin : begin_srv ; 1145 // zoom_end_srv = global_zoom_end < end_srv ? global_zoom_end : end_srv ; 1146 // zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 1147 1148 // if (zoom_size_srv<=0) 1149 // { 1150 // zoom_begin_srv = 0; zoom_end_srv = 0; zoom_size_srv = 0; 1151 // } 1152 1153 // if (n_glo == n) 1154 // { 1155 // zoom_begin_srv = global_zoom_begin; 1156 // zoom_end_srv = global_zoom_end; //zoom_end; 1157 // zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 1158 // } 1159 // if (hasValue) 1160 // { 1161 // value_srv.resize(zoom_size_srv); 1162 // if (hasBounds_) bound_srv.resize(2,zoom_size_srv); 1163 // } 1164 // } 989 1165 990 1166 CTransformation<CAxis>* CAxis::addTransformation(ETranformationType transType, const StdString& id) … … 1007 1183 { 1008 1184 return transformationMap_; 1009 }1010 1011 /*!1012 Check the validity of all transformations applied on axis1013 This functions is called AFTER all inherited attributes are solved1014 */1015 void CAxis::checkTransformations()1016 {1017 TransMapTypes::const_iterator itb = transformationMap_.begin(), it,1018 ite = transformationMap_.end();1019 // for (it = itb; it != ite; ++it)1020 // {1021 // (it->second)->checkValid(this);1022 // }1023 1185 } 1024 1186 -
XIOS/dev/dev_olga/src/node/axis.hpp
r987 r1025 48 48 EVENT_ID_INDEX, 49 49 EVENT_ID_DISTRIBUTED_VALUE, 50 EVENT_ID_NON_DISTRIBUTED_VALUE 50 EVENT_ID_NON_DISTRIBUTED_VALUE, 51 EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES, 52 EVENT_ID_DISTRIBUTED_ATTRIBUTES 51 53 } ; 52 54 … … 76 78 int getOffsetWrittenIndexes() const; 77 79 80 int getStartWriteIndex() const; 81 int getCountWriteIndex() const; 82 int getLocalWriteSize() const; 83 int getGlobalWriteSize() const; 84 78 85 std::map<int, StdSize> getAttributesBufferSize(); 79 86 … … 101 108 static ENodeType GetType(void); 102 109 103 void sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid,104 CServerDistributionDescription::ServerDistributionType distType);110 // void sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, 111 // CServerDistributionDescription::ServerDistributionType distType); 105 112 static bool dispatchEvent(CEventServer& event); 106 113 static void recvServerAttribut(CEventServer& event); 107 void recvServerAttribut(CBufferIn& buffer) ;114 // void recvServerAttribut(CBufferIn& buffer) ; 108 115 void checkAttributesOnClient(); 109 116 void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, … … 134 141 void checkMask(); 135 142 void checkZoom(); 136 void checkBounds(); 137 void checkTransformations(); 138 void sendValue(); 143 void checkBounds(); 144 void sendAttributes(); 139 145 void computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 140 146 CServerDistributionDescription::ServerDistributionType distType); 141 void sendDistributedValue();142 void sendNonDistributedValue();143 147 144 static void recvIndex(CEventServer& event); 145 static void recvDistributedValue(CEventServer& event); 146 static void recvNonDistributedValue(CEventServer& event); 147 void recvIndex(int rank, CBufferIn& buffer); 148 void recvDistributedValue(int rank, CBufferIn& buffer); 149 void recvNonDistributedValue(int rank, CBufferIn& buffer); 148 void sendNonDistributedAttributes(void); 149 void sendDistributedAttributes(void); 150 151 static void recvNonDistributedAttributes(CEventServer& event); 152 static void recvDistributedAttributes(CEventServer& event); 153 void recvNonDistributedAttributes(int rank, CBufferIn& buffer); 154 void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers); 150 155 151 156 void setTransformations(const TransMapTypes&); … … 161 166 bool isCompressible_; 162 167 std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 163 std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server168 boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 164 169 std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 170 boost::unordered_map<size_t,size_t> globalLocalIndexMap_; 165 171 std::vector<int> indexesToWrite; 166 172 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; … … 168 174 std::map<int, CArray<int,1> > indiSrv_; 169 175 bool hasBounds_; 176 177 int start_write_index_; 178 int count_write_index_; 179 int local_write_size_; 180 int global_write_size_; 170 181 171 182 private: -
XIOS/dev/dev_olga/src/node/context.cpp
r1021 r1025 29 29 , idServer_(), client(0), server(0) 30 30 // , clientPrimServer(0), serverPrimServer(0) 31 , allProcessed(false) 31 32 { /* Ne rien faire de plus */ } 32 33 … … 37 38 , idServer_(), client(0), server(0) 38 39 // , clientPrimServer(0), serverPrimServer(0) 40 , allProcessed(false) 39 41 { /* Ne rien faire de plus */ } 40 42 … … 475 477 } 476 478 479 480 void CContext::postProcessingGlobalAttributes() 481 { 482 if (allProcessed) return; 483 484 if (hasClient) 485 { 486 // After xml is parsed, there are some more works with post processing 487 postProcessing(); 488 } 489 490 setClientServerBuffer(); 491 492 if (hasClient) 493 { 494 // Send all attributes of current context to server 495 this->sendAllAttributesToServer(); 496 497 // Send all attributes of current calendar 498 CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 499 500 // We have enough information to send to server 501 // First of all, send all enabled files 502 sendEnabledFiles(); 503 504 // Then, send all enabled fields 505 sendEnabledFields(); 506 507 // At last, we have all info of domain and axis, then send them 508 sendRefDomainsAxis(); 509 510 // After that, send all grid (if any) 511 sendRefGrid(); 512 513 // We have a xml tree on the server side and now, it should be also processed 514 sendPostProcessing(); 515 } 516 allProcessed = true; 517 } 518 519 void CContext::sendPostProcessingGlobalAttributes() 520 { 521 // Use correct context client to send message 522 CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client; 523 CEventClient event(getType(),EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES); 524 525 if (contextClientTmp->isServerLeader()) 526 { 527 CMessage msg; 528 msg<<this->getIdServer(); 529 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 530 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 531 event.push(*itRank,1,msg); 532 contextClientTmp->sendEvent(event); 533 } 534 else contextClientTmp->sendEvent(event); 535 } 536 537 void CContext::recvPostProcessingGlobalAttributes(CEventServer& event) 538 { 539 CBufferIn* buffer=event.subEvents.begin()->buffer; 540 string id; 541 *buffer>>id; 542 // get(id)->recvPostProcessingGlobalAttributes(*buffer); 543 } 544 545 void CContext::recvPostProcessingGlobalAttributes(CBufferIn& buffer) 546 { 547 // CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar(); 548 postProcessingGlobalAttributes(); 549 } 550 477 551 /*! 478 552 \brief Close all the context defintion and do processing data … … 487 561 { 488 562 // There is nothing client need to send to server 489 if (hasClient) 490 { 491 // After xml is parsed, there are some more works with post processing 492 postProcessing(); 493 } 494 495 setClientServerBuffer(); 496 497 if (hasClient) 498 { 499 // Send all attributes of current context to server 500 this->sendAllAttributesToServer(); 501 502 // Send all attributes of current calendar 503 CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 504 505 // We have enough information to send to server 506 // First of all, send all enabled files 507 sendEnabledFiles(); 508 509 // Then, send all enabled fields 510 sendEnabledFields(); 511 512 // At last, we have all info of domain and axis, then send them 513 sendRefDomainsAxis(); 514 515 // After that, send all grid (if any) 516 sendRefGrid(); 517 518 // We have a xml tree on the server side and now, it should be also processed 519 sendPostProcessing(); 520 } 563 // if (hasClient) 564 // if (hasClient && !hasServer) 565 // if (hasClient) 566 // { 567 // // After xml is parsed, there are some more works with post processing 568 // postProcessing(); 569 // } 570 571 // setClientServerBuffer(); 572 573 // // if (hasClient && !hasServer) 574 // if (hasClient) 575 // { 576 // // Send all attributes of current context to server 577 // this->sendAllAttributesToServer(); 578 579 // // Send all attributes of current calendar 580 // CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 581 582 // // We have enough information to send to server 583 // // First of all, send all enabled files 584 // sendEnabledFiles(); 585 586 // // Then, send all enabled fields 587 // sendEnabledFields(); 588 589 // // At last, we have all info of domain and axis, then send them 590 // sendRefDomainsAxis(); 591 592 // // After that, send all grid (if any) 593 // sendRefGrid(); 594 595 // // // We have a xml tree on the server side and now, it should be also processed 596 // sendPostProcessing(); 597 // } 521 598 522 599 523 600 // Now tell server that it can process all messages from client 524 if (hasClient) this->sendCloseDefinition(); 601 // if (hasClient) this->sendCloseDefinition(); 602 postProcessingGlobalAttributes(); 603 604 if (hasClient) sendPostProcessingGlobalAttributes(); 525 605 526 606 // There are some processings that should be done after all of above. For example: check mask or index 607 this->buildFilterGraphOfEnabledFields(); 608 527 609 if (hasClient && !hasServer) 528 610 { 529 this->buildFilterGraphOfEnabledFields(); // references are resolved here (access xml file)611 // this->buildFilterGraphOfEnabledFields(); // references are resolved here (access xml file) 530 612 buildFilterGraphOfFieldsWithReadAccess(); 531 this->solveAllRefOfEnabledFields(true);613 // this->solveAllRefOfEnabledFields(true); 532 614 } 533 615 616 // if (hasClient) this->solveAllRefOfEnabledFields(true); 617 this->processGridEnabledFields(); 618 if (hasClient) this->sendProcessingGridOfEnabledFields(); 619 // if (hasClient) // We have a xml tree on the server side and now, it should be also processed 620 // sendPostProcessing(); 534 621 // // Now tell server that it can process all messages from client 535 622 //// if (hasClient && !hasServer) this->sendCloseDefinition(); 536 //if (hasClient) this->sendCloseDefinition();623 if (hasClient) this->sendCloseDefinition(); 537 624 538 625 // Nettoyage de l'arborescence … … 564 651 (void)this->enabledReadModeFiles[i]->readAttributesOfEnabledFieldsInReadMode(); 565 652 } 653 654 void CContext::solveAllEnabledFields() 655 { 656 int size = this->enabledFiles.size(); 657 for (int i = 0; i < size; ++i) 658 { 659 this->enabledFiles[i]->solveOnlyRefOfEnabledFields(false); 660 } 661 662 for (int i = 0; i < size; ++i) 663 { 664 this->enabledFiles[i]->generateNewTransformationGridDest(); 665 } 666 } 667 668 void CContext::processGridEnabledFields() 669 { 670 int size = this->enabledFiles.size(); 671 for (int i = 0; i < size; ++i) 672 { 673 this->enabledFiles[i]->checkGridOfEnabledFields(); 674 this->enabledFiles[i]->sendGridOfEnabledFields(); 675 } 676 } 677 678 566 679 567 680 void CContext::solveOnlyRefOfEnabledFields(bool sendToServer) … … 754 867 recvRegistry(event); 755 868 return true; 756 break; 757 869 break; 870 case EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES: 871 recvPostProcessingGlobalAttributes(event); 872 return true; 873 break; 874 case EVENT_ID_PROCESS_GRID_ENABLED_FIELDS: 875 recvProcessingGridOfEnabledFields(event); 876 return true; 877 break; 758 878 default : 759 879 ERROR("bool CContext::dispatchEvent(CEventServer& event)", … … 802 922 *buffer>>id; 803 923 get(id)->closeDefinition(); 804 if (get(id)->hasClient && get(id)->hasServer)805 {806 get(id)->sendCloseDefinition();807 }924 // if (get(id)->hasClient && get(id)->hasServer) 925 // { 926 // get(id)->sendCloseDefinition(); 927 // } 808 928 } 809 929 … … 833 953 else contextClientTmp->sendEvent(event); 834 954 } 835 836 // if (!hasServer)837 // {838 // if (client->isServerLeader())839 // {840 // CMessage msg;841 // msg<<this->getIdServer()<<step;842 // const std::list<int>& ranks = client->getRanksServerLeader();843 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)844 // event.push(*itRank,1,msg);845 // client->sendEvent(event);846 // }847 // else client->sendEvent(event);848 // }849 // else850 // {851 // if (clientPrimServer->isServerLeader())852 // {853 // CMessage msg;854 // msg<<this->getIdServer()<<step;855 // const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();856 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)857 // event.push(*itRank,1,msg);858 // clientPrimServer->sendEvent(event);859 // }860 // else clientPrimServer->sendEvent(event);861 // }862 955 } 863 956 … … 907 1000 else contextClientTmp->sendEvent(event); 908 1001 } 909 // if (!hasServer)910 // {911 // if (client->isServerLeader())912 // {913 // CMessage msg;914 // msg<<this->getIdServer();915 // const std::list<int>& ranks = client->getRanksServerLeader();916 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)917 // event.push(*itRank,1,msg) ;918 // client->sendEvent(event);919 // }920 // else client->sendEvent(event);921 // }922 // else923 // {924 // if (clientPrimServer->isServerLeader())925 // {926 // CMessage msg;927 // msg<<this->getIdServer();928 // const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();929 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)930 // event.push(*itRank,1,msg) ;931 // clientPrimServer->sendEvent(event);932 // }933 // else clientPrimServer->sendEvent(event);934 // }935 1002 } 936 1003 … … 948 1015 { 949 1016 // The creation of header file should be delegated to server2, for now 950 if (hasClient && hasServer)951 {952 sendCreateFileHeader();953 }1017 // if (hasClient && hasServer) 1018 // { 1019 // sendCreateFileHeader(); 1020 // } 954 1021 955 1022 if (!hasClient && hasServer) 956 1023 createFileHeader(); 1024 } 1025 1026 //! Client side: Send a message to do some post processing on server 1027 void CContext::sendProcessingGridOfEnabledFields() 1028 { 1029 // Use correct context client to send message 1030 CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client; 1031 CEventClient event(getType(),EVENT_ID_PROCESS_GRID_ENABLED_FIELDS); 1032 1033 if (contextClientTmp->isServerLeader()) 1034 { 1035 CMessage msg; 1036 msg<<this->getIdServer(); 1037 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 1038 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1039 event.push(*itRank,1,msg); 1040 contextClientTmp->sendEvent(event); 1041 } 1042 else contextClientTmp->sendEvent(event); 1043 } 1044 1045 //! Server side: Receive a message to do some post processing 1046 void CContext::recvProcessingGridOfEnabledFields(CEventServer& event) 1047 { 1048 CBufferIn* buffer=event.subEvents.begin()->buffer; 1049 string id; 1050 *buffer>>id; 1051 // get(id)->processGridEnabledFields(); 957 1052 } 958 1053 … … 980 1075 else contextClientTmp->sendEvent(event); 981 1076 } 982 983 // if (hasClient)984 // {985 // if (!hasServer)986 // {987 // CEventClient event(getType(),EVENT_ID_POST_PROCESS);988 // if (client->isServerLeader())989 // {990 // CMessage msg;991 // msg<<this->getIdServer();992 // const std::list<int>& ranks = client->getRanksServerLeader();993 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)994 // event.push(*itRank,1,msg);995 // client->sendEvent(event);996 // }997 // else client->sendEvent(event);998 // }999 // else1000 // {1001 // CEventClient event(getType(),EVENT_ID_POST_PROCESS);1002 // if (clientPrimServer->isServerLeader())1003 // {1004 // CMessage msg;1005 // msg<<this->getIdServer();1006 // const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();1007 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)1008 // event.push(*itRank,1,msg);1009 // clientPrimServer->sendEvent(event);1010 // }1011 // else clientPrimServer->sendEvent(event);1012 // }1013 // }1014 1077 } 1015 1078 … … 1075 1138 // Check if some axis, domains or grids are eligible to for compressed indexed output. 1076 1139 // Warning: This must be done after solving the inheritance and before the rest of post-processing 1077 checkAxisDomainsGridsEligibilityForCompressedOutput(); 1140 checkAxisDomainsGridsEligibilityForCompressedOutput(); 1078 1141 1079 1142 // Check if some automatic time series should be generated 1080 1143 // Warning: This must be done after solving the inheritance and before the rest of post-processing 1081 if (!hasServer) 1082 prepareTimeseries(); 1144 // prepareTimeseries(); 1145 1146 // The timeseries should only be prepared in client 1147 if (hasClient && !hasServer) prepareTimeseries(); 1083 1148 1084 1149 //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 1085 1150 this->findEnabledFiles(); 1086 this->findEnabledReadModeFiles(); 1151 // this->findEnabledReadModeFiles(); 1152 // For now, only read files with client and only one level server 1153 if (hasClient && !hasServer) this->findEnabledReadModeFiles(); 1154 1087 1155 1088 1156 // Find all enabled fields of each file 1089 1157 this->findAllEnabledFields(); 1090 this->findAllEnabledFieldsInReadModeFiles(); 1158 // this->findAllEnabledFieldsInReadModeFiles(); 1159 // For now, only read files with client and only one level server 1160 if (hasClient && !hasServer) this->findAllEnabledFieldsInReadModeFiles(); 1091 1161 1092 1162 // if (hasClient) … … 1097 1167 } 1098 1168 1169 // // Only search and rebuild all reference objects of enable fields, don't transform 1170 // this->solveOnlyRefOfEnabledFields(false); 1171 1172 // // Search and rebuild all reference object of enabled fields 1173 // this->solveAllRefOfEnabledFields(false); 1174 1175 // // Find all fields with read access from the public API 1176 // findFieldsWithReadAccess(); 1177 // // and solve the all reference for them 1178 // solveAllRefOfFieldsWithReadAccess(); 1179 1099 1180 // Only search and rebuild all reference objects of enable fields, don't transform 1100 this->solveOnlyRefOfEnabledFields(false);1181 if (hasClient) this->solveOnlyRefOfEnabledFields(false); 1101 1182 1102 1183 // Search and rebuild all reference object of enabled fields 1103 this->solveAllRefOfEnabledFields(false);1184 // if (hasClient) this->solveAllRefOfEnabledFields(false); 1104 1185 1105 1186 // Find all fields with read access from the public API 1106 findFieldsWithReadAccess();1187 if (hasClient && !hasServer) findFieldsWithReadAccess(); 1107 1188 // and solve the all reference for them 1108 solveAllRefOfFieldsWithReadAccess();1189 if (hasClient && !hasServer) solveAllRefOfFieldsWithReadAccess(); 1109 1190 1110 1191 isPostProcessed = true; -
XIOS/dev/dev_olga/src/node/context.hpp
r1021 r1025 51 51 EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, 52 52 EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 53 EVENT_ID_POST_PROCESS, EVENT_ID_SEND_REGISTRY 53 EVENT_ID_POST_PROCESS, EVENT_ID_SEND_REGISTRY, 54 EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES, 55 EVENT_ID_PROCESS_GRID_ENABLED_FIELDS 54 56 }; 55 57 … … 122 124 void buildFilterGraphOfFieldsWithReadAccess(); 123 125 void postProcessing(); 126 void postProcessingGlobalAttributes(); 127 128 void solveAllEnabledFields(); 129 void processGridEnabledFields(); 124 130 125 131 std::map<int, StdSize> getAttributesBufferSize(std::map<int, StdSize>& maxEventSize); … … 137 143 void sendRefGrid(); 138 144 void sendPostProcessing(); 145 void sendPostProcessingGlobalAttributes(); 146 void sendProcessingGridOfEnabledFields(); 139 147 //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 140 148 void sendRegistry(void) ; … … 153 161 static void recvPostProcessing(CEventServer& event); 154 162 void recvPostProcessing(CBufferIn& buffer); 163 static void recvProcessingGridOfEnabledFields(CEventServer& event); 164 static void recvPostProcessingGlobalAttributes(CEventServer& event); 165 void recvPostProcessingGlobalAttributes(CBufferIn& buffer); 155 166 static void recvRegistry(CEventServer& event) ; 156 167 void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the servers … … 235 246 private: 236 247 bool isPostProcessed; 248 bool allProcessed; 237 249 bool finalized; 238 250 StdString idServer_; -
XIOS/dev/dev_olga/src/node/domain.cpp
r1009 r1025 31 31 : CObjectTemplate<CDomain>(), CDomainAttributes() 32 32 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 33 , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(),isCompressible_(false), isUnstructed_(false)33 , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 34 34 , isClientAfterTransformationChecked(false), hasLonLat(false) 35 , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client()36 35 , isRedistributed_(false), hasPole(false) 37 36 { … … 41 40 : CObjectTemplate<CDomain>(id), CDomainAttributes() 42 41 , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 43 , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(),isCompressible_(false), isUnstructed_(false)42 , hasBounds(false), hasArea(false), isDistributed_(false), isCompressible_(false), isUnstructed_(false) 44 43 , isClientAfterTransformationChecked(false), hasLonLat(false) 45 , lonvalue_client(), latvalue_client(), bounds_lon_client(), bounds_lat_client()46 44 , isRedistributed_(false), hasPole(false) 47 45 { … … 113 111 { 114 112 return offsetWrittenIndexes_; 113 } 114 115 /*! 116 Returns the start of indexes written by each server. 117 \return the start of indexes written by each server 118 */ 119 const std::vector<int>& CDomain::getStartWriteIndex() const 120 { 121 return start_write_index_; 122 } 123 124 /*! 125 Returns the count of indexes written by each server. 126 \return the count of indexes written by each server 127 */ 128 const std::vector<int>& CDomain::getCountWriteIndex() const 129 { 130 return count_write_index_; 131 } 132 133 /*! 134 Returns the local data written by each server. 135 */ 136 const std::vector<int>& CDomain::getLocalWriteSize() const 137 { 138 return local_write_size_; 139 } 140 141 /*! 142 Returns the global data written by all server. 143 */ 144 const std::vector<int>& CDomain::getGlobalWriteSize() const 145 { 146 return global_write_size_; 115 147 } 116 148 … … 130 162 if (client->isServerLeader()) 131 163 { 132 // size estimation for send ServerAttribut164 // size estimation for sendDistributionAttribut 133 165 size_t size = 11 * sizeof(size_t); 134 166 … … 141 173 } 142 174 143 std::map<int, std::vector<size_t> >::const_iterator itIndexEnd = indSrv_.end();175 boost::unordered_map<int, vector<size_t> >::const_iterator itIndexEnd = indSrv_.end(); 144 176 std::map<int, std::vector<int> >::const_iterator itWrittenIndexEnd = indWrittenSrv_.end(); 145 177 for (size_t k = 0; k < connectedServerRank_.size(); ++k) 146 178 { 147 179 int rank = connectedServerRank_[k]; 148 std::map<int, std::vector<size_t> >::const_iterator it = indSrv_.find(rank);180 boost::unordered_map<int, std::vector<size_t> >::const_iterator it = indSrv_.find(rank); 149 181 size_t idxCount = (it != itIndexEnd) ? it->second.size() : 0; 150 182 … … 175 207 bool CDomain::isEmpty(void) const 176 208 { 177 return ((this->zoom_ni_srv == 0) || 178 (this->zoom_nj_srv == 0)); 209 return ((this->zoom_i_index.isEmpty()) || (0 == this->zoom_i_index.numElements())); 210 // return ((this->zoom_ni_srv == 0) || 211 // (this->zoom_nj_srv == 0)); 179 212 } 180 213 … … 695 728 for (int j = 0; j < nj; ++j) 696 729 for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; 697 } 698 computeNGlobDomain(); 730 } 699 731 checkZoom(); 700 732 … … 715 747 if (global_zoom_nj.isEmpty()) 716 748 global_zoom_nj.setValue(nj_glo); 749 if (zoom_i_index.isEmpty()) zoom_i_index.setValue(i_index.getValue()); 750 if (zoom_j_index.isEmpty()) zoom_j_index.setValue(j_index.getValue()); 717 751 } 718 752 … … 993 1027 localMask.resize(ni*nj) ; 994 1028 localMask=false ; 995 size_t zoom_ibegin= global_zoom_ibegin ;996 size_t zoom_iend= global_zoom_ibegin+global_zoom_ni-1 ;997 size_t zoom_jbegin= global_zoom_jbegin ;998 size_t zoom_jend= global_zoom_jbegin+global_zoom_nj-1 ;1029 size_t zoom_ibegin= global_zoom_ibegin ; 1030 size_t zoom_iend= global_zoom_ibegin+global_zoom_ni-1 ; 1031 size_t zoom_jbegin= global_zoom_jbegin ; 1032 size_t zoom_jend= global_zoom_jbegin+global_zoom_nj-1 ; 999 1033 1000 1034 … … 1037 1071 if (!lonvalue_2d.isEmpty()) 1038 1072 { 1039 lonvalue _client.resize(ni * nj);1040 latvalue _client.resize(ni * nj);1073 lonvalue.resize(ni * nj); 1074 latvalue.resize(ni * nj); 1041 1075 if (hasBounds) 1042 1076 { 1043 bounds_lon _client.resize(nvertex, ni * nj);1044 bounds_lat _client.resize(nvertex, ni * nj);1077 bounds_lonvalue.resize(nvertex, ni * nj); 1078 bounds_latvalue.resize(nvertex, ni * nj); 1045 1079 } 1046 1080 … … 1051 1085 int k = j * ni + i; 1052 1086 1053 lonvalue _client(k) = lonvalue_2d(i,j);1054 latvalue _client(k) = latvalue_2d(i,j);1087 lonvalue(k) = lonvalue_2d(i,j); 1088 latvalue(k) = latvalue_2d(i,j); 1055 1089 1056 1090 if (hasBounds) … … 1058 1092 for (int n = 0; n < nvertex; ++n) 1059 1093 { 1060 bounds_lon _client(n,k) = bounds_lon_2d(n,i,j);1061 bounds_lat _client(n,k) = bounds_lat_2d(n,i,j);1094 bounds_lonvalue(n,k) = bounds_lon_2d(n,i,j); 1095 bounds_latvalue(n,k) = bounds_lat_2d(n,i,j); 1062 1096 } 1063 1097 } … … 1071 1105 if (ni == lonvalue_1d.numElements() && nj == latvalue_1d.numElements()) 1072 1106 { 1073 lonvalue _client.resize(ni * nj);1074 latvalue _client.resize(ni * nj);1107 lonvalue.resize(ni * nj); 1108 latvalue.resize(ni * nj); 1075 1109 if (hasBounds) 1076 1110 { 1077 bounds_lon _client.resize(nvertex, ni * nj);1078 bounds_lat _client.resize(nvertex, ni * nj);1111 bounds_lonvalue.resize(nvertex, ni * nj); 1112 bounds_latvalue.resize(nvertex, ni * nj); 1079 1113 } 1080 1114 … … 1085 1119 int k = j * ni + i; 1086 1120 1087 lonvalue _client(k) = lonvalue_1d(i);1088 latvalue _client(k) = latvalue_1d(j);1121 lonvalue(k) = lonvalue_1d(i); 1122 latvalue(k) = latvalue_1d(j); 1089 1123 1090 1124 if (hasBounds) … … 1092 1126 for (int n = 0; n < nvertex; ++n) 1093 1127 { 1094 bounds_lon _client(n,k) = bounds_lon_1d(n,i);1095 bounds_lat _client(n,k) = bounds_lat_1d(n,j);1128 bounds_lonvalue(n,k) = bounds_lon_1d(n,i); 1129 bounds_latvalue(n,k) = bounds_lat_1d(n,j); 1096 1130 } 1097 1131 } … … 1101 1135 else if (i_index.numElements() == lonvalue_1d.numElements() && j_index.numElements() == latvalue_1d.numElements()) 1102 1136 { 1103 lonvalue _client.reference(lonvalue_1d);1104 latvalue _client.reference(latvalue_1d);1137 lonvalue.reference(lonvalue_1d); 1138 latvalue.reference(latvalue_1d); 1105 1139 if (hasBounds) 1106 1140 { 1107 bounds_lon _client.reference(bounds_lon_1d);1108 bounds_lat _client.reference(bounds_lat_1d);1141 bounds_lonvalue.reference(bounds_lon_1d); 1142 bounds_latvalue.reference(bounds_lat_1d); 1109 1143 } 1110 1144 } … … 1120 1154 else if (type == type_attr::curvilinear || type == type_attr::unstructured) 1121 1155 { 1122 lonvalue _client.reference(lonvalue_1d);1123 latvalue _client.reference(latvalue_1d);1156 lonvalue.reference(lonvalue_1d); 1157 latvalue.reference(latvalue_1d); 1124 1158 if (hasBounds) 1125 1159 { 1126 bounds_lon _client.reference(bounds_lon_1d);1127 bounds_lat _client.reference(bounds_lat_1d);1160 bounds_lonvalue.reference(bounds_lon_1d); 1161 bounds_latvalue.reference(bounds_lat_1d); 1128 1162 } 1129 1163 } … … 1221 1255 void CDomain::checkArea(void) 1222 1256 { 1223 hasArea = !area.isEmpty() ;1257 hasArea = !area.isEmpty() || !areavalue.isEmpty(); 1224 1258 if (hasArea) 1225 1259 { … … 1231 1265 << "Local size is " << ni.getValue() << " x " << nj.getValue() << "." << std::endl 1232 1266 << "Area size is " << area.extent(0) << " x " << area.extent(1) << "."); 1267 } 1268 if (areavalue.isEmpty()) 1269 { 1270 areavalue.resize(ni*nj); 1271 for (int j = 0; j < nj; ++j) 1272 { 1273 for (int i = 0; i < ni; ++i) 1274 { 1275 int k = j * ni + i; 1276 areavalue(k) = area(i,j); 1277 } 1278 } 1233 1279 } 1234 1280 } … … 1302 1348 if (context->hasClient) 1303 1349 { 1304 this->checkMask(); 1305 if (hasLonLat || hasArea || isCompressible_) this->computeConnectedServer(); 1350 // this->checkMask(); 1351 this->computeConnectedClients(); 1352 // if (hasLonLat || hasArea || isCompressible_) this->computeConnectedClients(); 1306 1353 if (hasLonLat) this->completeLonLatClient(); 1307 1354 } … … 1318 1365 CContext* context=CContext::getCurrent(); 1319 1366 1367 if (context->hasClient && !context->hasServer) 1368 { 1369 this->checkDomain(); 1370 this->checkBounds(); 1371 this->checkArea(); 1372 this->checkLonLat(); 1373 } 1374 1375 if (context->hasClient && !context->hasServer) 1376 { // CÃŽté client uniquement 1377 this->checkMask(); 1378 this->checkDomainData(); 1379 this->checkCompression(); 1380 this->computeLocalMask() ; 1381 } 1382 else 1383 { // CÃŽté serveur uniquement 1384 } 1385 1386 this->isClientChecked = true; 1387 } 1388 1389 // Send all checked attributes to server 1390 void CDomain::sendCheckedAttributes() 1391 { 1392 if (!this->isClientChecked) checkAttributesOnClient(); 1393 if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(); 1394 CContext* context=CContext::getCurrent() ; 1395 1396 if (this->isChecked) return; 1397 if (context->hasClient) 1398 { 1399 sendAttributes(); 1400 } 1401 this->isChecked = true; 1402 } 1403 1404 void CDomain::checkAttributes(void) 1405 { 1406 if (this->isChecked) return; 1407 CContext* context=CContext::getCurrent() ; 1408 1320 1409 this->checkDomain(); 1410 this->checkLonLat(); 1321 1411 this->checkBounds(); 1322 1412 this->checkArea(); 1323 this->checkLonLat();1324 1413 1325 1414 if (context->hasClient) … … 1329 1418 this->checkCompression(); 1330 1419 this->computeLocalMask() ; 1420 1331 1421 } 1332 1422 else … … 1334 1424 } 1335 1425 1336 this->isClientChecked = true;1337 }1338 1339 // Send all checked attributes to server1340 void CDomain::sendCheckedAttributes()1341 {1342 if (!this->isClientChecked) checkAttributesOnClient();1343 if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation();1344 CContext* context=CContext::getCurrent() ;1345 1346 if (this->isChecked) return;1347 if (context->hasClient)1348 {1349 sendServerAttribut();1350 if (hasLonLat || hasArea || isCompressible_) sendLonLatArea();1351 }1352 this->isChecked = true;1353 }1354 1355 void CDomain::checkAttributes(void)1356 {1357 if (this->isChecked) return;1358 CContext* context=CContext::getCurrent() ;1359 1360 this->checkDomain();1361 this->checkLonLat();1362 this->checkBounds();1363 this->checkArea();1364 1365 1426 if (context->hasClient) 1366 { // CÃŽté client uniquement 1367 this->checkMask(); 1368 this->checkDomainData(); 1369 this->checkCompression(); 1370 this->computeLocalMask() ; 1371 1372 } 1373 else 1374 { // CÃŽté serveur uniquement 1375 } 1376 1377 if (context->hasClient) 1378 { 1379 this->computeConnectedServer(); 1427 { 1428 this->computeConnectedClients(); 1380 1429 this->completeLonLatClient(); 1381 this->sendServerAttribut();1382 this->sendLonLatArea();1383 1430 } 1384 1431 … … 1386 1433 } 1387 1434 1388 void CDomain::sendServerAttribut(void) 1435 /*! 1436 Send distribution from client to other clients 1437 Because a client in a level knows correctly the grid distribution of client on the next level 1438 it calculates this distribution then sends it to the corresponding clients on the next level 1439 */ 1440 void CDomain::sendDistributionAttributes(void) 1389 1441 { 1390 1442 CContext* context = CContext::getCurrent(); … … 1394 1446 { 1395 1447 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] 1396 : context->client; 1397 // CContextClient* client = context->client; 1448 : context->client; 1398 1449 int nbServer = contextClientTmp->serverSize; 1399 1400 CServerDistributionDescription serverDescription(nGlobDomain_, nbServer); 1450 std::vector<int> nGlobDomain(2); 1451 nGlobDomain[0] = this->ni_glo; 1452 nGlobDomain[1] = this->nj_glo; 1453 1454 CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 1401 1455 if (isUnstructed_) serverDescription.computeServerDistribution(false, 0); 1402 1456 else serverDescription.computeServerDistribution(false, 1); … … 1418 1472 const int ni_srv = serverDimensionSizes[*itRank][0]; 1419 1473 const int nj_srv = serverDimensionSizes[*itRank][1]; 1420 const int iend_srv = ibegin_srv + ni_srv - 1;1421 const int jend_srv = jbegin_srv + nj_srv - 1;1422 1474 1423 1475 msgs.push_back(CMessage()); 1424 1476 CMessage& msg = msgs.back(); 1425 1477 msg << this->getId() ; 1426 msg << ni_srv << ibegin_srv << iend_srv << nj_srv << jbegin_srv << jend_srv; 1427 msg << global_zoom_ni.getValue() << global_zoom_ibegin.getValue() << global_zoom_nj.getValue() << global_zoom_jbegin.getValue(); 1478 msg << ni_srv << ibegin_srv << nj_srv << jbegin_srv; 1428 1479 msg << isCompressible_; 1429 1480 … … 1436 1487 } 1437 1488 1438 void CDomain::computeNGlobDomain() 1439 { 1440 nGlobDomain_.resize(2); 1441 nGlobDomain_[0] = ni_glo.getValue(); 1442 nGlobDomain_[1] = nj_glo.getValue(); 1443 } 1444 1445 void CDomain::computeConnectedServer(void) 1489 // void CDomain::computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid, 1490 // CServerDistributionDescription::ServerDistributionType distType) 1491 /*! 1492 Compute the connection of a client to other clients to determine which clients to send attributes to 1493 */ 1494 void CDomain::computeConnectedClients() 1446 1495 { 1447 1496 CContext* context=CContext::getCurrent() ; 1448 CContextClient* client =context->client;1497 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1449 1498 int nbServer=client->serverSize; 1450 1499 int rank = client->clientRank; 1451 1500 bool doComputeGlobalIndexServer = true; 1452 1501 1453 int i,j,i_ind,j_ind, nbIndex ;1502 int i,j,i_ind,j_ind, nbIndex, nbIndexZoom; 1454 1503 int global_zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 1455 1504 int global_zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; … … 1458 1507 int globalIndexCountZoom = 0; 1459 1508 nbIndex = i_index.numElements(); 1460 for (i = 0; i < nbIndex; ++i)1461 {1462 i_ind=i_index(i);1463 j_ind=j_index(i);1464 1465 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend)1466 {1467 ++globalIndexCountZoom;1468 }1469 }1470 1471 int globalIndexWrittenCount = 0;1472 if (isCompressible_)1473 {1474 for (i = 0; i < data_i_index.numElements(); ++i)1475 {1476 i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i),1477 data_ibegin, data_jbegin, data_dim, ni,1478 j_ind);1479 if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni))1480 {1481 i_ind += ibegin;1482 j_ind += jbegin;1483 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend)1484 ++globalIndexWrittenCount;1485 }1486 }1487 }1509 // for (i = 0; i < nbIndex; ++i) 1510 // { 1511 // i_ind=i_index(i); 1512 // j_ind=j_index(i); 1513 1514 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1515 // { 1516 // ++globalIndexCountZoom; 1517 // } 1518 // } 1519 1520 // int globalIndexWrittenCount = 0; 1521 // if (isCompressible_) 1522 // { 1523 // for (i = 0; i < data_i_index.numElements(); ++i) 1524 // { 1525 // i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 1526 // data_ibegin, data_jbegin, data_dim, ni, 1527 // j_ind); 1528 // if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 1529 // { 1530 // i_ind += ibegin; 1531 // j_ind += jbegin; 1532 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1533 // ++globalIndexWrittenCount; 1534 // } 1535 // } 1536 // } 1488 1537 1489 1538 // Fill in index 1490 CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom);1539 1491 1540 CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 1492 1541 CArray<size_t,1> globalIndexDomain(nbIndex); 1493 1542 size_t globalIndex; 1494 1543 int globalIndexCount = 0; 1495 globalIndexCountZoom = 0;1544 1496 1545 1497 1546 for (i = 0; i < nbIndex; ++i) … … 1501 1550 globalIndex = i_ind + j_ind * ni_glo; 1502 1551 globalIndexDomain(globalIndexCount) = globalIndex; 1552 globalLocalIndexMap_[globalIndex] = i; 1503 1553 ++globalIndexCount; 1504 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1505 { 1506 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1507 localIndexDomainZoom(globalIndexCountZoom) = i; 1508 ++globalIndexCountZoom; 1509 } 1510 } 1511 1512 CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 1513 if (isCompressible_) 1514 { 1515 globalIndexWrittenCount = 0; 1516 for (i = 0; i < data_i_index.numElements(); ++i) 1517 { 1518 i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 1519 data_ibegin, data_jbegin, data_dim, ni, 1520 j_ind); 1521 if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 1522 { 1523 i_ind += ibegin; 1524 j_ind += jbegin; 1525 if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1526 { 1527 globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 1528 ++globalIndexWrittenCount; 1529 } 1530 } 1531 } 1532 } 1554 } 1555 1556 nbIndexZoom = zoom_i_index.numElements(); 1557 CArray<size_t,1> globalIndexDomainZoom(nbIndexZoom); 1558 globalIndexCountZoom = 0; 1559 for (i = 0; i < nbIndexZoom; ++i) 1560 { 1561 i_ind=zoom_i_index(i); 1562 j_ind=zoom_j_index(i); 1563 globalIndex = i_ind + j_ind * ni_glo; 1564 globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1565 1566 ++globalIndexCountZoom; 1567 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1568 // { 1569 // globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 1570 // localIndexDomainZoom(globalIndexCountZoom) = i; 1571 // ++globalIndexCountZoom; 1572 // } 1573 } 1574 1575 // CArray<int,1> globalIndexWrittenDomain(globalIndexWrittenCount); 1576 // if (isCompressible_) 1577 // { 1578 // globalIndexWrittenCount = 0; 1579 // for (i = 0; i < data_i_index.numElements(); ++i) 1580 // { 1581 // i_ind = CDistributionClient::getDomainIndex(data_i_index(i), data_j_index(i), 1582 // data_ibegin, data_jbegin, data_dim, ni, 1583 // j_ind); 1584 // if (i_ind >= 0 && i_ind < ni && j_ind >= 0 && j_ind < nj && mask_1d(i_ind + j_ind * ni)) 1585 // { 1586 // i_ind += ibegin; 1587 // j_ind += jbegin; 1588 // if (i_ind >= global_zoom_ibegin && i_ind <= global_zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= global_zoom_jend) 1589 // { 1590 // globalIndexWrittenDomain(globalIndexWrittenCount) = i_ind + j_ind * ni_glo; 1591 // ++globalIndexWrittenCount; 1592 // } 1593 // } 1594 // } 1595 // } 1533 1596 1534 1597 size_t globalSizeIndex = 1, indexBegin, indexEnd; 1535 1598 int range, clientSize = client->clientSize; 1536 for (int i = 0; i < nGlobDomain_.size(); ++i) globalSizeIndex *= nGlobDomain_[i]; 1599 std::vector<int> nGlobDomain(2); 1600 nGlobDomain[0] = this->ni_glo; 1601 nGlobDomain[1] = this->nj_glo; 1602 for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 1537 1603 indexBegin = 0; 1538 1604 if (globalSizeIndex <= clientSize) … … 1553 1619 } 1554 1620 1555 CServerDistributionDescription serverDescription(nGlobDomain _, nbServer);1621 CServerDistributionDescription serverDescription(nGlobDomain, nbServer); 1556 1622 if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 1557 1623 else serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); … … 1560 1626 client->intraComm); 1561 1627 clientServerMap->computeServerIndexMapping(globalIndexDomain); 1562 constCClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer();1628 CClientServerMapping::GlobalIndexMap& globalIndexDomainOnServer = clientServerMap->getGlobalIndexOnServer(); 1563 1629 1564 1630 CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexDomainOnServer.begin(), 1565 1631 ite = globalIndexDomainOnServer.end(); 1566 typedef XIOSBinarySearchWithIndex<size_t> BinarySearch;1567 std::vector<int>::iterator itVec;1568 1569 indSrv_.clear();1570 indWrittenSrv_.clear();1571 for (; it != ite; ++it)1572 {1573 int rank = it->first;1574 int indexSize = it->second.size();1575 std::vector<int> permutIndex(indexSize);1576 XIOSAlgorithms::fillInIndex(indexSize, permutIndex);1577 XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex);1578 BinarySearch binSearch(it->second);1579 int nb = globalIndexDomainZoom.numElements();1580 for (int i = 0; i < nb; ++i)1581 {1582 if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec))1583 {1584 indSrv_[rank].push_back(localIndexDomainZoom(i));1585 }1586 }1587 for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i)1588 {1589 if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec))1590 {1591 indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i));1592 }1593 }1594 }1632 // typedef XIOSBinarySearchWithIndex<size_t> BinarySearch; 1633 // std::vector<int>::iterator itVec; 1634 1635 // indSrv_.clear(); 1636 // indWrittenSrv_.clear(); 1637 // for (; it != ite; ++it) 1638 // { 1639 // int rank = it->first; 1640 // int indexSize = it->second.size(); 1641 // std::vector<int> permutIndex(indexSize); 1642 // XIOSAlgorithms::fillInIndex(indexSize, permutIndex); 1643 // XIOSAlgorithms::sortWithIndex<size_t, CVectorStorage>(it->second, permutIndex); 1644 // BinarySearch binSearch(it->second); 1645 // int nb = globalIndexDomainZoom.numElements(); 1646 // for (int i = 0; i < nb; ++i) 1647 // { 1648 // if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexDomainZoom(i), itVec)) 1649 // { 1650 // indSrv_[rank].push_back(localIndexDomainZoom(i)); 1651 // } 1652 // } 1653 // for (int i = 0; i < globalIndexWrittenDomain.numElements(); ++i) 1654 // { 1655 // if (binSearch.search(permutIndex.begin(), permutIndex.end(), globalIndexWrittenDomain(i), itVec)) 1656 // { 1657 // indWrittenSrv_[rank].push_back(globalIndexWrittenDomain(i)); 1658 // } 1659 // } 1660 // } 1595 1661 1596 1662 connectedServerRank_.clear(); … … 1599 1665 } 1600 1666 1667 indSrv_.swap(globalIndexDomainOnServer); 1601 1668 nbConnectedClients_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 1602 1669 1670 clientServerMap->computeServerIndexMapping(globalIndexDomainZoom); 1671 CClientServerMapping::GlobalIndexMap& globalIndexDomainZoomOnServer = clientServerMap->getGlobalIndexOnServer(); 1672 indZoomSrv_.swap(globalIndexDomainZoomOnServer); 1673 std::vector<int> connectedServerZoomRank(indZoomSrv_.size()); 1674 for (it = indZoomSrv_.begin(); it != indZoomSrv_.end(); ++it) 1675 connectedServerZoomRank.push_back(it->first); 1676 nbConnectedClientsZoom_ = clientServerMap->computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerZoomRank); 1677 1603 1678 delete clientServerMap; 1604 1679 } 1605 1680 1606 const std::map<int, vector<size_t> >& CDomain::getIndexServer() const1681 const boost::unordered_map<int, vector<size_t> >& CDomain::getIndexServer() const 1607 1682 { 1608 1683 return indSrv_; … … 1610 1685 1611 1686 /*! 1612 Send index from client to server(s) 1687 Send all attributes from client to connected clients 1688 The attributes will be rebuilt on receiving side 1689 */ 1690 void CDomain::sendAttributes() 1691 { 1692 sendIndex(); 1693 sendDistributionAttributes(); 1694 sendMask(); 1695 sendLonLat(); 1696 sendArea(); 1697 sendDataIndex(); 1698 } 1699 1700 /*! 1701 Send global index and zoom index from client to connected client(s) 1702 zoom index can be smaller than global index 1613 1703 */ 1614 1704 void CDomain::sendIndex() … … 1616 1706 int ns, n, i, j, ind, nv, idx; 1617 1707 CContext* context = CContext::getCurrent(); 1618 CContextClient* client =context->client;1708 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1619 1709 1620 1710 CEventClient eventIndex(getType(), EVENT_ID_INDEX); 1621 1711 1622 1712 list<CMessage> list_msgsIndex; 1623 list<CArray<int,1> > list_indi, list_indj, list_writtenInd; 1624 1625 std::map<int, std::vector<size_t> >::const_iterator it, iteMap; 1713 list<CArray<int,1> > list_indZoom, list_writtenInd, list_indGlob; 1714 1715 boost::unordered_map<int, vector<size_t> >::const_iterator itIndex, iteIndex, itZoom, iteZoom; 1716 iteIndex = indSrv_.end(); iteZoom = indZoomSrv_.end(); 1717 for (int k = 0; k < connectedServerRank_.size(); ++k) 1718 { 1719 int nbIndGlob = 0; 1720 int rank = connectedServerRank_[k]; 1721 itIndex = indSrv_.find(rank); 1722 if (iteIndex != itIndex) 1723 nbIndGlob = itIndex->second.size(); 1724 int nbIndZoom = 0; 1725 itZoom = indZoomSrv_.find(rank); 1726 if (iteZoom != itZoom) 1727 nbIndZoom = itZoom->second.size(); 1728 1729 list_indGlob.push_back(CArray<int,1>(nbIndGlob)); 1730 list_indZoom.push_back(CArray<int,1>(nbIndZoom)); 1731 1732 CArray<int,1>& indZoom = list_indZoom.back(); 1733 CArray<int,1>& indGlob = list_indGlob.back(); 1734 for (n = 0; n < nbIndGlob; ++n) 1735 { 1736 indGlob(n) = static_cast<int>(itIndex->second[n]); 1737 } 1738 1739 for (n = 0; n < nbIndZoom; ++n) 1740 { 1741 indZoom(n) = static_cast<int>(itZoom->second[n]); 1742 } 1743 1744 list_msgsIndex.push_back(CMessage()); 1745 list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 1746 list_msgsIndex.back() << isCurvilinear; 1747 list_msgsIndex.back() << list_indGlob.back() << list_indZoom.back(); //list_indi.back() << list_indj.back(); 1748 1749 // if (isCompressible_) 1750 // { 1751 // std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 1752 // list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 1753 // CArray<int,1>& writtenInd = list_writtenInd.back(); 1754 1755 // for (n = 0; n < writtenInd.numElements(); ++n) 1756 // writtenInd(n) = writtenIndSrc[n]; 1757 1758 // list_msgsIndex.back() << writtenInd; 1759 // } 1760 1761 eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 1762 } 1763 1764 client->sendEvent(eventIndex); 1765 } 1766 1767 /*! 1768 Send mask index from client to connected(s) 1769 */ 1770 void CDomain::sendMask() 1771 { 1772 int ns, n, i, j, ind, nv, idx; 1773 CContext* context = CContext::getCurrent(); 1774 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1775 1776 // send area for each connected server 1777 CEventClient eventMask(getType(), EVENT_ID_MASK); 1778 1779 list<CMessage> list_msgsMask; 1780 list<CArray<bool,1> > list_mask; 1781 1782 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1626 1783 iteMap = indSrv_.end(); 1627 1784 for (int k = 0; k < connectedServerRank_.size(); ++k) … … 1632 1789 if (iteMap != it) 1633 1790 nbData = it->second.size(); 1634 1635 list_indi.push_back(CArray<int,1>(nbData)); 1636 list_indj.push_back(CArray<int,1>(nbData)); 1637 1638 CArray<int,1>& indi = list_indi.back(); 1639 CArray<int,1>& indj = list_indj.back(); 1791 list_mask.push_back(CArray<bool,1>(nbData)); 1792 1640 1793 const std::vector<size_t>& temp = it->second; 1641 1794 for (n = 0; n < nbData; ++n) 1642 1795 { 1643 1796 idx = static_cast<int>(it->second[n]); 1644 indi(n) = i_index(idx); 1645 indj(n) = j_index(idx); 1646 } 1647 1648 list_msgsIndex.push_back(CMessage()); 1649 1650 list_msgsIndex.back() << this->getId() << (int)type; // enum ne fonctionne pour les message => ToFix 1651 list_msgsIndex.back() << isCurvilinear; 1652 list_msgsIndex.back() << list_indi.back() << list_indj.back(); 1653 1654 if (isCompressible_) 1655 { 1656 std::vector<int>& writtenIndSrc = indWrittenSrv_[rank]; 1657 list_writtenInd.push_back(CArray<int,1>(writtenIndSrc.size())); 1658 CArray<int,1>& writtenInd = list_writtenInd.back(); 1659 1660 for (n = 0; n < writtenInd.numElements(); ++n) 1661 writtenInd(n) = writtenIndSrc[n]; 1662 1663 list_msgsIndex.back() << writtenInd; 1664 } 1665 1666 eventIndex.push(rank, nbConnectedClients_[rank], list_msgsIndex.back()); 1667 } 1668 1669 client->sendEvent(eventIndex); 1797 list_mask.back()(n) = mask_1d(globalLocalIndexMap_[idx]); 1798 } 1799 1800 list_msgsMask.push_back(CMessage()); 1801 list_msgsMask.back() << this->getId() << list_mask.back(); 1802 eventMask.push(rank, nbConnectedClients_[rank], list_msgsMask.back()); 1803 } 1804 client->sendEvent(eventMask); 1670 1805 } 1671 1806 1672 1807 /*! 1673 Send area from client to server(s)1808 Send area from client to connected client(s) 1674 1809 */ 1675 1810 void CDomain::sendArea() … … 1679 1814 int ns, n, i, j, ind, nv, idx; 1680 1815 CContext* context = CContext::getCurrent(); 1681 CContextClient* client =context->client;1816 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1682 1817 1683 1818 // send area for each connected server … … 1687 1822 list<CArray<double,1> > list_area; 1688 1823 1689 std::map<int, std::vector<size_t> >::const_iterator it, iteMap;1824 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1690 1825 iteMap = indSrv_.end(); 1691 1826 for (int k = 0; k < connectedServerRank_.size(); ++k) … … 1702 1837 { 1703 1838 idx = static_cast<int>(it->second[n]); 1704 i = i_index(idx); 1705 j = j_index(idx); 1706 if (hasArea) 1707 list_area.back()(n) = area(i - ibegin, j - jbegin); 1839 list_area.back()(n) = areavalue(globalLocalIndexMap_[idx]); 1708 1840 } 1709 1841 1710 1842 list_msgsArea.push_back(CMessage()); 1711 list_msgsArea.back() << this->getId() << list_area.back(); 1843 list_msgsArea.back() << this->getId() << hasArea; 1844 list_msgsArea.back() << list_area.back(); 1712 1845 eventArea.push(rank, nbConnectedClients_[rank], list_msgsArea.back()); 1713 1846 } … … 1726 1859 int ns, n, i, j, ind, nv, idx; 1727 1860 CContext* context = CContext::getCurrent(); 1728 CContextClient* client =context->client;1861 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1729 1862 1730 1863 // send lon lat for each connected server … … 1736 1869 list<CArray<double,2> > list_boundslon, list_boundslat; 1737 1870 1738 std::map<int, std::vector<size_t> >::const_iterator it, iteMap;1871 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1739 1872 iteMap = indSrv_.end(); 1740 1873 for (int k = 0; k < connectedServerRank_.size(); ++k) … … 1761 1894 { 1762 1895 idx = static_cast<int>(it->second[n]); 1763 lon(n) = lonvalue_client(idx); 1764 lat(n) = latvalue_client(idx); 1896 int localInd = globalLocalIndexMap_[idx]; 1897 lon(n) = lonvalue(localInd); 1898 lat(n) = latvalue(localInd); 1765 1899 1766 1900 if (hasBounds) … … 1771 1905 for (nv = 0; nv < nvertex; ++nv) 1772 1906 { 1773 boundslon(nv, n) = bounds_lon _client(nv, idx);1774 boundslat(nv, n) = bounds_lat _client(nv, idx);1907 boundslon(nv, n) = bounds_lonvalue(nv, localInd); 1908 boundslat(nv, n) = bounds_latvalue(nv, localInd); 1775 1909 } 1776 1910 } … … 1780 1914 list_msgsLat.push_back(CMessage()); 1781 1915 1782 list_msgsLon.back() << this->getId() << list_lon.back();1783 list_msgsLat.back() << this->getId() << list_lat.back();1916 list_msgsLon.back() << this->getId() << hasLonLat << list_lon.back() << hasBounds; 1917 list_msgsLat.back() << this->getId() << hasLonLat << list_lat.back() << hasBounds; 1784 1918 1785 1919 if (hasBounds) … … 1798 1932 1799 1933 /*! 1800 Send some optional information to server(s) 1801 In the future, this function can be extended with more optional information to send 1934 Send data index to corresponding connected clients. 1935 Data index can be compressed however, we always send decompressed data index 1936 and they will be compressed on receiving. 1802 1937 */ 1803 void CDomain::sendLonLatArea(void) 1804 { 1805 sendIndex(); 1806 sendLonLat(); 1807 sendArea(); 1808 } 1809 1938 void CDomain::sendDataIndex() 1939 { 1940 int ns, n, i, j, ind, nv, idx; 1941 CContext* context = CContext::getCurrent(); 1942 CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 1943 1944 // send area for each connected server 1945 CEventClient eventDataIndex(getType(), EVENT_ID_DATA_INDEX); 1946 1947 list<CMessage> list_msgsDataIndex; 1948 list<CArray<int,1> > list_data_i_index, list_data_j_index; 1949 1950 int nbIndex = i_index.numElements(); 1951 CArray<int,1> dataIIndex(nbIndex), dataJIndex(nbIndex); 1952 dataIIndex = -1; dataJIndex = -1, ind = 0; 1953 for (idx = 0; idx < data_i_index.numElements(); ++idx) 1954 { 1955 if ((0 <= data_i_index(idx)) && (data_i_index(idx) < ni) && (ind < nbIndex)) 1956 { 1957 dataIIndex(ind) = data_i_index(idx); 1958 dataJIndex(ind) = data_j_index(idx); 1959 ++ind; 1960 } 1961 } 1962 1963 boost::unordered_map<int, vector<size_t> >::const_iterator it, iteMap; 1964 iteMap = indSrv_.end(); 1965 for (int k = 0; k < connectedServerRank_.size(); ++k) 1966 { 1967 int nbData = 0; 1968 int rank = connectedServerRank_[k]; 1969 it = indSrv_.find(rank); 1970 if (iteMap != it) 1971 nbData = it->second.size(); 1972 list_data_i_index.push_back(CArray<int,1>(nbData)); 1973 list_data_j_index.push_back(CArray<int,1>(nbData)); 1974 1975 const std::vector<size_t>& temp = it->second; 1976 for (n = 0; n < nbData; ++n) 1977 { 1978 idx = static_cast<int>(it->second[n]); 1979 i = globalLocalIndexMap_[idx]; 1980 list_data_i_index.back()(n) = dataIIndex(i); 1981 list_data_j_index.back()(n) = dataJIndex(i); 1982 } 1983 1984 list_msgsDataIndex.push_back(CMessage()); 1985 list_msgsDataIndex.back() << this->getId(); 1986 list_msgsDataIndex.back() << list_data_i_index.back() << list_data_j_index.back(); 1987 eventDataIndex.push(rank, nbConnectedClients_[rank], list_msgsDataIndex.back()); 1988 } 1989 client->sendEvent(eventDataIndex); 1990 } 1991 1810 1992 bool CDomain::dispatchEvent(CEventServer& event) 1811 1993 { … … 1816 1998 { 1817 1999 case EVENT_ID_SERVER_ATTRIBUT: 1818 recv ServerAttribut(event);2000 recvDistributionAttributes(event); 1819 2001 return true; 1820 2002 break; 1821 2003 case EVENT_ID_INDEX: 1822 2004 recvIndex(event); 2005 return true; 2006 break; 2007 case EVENT_ID_MASK: 2008 recvMask(event); 1823 2009 return true; 1824 2010 break; … … 1834 2020 recvArea(event); 1835 2021 return true; 2022 break; 2023 case EVENT_ID_DATA_INDEX: 2024 recvDataIndex(event); 2025 return true; 1836 2026 break; 1837 2027 default: … … 1847 2037 \param[in] event event contain info about rank and associated attributes 1848 2038 */ 1849 void CDomain::recv ServerAttribut(CEventServer& event)2039 void CDomain::recvDistributionAttributes(CEventServer& event) 1850 2040 { 1851 2041 CBufferIn* buffer=event.subEvents.begin()->buffer; 1852 2042 string domainId ; 1853 2043 *buffer>>domainId ; 1854 get(domainId)->recvServerAttribut(*buffer) ; 1855 1856 CContext* context = CContext::getCurrent(); 1857 if (context->hasClient && context->hasServer) 1858 { 1859 get(domainId)->sendServerAttribut(); 1860 } 1861 2044 get(domainId)->recvDistributionAttributes(*buffer) ; 1862 2045 } 1863 2046 … … 1867 2050 \param[in] buffer message containing attributes info 1868 2051 */ 1869 void CDomain::recvServerAttribut(CBufferIn& buffer) 1870 { 1871 int global_zoom_ni_tmp, global_zoom_ibegin_tmp, global_zoom_nj_tmp, global_zoom_jbegin_tmp; 1872 buffer >> ni_srv >> ibegin_srv >> iend_srv >> nj_srv >> jbegin_srv >> jend_srv 1873 >> global_zoom_ni_tmp >> global_zoom_ibegin_tmp >> global_zoom_nj_tmp >> global_zoom_jbegin_tmp 2052 void CDomain::recvDistributionAttributes(CBufferIn& buffer) 2053 { 2054 int ni_tmp, ibegin_tmp, nj_tmp, jbegin_tmp; 2055 buffer >> ni_tmp >> ibegin_tmp >> nj_tmp >> jbegin_tmp 1874 2056 >> isCompressible_; 1875 1876 global_zoom_ni.setValue(global_zoom_ni_tmp); 1877 global_zoom_ibegin.setValue(global_zoom_ibegin_tmp); 1878 global_zoom_nj.setValue(global_zoom_nj_tmp); 1879 global_zoom_jbegin.setValue(global_zoom_jbegin_tmp); 1880 1881 int zoom_iend = global_zoom_ibegin + global_zoom_ni - 1; 1882 int zoom_jend = global_zoom_jbegin + global_zoom_nj - 1; 1883 1884 zoom_ibegin_srv = global_zoom_ibegin > ibegin_srv ? global_zoom_ibegin : ibegin_srv ; 1885 zoom_iend_srv = zoom_iend < iend_srv ? zoom_iend : iend_srv ; 1886 zoom_ni_srv=zoom_iend_srv-zoom_ibegin_srv+1 ; 1887 1888 zoom_jbegin_srv = global_zoom_jbegin > jbegin_srv ? global_zoom_jbegin : jbegin_srv ; 1889 zoom_jend_srv = zoom_jend < jend_srv ? zoom_jend : jend_srv ; 1890 zoom_nj_srv=zoom_jend_srv-zoom_jbegin_srv+1 ; 1891 1892 if (zoom_ni_srv<=0 || zoom_nj_srv<=0) 1893 { 1894 zoom_ibegin_srv=0 ; zoom_iend_srv=0 ; zoom_ni_srv=0 ; 1895 zoom_jbegin_srv=0 ; zoom_jend_srv=0 ; zoom_nj_srv=0 ; 1896 } 1897 lonvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 1898 lonvalue_srv = 0. ; 1899 latvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 1900 latvalue_srv = 0. ; 1901 if (hasBounds) 1902 { 1903 bounds_lon_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; 1904 bounds_lon_srv = 0. ; 1905 bounds_lat_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; 1906 bounds_lat_srv = 0. ; 1907 } 1908 1909 if (hasArea) 1910 { 1911 area_srv.resize(zoom_ni_srv * zoom_nj_srv); 1912 area_srv = 0.; 1913 } 1914 2057 ni.setValue(ni_tmp); 2058 ibegin.setValue(ibegin_tmp); 2059 nj.setValue(nj_tmp); 2060 jbegin.setValue(jbegin_tmp); 1915 2061 } 1916 2062 … … 1921 2067 void CDomain::recvIndex(CEventServer& event) 1922 2068 { 1923 CDomain* domain; 2069 string domainId; 2070 std::map<int, CBufferIn*> rankBuffers; 1924 2071 1925 2072 list<CEventServer::SSubEvent>::iterator it; 1926 2073 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 1927 { 2074 { 1928 2075 CBufferIn* buffer = it->buffer; 1929 string domainId;1930 2076 *buffer >> domainId; 1931 domain = get(domainId);1932 domain->recvIndex(it->rank, *buffer);1933 }1934 1935 if (domain->isCompressible_)1936 {1937 std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end());1938 1939 CContextServer* server = CContext::getCurrent()->server;1940 domain->numberWrittenIndexes_ = domain->indexesToWrite.size();1941 MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm);1942 MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm);1943 domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_;1944 }2077 rankBuffers[it->rank] = buffer; 2078 } 2079 get(domainId)->recvIndex(rankBuffers); 2080 2081 // if (domain->isCompressible_) 2082 // { 2083 // std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); 2084 2085 // CContextServer* server = CContext::getCurrent()->server; 2086 // domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); 2087 // MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 2088 // MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 2089 // domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; 2090 // } 1945 2091 } 1946 2092 1947 2093 /*! 1948 2094 Receive index information from client(s) 1949 \param[in] rank rank of client source 1950 \param[in] buffer message containing index info 2095 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 1951 2096 */ 1952 void CDomain::recvIndex(int rank, CBufferIn& buffer) 1953 { 1954 int type_int; 1955 buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; 1956 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 1957 1958 if (isCompressible_) 1959 { 1960 CArray<int, 1> writtenIndexes; 1961 buffer >> writtenIndexes; 1962 indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 1963 for (int i = 0; i < writtenIndexes.numElements(); ++i) 1964 indexesToWrite.push_back(writtenIndexes(i)); 1965 } 2097 void CDomain::recvIndex(std::map<int, CBufferIn*>& rankBuffers) 2098 { 2099 int nbReceived = rankBuffers.size(), i, ind, index, type_int; 2100 recvClientRanks_.resize(nbReceived); 2101 vector<CArray<int,1> > recvZoomInd(nbReceived); 2102 2103 std::map<int, CBufferIn*>::iterator it = rankBuffers.begin(), ite = rankBuffers.end(); 2104 ind = 0; 2105 for (ind = 0; it != ite; ++it, ++ind) 2106 { 2107 recvClientRanks_[ind] = it->first; 2108 CBufferIn& buffer = *(it->second); 2109 buffer >> type_int >> isCurvilinear >> indGlob_[it->first] >> recvZoomInd[ind]; //recvIndGlob[ind]; 2110 type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 2111 } 2112 int nbIndGlob = 0; 2113 for (i = 0; i < nbReceived; ++i) 2114 { 2115 nbIndGlob += indGlob_[recvClientRanks_[i]].numElements(); 2116 } 2117 2118 i_index.resize(nbIndGlob); 2119 j_index.resize(nbIndGlob); 2120 2121 nbIndGlob = 0; 2122 for (i = 0; i < nbReceived; ++i) 2123 { 2124 CArray<int,1>& tmp = indGlob_[recvClientRanks_[i]]; 2125 for (ind = 0; ind < tmp.numElements(); ++ind) 2126 { 2127 index = tmp(ind); 2128 i_index(nbIndGlob) = index / ni_glo; 2129 j_index(nbIndGlob) = index % ni_glo; 2130 ++nbIndGlob; 2131 } 2132 } 2133 2134 int nbZoomInd = 0; 2135 for (i = 0; i < nbReceived; ++i) 2136 { 2137 nbZoomInd += recvZoomInd[i].numElements(); 2138 } 2139 2140 zoom_i_index.resize(nbZoomInd); 2141 zoom_j_index.resize(nbZoomInd); 2142 2143 nbZoomInd = 0; 2144 for (i = 0; i < nbReceived; ++i) 2145 { 2146 CArray<int,1>& tmp = recvZoomInd[i]; 2147 for (ind = 0; ind < tmp.numElements(); ++ind) 2148 { 2149 index = tmp(ind); 2150 zoom_i_index(nbZoomInd) = index / ni_glo; 2151 zoom_j_index(nbZoomInd) = index % ni_glo; 2152 ++nbZoomInd; 2153 } 2154 } 2155 2156 { 2157 CContextServer* server = CContext::getCurrent()->server; 2158 count_write_index_.resize(2); 2159 start_write_index_.resize(2); 2160 local_write_size_.resize(2); 2161 global_write_size_.resize(2); 2162 if ((this->type) == CDomain::type_attr::unstructured) 2163 { 2164 count_write_index_[0] = zoom_i_index.numElements(); 2165 count_write_index_[1] = 0; 2166 } 2167 else 2168 { 2169 int ni_zoom = zoom_i_index.numElements(), idx, nbIZoom = 0, nbJZoom = 0; 2170 for (idx =0; idx < ni_zoom; ++idx) 2171 { 2172 if ((ibegin <= zoom_i_index(idx)) && (zoom_i_index(idx) < ibegin+ni) && (nbIZoom < ni)) 2173 ++nbIZoom; 2174 if ((jbegin <= zoom_j_index(idx)) && (zoom_j_index(idx) < jbegin+nj) && (nbJZoom < nj)) 2175 ++nbJZoom; 2176 } 2177 count_write_index_[0] = nbIZoom; 2178 count_write_index_[1] = nbJZoom; 2179 } 2180 2181 MPI_Scan(&count_write_index_[0], &start_write_index_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 2182 start_write_index_[0] = 0; 2183 start_write_index_[1] -= count_write_index_[1]; 2184 local_write_size_[0] = count_write_index_[0]; 2185 local_write_size_[1] = count_write_index_[1]; 2186 MPI_Allreduce(&count_write_index_[0], &global_write_size_[0], 2, MPI_INT, MPI_SUM, server->intraComm); 2187 global_write_size_[0] = count_write_index_[0]; 2188 global_write_size_[1] = (global_write_size_[1] > nj_glo) ? nj_glo : global_write_size_[1]; 2189 2190 } 2191 2192 // int type_int; 2193 // buffer >> type_int >> isCurvilinear >> indiSrv[rank] >> indjSrv[rank]; 2194 // type.setValue((type_attr::t_enum)type_int); // probleme des type enum avec les buffers : ToFix 2195 2196 // if (isCompressible_) 2197 // { 2198 // CArray<int, 1> writtenIndexes; 2199 // buffer >> writtenIndexes; 2200 // indexesToWrite.reserve(indexesToWrite.size() + writtenIndexes.numElements()); 2201 // for (int i = 0; i < writtenIndexes.numElements(); ++i) 2202 // indexesToWrite.push_back(writtenIndexes(i)); 2203 // } 2204 } 2205 2206 /*! 2207 Receive area event from clients(s) 2208 \param[in] event event contain info about rank and associated area 2209 */ 2210 void CDomain::recvMask(CEventServer& event) 2211 { 2212 string domainId; 2213 std::map<int, CBufferIn*> rankBuffers; 2214 2215 list<CEventServer::SSubEvent>::iterator it; 2216 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2217 { 2218 CBufferIn* buffer = it->buffer; 2219 *buffer >> domainId; 2220 rankBuffers[it->rank] = buffer; 2221 } 2222 get(domainId)->recvMask(rankBuffers); 2223 } 2224 2225 2226 /*! 2227 Receive mask information from client(s) 2228 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 2229 */ 2230 void CDomain::recvMask(std::map<int, CBufferIn*>& rankBuffers) 2231 { 2232 int nbReceived = rankBuffers.size(), i, ind, index; 2233 if (nbReceived != recvClientRanks_.size()) 2234 ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", 2235 << "The number of sending clients is not correct." 2236 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2237 2238 vector<CArray<bool,1> > recvMaskValue(nbReceived); 2239 for (i = 0; i < recvClientRanks_.size(); ++i) 2240 { 2241 int rank = recvClientRanks_[i]; 2242 CBufferIn& buffer = *(rankBuffers[rank]); 2243 buffer >> recvMaskValue[i]; 2244 } 2245 2246 int nbMaskInd = 0; 2247 for (i = 0; i < nbReceived; ++i) 2248 { 2249 nbMaskInd += recvMaskValue[i].numElements(); 2250 } 2251 2252 mask_1d.resize(nbMaskInd); 2253 nbMaskInd = 0; 2254 for (i = 0; i < nbReceived; ++i) 2255 { 2256 CArray<bool,1>& tmp = recvMaskValue[i]; 2257 for (ind = 0; ind < tmp.numElements(); ++ind) 2258 { 2259 mask_1d(nbMaskInd) = tmp(ind); 2260 ++nbMaskInd; 2261 } 2262 } 1966 2263 } 1967 2264 … … 1972 2269 void CDomain::recvLon(CEventServer& event) 1973 2270 { 2271 string domainId; 2272 std::map<int, CBufferIn*> rankBuffers; 2273 1974 2274 list<CEventServer::SSubEvent>::iterator it; 1975 2275 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 1976 { 2276 { 1977 2277 CBufferIn* buffer = it->buffer; 1978 string domainId;1979 2278 *buffer >> domainId; 1980 get(domainId)->recvLon(it->rank, *buffer); 1981 } 2279 rankBuffers[it->rank] = buffer; 2280 } 2281 get(domainId)->recvLon(rankBuffers); 1982 2282 } 1983 2283 1984 2284 /*! 1985 2285 Receive longitude information from client(s) 1986 \param[in] rank rank of client source 1987 \param[in] buffer message containing longitude info 2286 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 1988 2287 */ 1989 void CDomain::recvLon(int rank, CBufferIn& buffer) 1990 { 1991 CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 1992 CArray<double,1> lon; 1993 CArray<double,2> boundslon; 1994 1995 buffer >> lon; 1996 1997 if (hasBounds) buffer >> boundslon; 1998 1999 int i, j, ind_srv; 2000 for (int ind = 0; ind < indi.numElements(); ind++) 2001 { 2002 i = indi(ind); j = indj(ind); 2003 ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 2004 lonvalue_srv(ind_srv) = lon(ind); 2288 void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers) 2289 { 2290 int nbReceived = rankBuffers.size(), i, ind, index; 2291 if (nbReceived != recvClientRanks_.size()) 2292 ERROR("void CDomain::recvLon(std::map<int, CBufferIn*>& rankBuffers)", 2293 << "The number of sending clients is not correct." 2294 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2295 2296 vector<CArray<double,1> > recvLonValue(nbReceived); 2297 vector<CArray<double,2> > recvBoundsLonValue(nbReceived); 2298 for (i = 0; i < recvClientRanks_.size(); ++i) 2299 { 2300 int rank = recvClientRanks_[i]; 2301 CBufferIn& buffer = *(rankBuffers[rank]); 2302 buffer >> hasLonLat; 2303 buffer >> recvLonValue[i]; 2304 buffer >> hasBounds; 2005 2305 if (hasBounds) 2006 { 2007 for (int nv = 0; nv < nvertex; ++nv) 2008 bounds_lon_srv(nv, ind_srv) = boundslon(nv, ind); 2306 buffer >> recvBoundsLonValue[i]; 2307 } 2308 2309 int nbLonInd = 0; 2310 for (i = 0; i < nbReceived; ++i) 2311 { 2312 nbLonInd += recvLonValue[i].numElements(); 2313 } 2314 2315 lonvalue.resize(nbLonInd); 2316 if (hasBounds) 2317 { 2318 bounds_lonvalue.resize(nvertex, nbLonInd); 2319 } 2320 2321 nbLonInd = 0; 2322 for (i = 0; i < nbReceived; ++i) 2323 { 2324 CArray<double,1>& tmp = recvLonValue[i]; 2325 for (ind = 0; ind < tmp.numElements(); ++ind) 2326 { 2327 lonvalue(nbLonInd) = tmp(ind); 2328 if (hasBounds) 2329 { 2330 CArray<double,2>& tmpBnds = recvBoundsLonValue[i]; 2331 for (int nv = 0; nv < nvertex; ++nv) 2332 bounds_lonvalue(nv, nbLonInd) = tmpBnds(nv, ind); 2333 } 2334 ++nbLonInd; 2009 2335 } 2010 2336 } … … 2017 2343 void CDomain::recvLat(CEventServer& event) 2018 2344 { 2345 string domainId; 2346 std::map<int, CBufferIn*> rankBuffers; 2347 2019 2348 list<CEventServer::SSubEvent>::iterator it; 2020 2349 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2021 { 2350 { 2022 2351 CBufferIn* buffer = it->buffer; 2023 string domainId;2024 2352 *buffer >> domainId; 2025 get(domainId)->recvLat(it->rank, *buffer); 2026 } 2353 rankBuffers[it->rank] = buffer; 2354 } 2355 get(domainId)->recvLat(rankBuffers); 2027 2356 } 2028 2357 2029 2358 /*! 2030 2359 Receive latitude information from client(s) 2031 \param[in] rank rank of client source 2032 \param[in] buffer message containing latitude info 2360 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 2033 2361 */ 2034 void CDomain::recvLat(int rank, CBufferIn& buffer) 2035 { 2036 CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 2037 CArray<double,1> lat; 2038 CArray<double,2> boundslat; 2039 2040 buffer >> lat; 2041 if (hasBounds) buffer >> boundslat; 2042 2043 int i, j, ind_srv; 2044 for (int ind = 0; ind < indi.numElements(); ind++) 2045 { 2046 i = indi(ind); j = indj(ind); 2047 ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 2048 latvalue_srv(ind_srv) = lat(ind); 2362 void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers) 2363 { 2364 int nbReceived = rankBuffers.size(), i, ind, index; 2365 if (nbReceived != recvClientRanks_.size()) 2366 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 2367 << "The number of sending clients is not correct." 2368 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2369 2370 vector<CArray<double,1> > recvLatValue(nbReceived); 2371 vector<CArray<double,2> > recvBoundsLatValue(nbReceived); 2372 for (i = 0; i < recvClientRanks_.size(); ++i) 2373 { 2374 int rank = recvClientRanks_[i]; 2375 CBufferIn& buffer = *(rankBuffers[rank]); 2376 buffer >> hasLonLat; 2377 buffer >> recvLatValue[i]; 2378 buffer >> hasBounds; 2049 2379 if (hasBounds) 2050 { 2051 for (int nv = 0; nv < nvertex; nv++) 2052 bounds_lat_srv(nv, ind_srv) = boundslat(nv, ind); 2380 buffer >> recvBoundsLatValue[i]; 2381 } 2382 2383 int nbLatInd = 0; 2384 for (i = 0; i < nbReceived; ++i) 2385 { 2386 nbLatInd += recvLatValue[i].numElements(); 2387 } 2388 2389 latvalue.resize(nbLatInd); 2390 if (hasBounds) 2391 { 2392 bounds_latvalue.resize(nvertex, nbLatInd); 2393 } 2394 2395 nbLatInd = 0; 2396 for (i = 0; i < nbReceived; ++i) 2397 { 2398 CArray<double,1>& tmp = recvLatValue[i]; 2399 for (ind = 0; ind < tmp.numElements(); ++ind) 2400 { 2401 latvalue(nbLatInd) = tmp(ind); 2402 if (hasBounds) 2403 { 2404 CArray<double,2>& tmpBnds = recvBoundsLatValue[i]; 2405 for (int nv = 0; nv < nvertex; ++nv) 2406 bounds_latvalue(nv, nbLatInd) = tmpBnds(nv, ind); 2407 } 2408 ++nbLatInd; 2053 2409 } 2054 2410 } … … 2061 2417 void CDomain::recvArea(CEventServer& event) 2062 2418 { 2419 string domainId; 2420 std::map<int, CBufferIn*> rankBuffers; 2421 2063 2422 list<CEventServer::SSubEvent>::iterator it; 2064 2423 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2065 { 2424 { 2066 2425 CBufferIn* buffer = it->buffer; 2067 string domainId;2068 2426 *buffer >> domainId; 2069 get(domainId)->recvArea(it->rank, *buffer); 2070 } 2071 } 2427 rankBuffers[it->rank] = buffer; 2428 } 2429 get(domainId)->recvArea(rankBuffers); 2430 } 2431 2072 2432 2073 2433 /*! 2074 2434 Receive area information from client(s) 2075 \param[in] rank rank of client source 2076 \param[in] buffer message containing area info 2435 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 2077 2436 */ 2078 void CDomain::recvArea(int rank, CBufferIn& buffer) 2079 { 2080 CArray<int,1> &indi = indiSrv[rank], &indj = indjSrv[rank]; 2081 CArray<double,1> clientArea; 2082 2083 buffer >> clientArea; 2084 2085 int i, j, ind_srv; 2086 for (int ind = 0; ind < indi.numElements(); ind++) 2087 { 2088 i = indi(ind); j = indj(ind); 2089 ind_srv = (i - zoom_ibegin_srv) + (j - zoom_jbegin_srv) * zoom_ni_srv; 2090 area_srv(ind_srv) = clientArea(ind); 2437 void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers) 2438 { 2439 int nbReceived = rankBuffers.size(), i, ind, index; 2440 if (nbReceived != recvClientRanks_.size()) 2441 ERROR("void CDomain::recvArea(std::map<int, CBufferIn*>& rankBuffers)", 2442 << "The number of sending clients is not correct." 2443 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2444 2445 vector<CArray<double,1> > recvAreaValue(nbReceived); 2446 for (i = 0; i < recvClientRanks_.size(); ++i) 2447 { 2448 int rank = recvClientRanks_[i]; 2449 CBufferIn& buffer = *(rankBuffers[rank]); 2450 buffer >> hasArea; 2451 if (hasArea) 2452 buffer >> recvAreaValue[i]; 2453 } 2454 2455 int nbAreaInd = 0; 2456 for (i = 0; i < nbReceived; ++i) 2457 { 2458 if (hasArea) 2459 nbAreaInd += recvAreaValue[i].numElements(); 2460 } 2461 2462 areavalue.resize(nbAreaInd); 2463 nbAreaInd = 0; 2464 if (hasArea) 2465 { 2466 for (i = 0; i < nbReceived; ++i) 2467 { 2468 CArray<double,1>& tmp = recvAreaValue[i]; 2469 for (ind = 0; ind < tmp.numElements(); ++ind) 2470 { 2471 area(nbAreaInd) = tmp(ind); 2472 ++nbAreaInd; 2473 } 2474 } 2475 } 2476 } 2477 2478 /*! 2479 Receive data index event from clients(s) 2480 \param[in] event event contain info about rank and associated index 2481 */ 2482 void CDomain::recvDataIndex(CEventServer& event) 2483 { 2484 string domainId; 2485 std::map<int, CBufferIn*> rankBuffers; 2486 2487 list<CEventServer::SSubEvent>::iterator it; 2488 for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it) 2489 { 2490 CBufferIn* buffer = it->buffer; 2491 *buffer >> domainId; 2492 rankBuffers[it->rank] = buffer; 2493 } 2494 get(domainId)->recvDataIndex(rankBuffers); 2495 2496 // if (domain->isCompressible_) 2497 // { 2498 // std::sort(domain->indexesToWrite.begin(), domain->indexesToWrite.end()); 2499 2500 // CContextServer* server = CContext::getCurrent()->server; 2501 // domain->numberWrittenIndexes_ = domain->indexesToWrite.size(); 2502 // MPI_Allreduce(&domain->numberWrittenIndexes_, &domain->totalNumberWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 2503 // MPI_Scan(&domain->numberWrittenIndexes_, &domain->offsetWrittenIndexes_, 1, MPI_INT, MPI_SUM, server->intraComm); 2504 // domain->offsetWrittenIndexes_ -= domain->numberWrittenIndexes_; 2505 // } 2506 } 2507 2508 /*! 2509 Receive data index information from client(s) 2510 A client receives data index from different clients to rebuild its own data index. 2511 Because the data index is local, to rebuild data index of received client, we should use global index along with. 2512 \param[in] rankBuffers rank of sending client and the corresponding receive buffer 2513 */ 2514 void CDomain::recvDataIndex(std::map<int, CBufferIn*>& rankBuffers) 2515 { 2516 int nbReceived = rankBuffers.size(), i, ind, index, indexI, type_int; 2517 if (nbReceived != recvClientRanks_.size()) 2518 ERROR("void CDomain::recvLat(std::map<int, CBufferIn*>& rankBuffers)", 2519 << "The number of sending clients is not correct." 2520 << "Expected number: " << recvClientRanks_.size() << " but received " << nbReceived); 2521 2522 vector<CArray<int,1> > recvDataIIndex(nbReceived),recvDataJIndex(nbReceived); 2523 for (i = 0; i < recvClientRanks_.size(); ++i) 2524 { 2525 int rank = recvClientRanks_[i]; 2526 CBufferIn& buffer = *(rankBuffers[rank]); 2527 buffer >> recvDataIIndex[i]; 2528 buffer >> recvDataJIndex[i]; 2529 } 2530 2531 int nbCompressedData = 0; 2532 for (i = 0; i < nbReceived; ++i) 2533 { 2534 CArray<int,1>& tmp = recvDataIIndex[i]; 2535 for (ind = 0; ind < tmp.numElements(); ++ind) 2536 { 2537 index = tmp(ind); 2538 if (0 <= index) 2539 ++nbCompressedData; 2540 } 2541 } 2542 2543 data_i_index.resize(nbCompressedData); 2544 data_j_index.resize(nbCompressedData); 2545 2546 nbCompressedData = 0; 2547 for (i = 0; i < nbReceived; ++i) 2548 { 2549 CArray<int,1>& tmpI = recvDataIIndex[i]; 2550 CArray<int,1>& tmpIndex = indGlob_[recvClientRanks_[i]]; 2551 for (ind = 0; ind < tmpI.numElements(); ++ind) 2552 { 2553 indexI = tmpI(ind); 2554 index = tmpIndex(ind); 2555 if (0 <= indexI) 2556 { 2557 data_i_index(nbCompressedData) = index % ni_glo - ibegin; 2558 data_j_index(nbCompressedData) = index / ni_glo - jbegin; 2559 ++nbCompressedData; 2560 } 2561 } 2091 2562 } 2092 2563 } … … 2123 2594 { 2124 2595 return transformationMap_; 2125 }2126 2127 /*!2128 Check the validity of all transformations applied on domain2129 This functions is called AFTER all inherited attributes are solved2130 */2131 void CDomain::checkTransformations()2132 {2133 TransMapTypes::const_iterator itb = transformationMap_.begin(), it,2134 ite = transformationMap_.end();2135 // for (it = itb; it != ite; ++it)2136 // {2137 // (it->second)->checkValid(this);2138 // }2139 2596 } 2140 2597 -
XIOS/dev/dev_olga/src/node/domain.hpp
r987 r1025 16 16 #include "transformation.hpp" 17 17 #include "transformation_enum.hpp" 18 18 #include "server_distribution_description.hpp" 19 19 #include "mesh.hpp" 20 20 … … 49 49 enum EEventId 50 50 { 51 EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, EVENT_ID_AREA 51 EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 52 EVENT_ID_AREA, EVENT_ID_MASK, 53 EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT 52 54 } ; 53 55 … … 75 77 /// Vérifications /// 76 78 void checkAttributes(void); 77 78 79 void checkAttributesOnClient(); 79 80 void checkAttributesOnClientAfterTransformation(); 80 81 81 void checkEligibilityForCompressedOutput(void); 82 82 … … 100 100 int getOffsetWrittenIndexes() const; 101 101 102 const std::vector<int>& getStartWriteIndex() const; 103 const std::vector<int>& getCountWriteIndex() const; 104 const std::vector<int>& getLocalWriteSize() const; 105 const std::vector<int>& getGlobalWriteSize() const; 106 102 107 std::map<int, StdSize> getAttributesBufferSize(); 103 108 104 109 bool isEmpty(void) const; 105 110 bool isDistributed(void) const; 106 bool isCompressible(void) const; 107 108 int ni_srv,ibegin_srv,iend_srv ; 109 int zoom_ni_srv,zoom_ibegin_srv,zoom_iend_srv ; 110 111 int nj_srv,jbegin_srv,jend_srv ; 112 int zoom_nj_srv,zoom_jbegin_srv,zoom_jend_srv ; 113 114 CArray<double, 1> lonvalue_srv, latvalue_srv ; 115 CArray<double, 2> bounds_lon_srv, bounds_lat_srv ; 116 CArray<double, 1> lonvalue_client, latvalue_client; 117 CArray<double, 2> bounds_lon_client, bounds_lat_client; 118 CArray<double, 1> area_srv; 119 120 vector<int> connectedServer ; // list of connected server 121 vector<int> nbSenders ; // for each communication with a server, number of communicating client 122 vector<int> nbDataSrv ; // size of data to send to each server 123 vector< vector<int> > i_indSrv ; // for each server, i global index to send 124 vector< vector<int> > j_indSrv ; // for each server, j global index to send 111 bool isCompressible(void) const; 112 113 CArray<double, 1> lonvalue, latvalue; 114 CArray<double, 2> bounds_lonvalue, bounds_latvalue; 115 CArray<double, 1> areavalue; 116 117 vector<int> connectedServer ; // list of connected server 118 vector<int> nbSenders ; // for each communication with a server, number of communicating client 119 vector<int> nbDataSrv ; // size of data to send to each server 120 vector< vector<int> > i_indSrv ; // for each server, i global index to send 121 vector< vector<int> > j_indSrv ; // for each server, j global index to send 125 122 126 123 public: … … 128 125 void addRelFile(const StdString & filename); 129 126 void addRelFileCompressed(const StdString& filename); 130 void completeLonLatClient(void); 131 void sendServerAttribut(void) ; 132 void sendLonLatArea(void); 133 void computeConnectedServer(void) ; 127 void completeLonLatClient(void); 128 void computeConnectedClients(); 134 129 135 130 void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, … … 141 136 142 137 static bool dispatchEvent(CEventServer& event); 143 static void recv ServerAttribut(CEventServer& event);138 static void recvDistributionAttributes(CEventServer& event); 144 139 static void recvIndex(CEventServer& event); 140 static void recvMask(CEventServer& event); 141 static void recvZoom(CEventServer& event); 145 142 static void recvLon(CEventServer& event); 146 143 static void recvLat(CEventServer& event); 147 144 static void recvArea(CEventServer& event); 148 void recvServerAttribut(CBufferIn& buffer); 149 void recvIndex(int rank, CBufferIn& buffer); 150 void recvLon(int rank, CBufferIn& buffer); 151 void recvLat(int rank, CBufferIn& buffer); 152 void recvArea(int rank, CBufferIn& buffer); 145 static void recvDataIndex(CEventServer& event); 146 void recvDistributionAttributes(CBufferIn& buffer); 147 void recvZoom(std::vector<int>& rank, std::vector<CBufferIn*>& buffers); 148 void recvIndex(std::map<int, CBufferIn*>& rankBuffers); 149 void recvMask(std::map<int, CBufferIn*>& rankBuffers); 150 void recvLon(std::map<int, CBufferIn*>& rankBuffers); 151 void recvLat(std::map<int, CBufferIn*>& rankBuffers); 152 void recvArea(std::map<int, CBufferIn*>& rankBuffers); 153 void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers); 153 154 154 155 /// Destructeur /// … … 160 161 161 162 static ENodeType GetType(void); 162 const std::map<int, vector<size_t> >& getIndexServer() const;163 const boost::unordered_map<int, vector<size_t> >& getIndexServer() const; 163 164 CArray<bool, 1> localMask; 164 165 bool isCurvilinear ; … … 183 184 void computeLocalMask(void) ; 184 185 185 void checkTransformations(); 186 void setTransformations(const TransMapTypes&); 187 void computeNGlobDomain(); 188 186 void setTransformations(const TransMapTypes&); 187 188 void sendAttributes(); 189 189 void sendIndex(); 190 void sendDistributionAttributes(); 191 void sendMask(); 190 192 void sendArea(); 191 193 void sendLonLat(); 192 193 private: 194 void sendZoom(); 195 void sendDataIndex(); 196 197 private: 198 std::vector<int> start_write_index_; 199 std::vector<int> count_write_index_; 200 std::vector<int> local_write_size_; 201 std::vector<int> global_write_size_; 202 194 203 bool isChecked; 195 204 std::set<StdString> relFiles, relFilesCompressed; 196 205 bool isClientChecked; // Verify whether all attributes of domain on the client side are good 197 206 bool isClientAfterTransformationChecked; 198 std::map<int, CArray<int,1> > indiSrv, indjSrv; 199 std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server 200 std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 207 std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_; 208 std::map<int,int> nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server 209 210 boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server 211 boost::unordered_map<int, vector<size_t> > indZoomSrv_; // Global index of each client sent to server 201 212 std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server 202 213 std::vector<int> indexesToWrite; 214 std::vector<int> recvClientRanks_; 203 215 int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; 204 216 std::vector<int> connectedServerRank_; … … 207 219 bool isCompressible_; 208 220 bool isRedistributed_; 209 TransMapTypes transformationMap_; 210 std::vector<int> nGlobDomain_; 221 TransMapTypes transformationMap_; 211 222 bool isUnstructed_; 223 boost::unordered_map<size_t,size_t> globalLocalIndexMap_; 212 224 213 225 private: -
XIOS/dev/dev_olga/src/node/field.cpp
r1021 r1025 23 23 #include "temporal_filter.hpp" 24 24 #include "spatial_transform_filter.hpp" 25 #include "file_server_writer_filter.hpp" 25 26 26 27 namespace xios{ … … 234 235 void CField::recvUpdateData(CEventServer& event) 235 236 { 236 vector<int> ranks; 237 vector<CBufferIn*> buffers; 237 std::map<int,CBufferIn*> rankBuffers; 238 238 239 239 list<CEventServer::SSubEvent>::iterator it; … … 245 245 CBufferIn* buffer = it->buffer; 246 246 *buffer >> fieldId; 247 ranks.push_back(rank); 248 buffers.push_back(buffer); 249 } 250 get(fieldId)->recvUpdateData(ranks,buffers); 247 rankBuffers[rank] = buffer; 248 } 249 get(fieldId)->recvUpdateData(rankBuffers); 251 250 } 252 251 253 void CField::recvUpdateData( vector<int>& ranks, vector<CBufferIn*>& buffers)252 void CField::recvUpdateData(std::map<int,CBufferIn*>& rankBuffers) 254 253 { 255 254 CContext* context = CContext::getCurrent(); 256 255 257 if (data_srv.empty()) 256 size_t sizeData = 0; 257 if (0 == recvDataSrv.numElements()) 258 { 259 for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 260 { 261 sizeData += it->second.numElements(); 262 } 263 264 // Gather all data from different clients 265 recvDataSrv.resize(sizeData); 266 recvFoperationSrv = boost::shared_ptr<func::CFunctor>(new func::CInstant(recvDataSrv)); 267 } 268 269 CArray<double,1> recv_data_tmp(recvDataSrv.numElements()); 270 sizeData = 0; 271 const CDate& currDate = context->getCalendar()->getCurrentDate(); 272 const CDate opeDate = last_operation_srv +freq_op + freq_operation_srv - freq_op; 273 274 if (opeDate <= currDate) 258 275 { 259 276 for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 260 { 261 int rank = it->first; 262 data_srv.insert(std::make_pair(rank, CArray<double,1>(it->second.numElements()))); 263 foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(data_srv[rank])))); 264 } 265 } 277 { 278 CArray<double,1> tmp; 279 *(rankBuffers[it->first]) >> tmp; 280 recv_data_tmp(Range(sizeData,sizeData+it->second.numElements()-1)) = tmp; 281 sizeData += it->second.numElements(); 282 } 283 } 284 285 this->setData(recv_data_tmp); 286 } 287 288 void CField::writeUpdateData(const CArray<double,1>& data) 289 { 290 CContext* context = CContext::getCurrent(); 266 291 267 292 const CDate& currDate = context->getCalendar()->getCurrentDate(); … … 271 296 if (opeDate <= currDate) 272 297 { 273 for (int n = 0; n < ranks.size(); n++) 274 { 275 CArray<double,1> data_tmp; 276 *buffers[n] >> data_tmp; 277 (*foperation_srv[ranks[n]])(data_tmp); 278 } 298 (*recvFoperationSrv)(data); 279 299 last_operation_srv = currDate; 300 // sendUpdateData(fieldData); 301 // Redirecting data to the correct secondary server 302 //int fileIdx = std::find(context->enabledFiles.begin(), context->enabledFiles.end(), this->file) - context->enabledFiles.begin(); 303 //int srvId = fileIdx % context->clientPrimServer.size(); 304 //sendUpdateData(fieldData, context->clientPrimServer[srvId]); 280 305 } 281 306 282 307 if (writeDate < (currDate + freq_operation_srv)) 283 308 { 284 for (int n = 0; n < ranks.size(); n++) 285 { 286 this->foperation_srv[ranks[n]]->final(); 287 } 288 309 recvFoperationSrv->final(); 289 310 last_Write_srv = writeDate; 290 }291 292 if (context->hasClient && context->hasServer)293 {294 size_t writtenSize;295 // if (field->getUseCompressedOutput())296 // writtenSize = grid->getNumberWrittenIndexes();297 // else298 writtenSize = grid->getWrittenDataSize();299 300 CArray<double,1> fieldData(writtenSize);301 // if (!field->default_value.isEmpty()) fieldData = field->default_value;302 303 // if (field->getUseCompressedOutput())304 // field->outputCompressedField(fieldData);305 // else306 this->outputField(fieldData);307 // sendUpdateData(fieldData);308 // Redirecting data to the correct secondary server309 int fileIdx = std::find(context->enabledFiles.begin(), context->enabledFiles.end(), this->file) - context->enabledFiles.begin();310 int srvId = fileIdx % context->clientPrimServer.size();311 sendUpdateData(fieldData, context->clientPrimServer[srvId]);312 }313 if (!context->hasClient && context->hasServer)314 {315 // size_t writtenSize;316 // if (this->getUseCompressedOutput())317 // writtenSize = grid->getNumberWrittenIndexes();318 // else319 // writtenSize = grid->getWrittenDataSize();320 //321 // CArray<double,1> fieldData(writtenSize);322 323 // if (this->getUseCompressedOutput())324 // this->outputCompressedField(fieldData);325 // else326 // this->outputField(fieldData);327 311 writeField(); 328 } 329 330 lastlast_Write_srv = last_Write_srv; 331 312 lastlast_Write_srv = last_Write_srv; 313 } 332 314 } 315 316 // void CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 317 // { 318 // CContext* context = CContext::getCurrent(); 319 320 // if (data_srv.empty()) 321 // { 322 // for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it) 323 // { 324 // int rank = it->first; 325 // data_srv.insert(std::make_pair(rank, CArray<double,1>(it->second.numElements()))); 326 // foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(data_srv[rank])))); 327 // } 328 // } 329 330 // const CDate& currDate = context->getCalendar()->getCurrentDate(); 331 // const CDate opeDate = last_operation_srv +freq_op + freq_operation_srv - freq_op; 332 // const CDate writeDate = last_Write_srv + freq_write_srv; 333 334 // if (opeDate <= currDate) 335 // { 336 // for (int n = 0; n < ranks.size(); n++) 337 // { 338 // CArray<double,1> data_tmp; 339 // *buffers[n] >> data_tmp; 340 // (*foperation_srv[ranks[n]])(data_tmp); 341 // } 342 // last_operation_srv = currDate; 343 // } 344 345 // if (writeDate < (currDate + freq_operation_srv)) 346 // { 347 // for (int n = 0; n < ranks.size(); n++) 348 // { 349 // this->foperation_srv[ranks[n]]->final(); 350 // } 351 352 // last_Write_srv = writeDate; 353 // } 354 355 // if (context->hasClient && context->hasServer) 356 // { 357 // size_t writtenSize; 358 // // if (field->getUseCompressedOutput()) 359 // // writtenSize = grid->getNumberWrittenIndexes(); 360 // // else 361 // writtenSize = grid->getWrittenDataSize(); 362 363 // CArray<double,1> fieldData(writtenSize); 364 // // if (!field->default_value.isEmpty()) fieldData = field->default_value; 365 366 // // if (field->getUseCompressedOutput()) 367 // // field->outputCompressedField(fieldData); 368 // // else 369 // this->outputField(fieldData); 370 // sendUpdateData(fieldData); 371 // } 372 // if (!context->hasClient && context->hasServer) 373 // { 374 // writeField(); 375 // } 376 377 // lastlast_Write_srv = last_Write_srv; 378 379 // } 333 380 334 381 void CField::writeField(void) … … 656 703 657 704 //---------------------------------------------------------------- 658 659 void CField::solveOnlyReferenceEnabledField(bool doSending2Server)660 {661 CContext* context = CContext::getCurrent();662 if (!isReferenceSolved)663 {664 isReferenceSolved = true;665 666 if (context->hasClient && !context->hasServer)667 // if (context->hasClient)668 {669 solveRefInheritance(true);670 if (hasDirectFieldReference()) getDirectFieldReference()->solveOnlyReferenceEnabledField(false);671 }672 // else if (context->hasServer)673 if (context->hasServer)674 solveServerOperation();675 676 solveGridReference();677 678 if (context->hasClient && !context->hasServer)679 // if (context->hasClient)680 {681 solveGenerateGrid();682 buildGridTransformationGraph();683 }684 }685 }686 705 687 706 /*! … … 784 803 } 785 804 } 786 805 806 void CField::solveAllEnabledFields() 807 { 808 CContext* context = CContext::getCurrent(); 809 bool hasClient = context->hasClient; 810 bool hasServer = context->hasServer; 811 812 if (!isReferenceSolved) 813 { 814 isReferenceSolved = true; 815 816 if (hasClient && !hasServer) 817 { 818 solveRefInheritance(true); 819 if (hasDirectFieldReference()) getDirectFieldReference()->solveAllEnabledFields(); 820 } 821 822 if (hasServer) 823 solveServerOperation(); 824 825 solveGridReference(); 826 827 if (hasClient && !hasServer) 828 { 829 solveGenerateGrid(); 830 buildGridTransformationGraph(); 831 } 832 833 solveGridDomainAxisRef(false); 834 835 if (hasClient && !hasServer) 836 { 837 solveTransformedGrid(); 838 } 839 840 solveGridDomainAxisRef(false); 841 } 842 } 843 844 void CField::checkGridOfEnabledFields() 845 { 846 solveCheckMaskIndex(false); 847 } 848 849 void CField::sendGridOfEnabledFields() 850 { 851 solveGridDomainAxisRef(true); 852 solveCheckMaskIndex(true); 853 } 854 855 856 void CField::solveOnlyReferenceEnabledField(bool doSending2Server) 857 { 858 CContext* context = CContext::getCurrent(); 859 if (!isReferenceSolved) 860 { 861 isReferenceSolved = true; 862 863 if (context->hasClient && !context->hasServer) 864 // if (context->hasClient) 865 { 866 solveRefInheritance(true); 867 if (hasDirectFieldReference()) getDirectFieldReference()->solveOnlyReferenceEnabledField(false); 868 } 869 // else if (context->hasServer) 870 if (context->hasServer) 871 solveServerOperation(); 872 873 solveGridReference(); 874 875 if (context->hasClient && !context->hasServer) 876 // if (context->hasClient) 877 { 878 solveGenerateGrid(); 879 buildGridTransformationGraph(); 880 } 881 } 882 } 883 787 884 void CField::solveAllReferenceEnabledField(bool doSending2Server) 788 885 { … … 794 891 areAllReferenceSolved = true; 795 892 796 //if (context->hasClient)893 // if (context->hasClient) 797 894 if (context->hasClient && !context->hasServer) 798 895 { … … 800 897 if (hasDirectFieldReference()) getDirectFieldReference()->solveAllReferenceEnabledField(false); 801 898 } 802 //else if (context->hasServer)803 if (context->hasServer && !context->hasClient)899 else if (context->hasServer) 900 // if (context->hasServer && !context->hasClient) 804 901 solveServerOperation(); 805 902 … … 885 982 void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput) 886 983 { 887 if (!areAllReferenceSolved) solveAllReferenceEnabledField(false); 888 889 // Start by building a filter which can provide the field's instant data 890 if (!instantDataFilter) 891 { 892 // Check if we have an expression to parse 984 // if (!areAllReferenceSolved) solveAllReferenceEnabledField(false); 985 if (!isReferenceSolved) solveAllEnabledFields(); 986 CContext* context = CContext::getCurrent(); 987 bool hasWriterServer = context->hasServer && !context->hasClient; 988 bool hasIntermediateServer = context->hasServer && context->hasClient; 989 990 if (hasWriterServer) 991 { 992 if (!instantDataFilter) 993 instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 994 995 // If the field data is to be read by the client or/and written to a file 996 if (enableOutput && !storeFilter && !fileWriterFilter) 997 { 998 if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write)) 999 { 1000 fileServerWriterFilter = boost::shared_ptr<CFileServerWriterFilter>(new CFileServerWriterFilter(gc, this)); 1001 instantDataFilter->connectOutput(fileServerWriterFilter, 0); 1002 } 1003 } 1004 } 1005 else if (hasIntermediateServer) 1006 { 1007 if (!instantDataFilter) 1008 instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid)); 1009 1010 // If the field data is to be read by the client or/and written to a file 1011 if (enableOutput && !storeFilter && !fileWriterFilter) 1012 { 1013 if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write)) 1014 { 1015 fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this)); 1016 instantDataFilter->connectOutput(fileWriterFilter, 0); 1017 } 1018 } 1019 } 1020 else 1021 { 1022 // Start by building a filter which can provide the field's instant data 1023 if (!instantDataFilter) 1024 { 1025 // Check if we have an expression to parse 893 1026 if (hasExpression()) 894 {1027 { 895 1028 boost::scoped_ptr<IFilterExprNode> expr(parseExpr(getExpression() + '\0')); 896 1029 boost::shared_ptr<COutputPin> filter = expr->reduce(gc, *this); … … 912 1045 913 1046 instantDataFilter = filter; 914 }915 // Check if we have a reference on another field916 else if (!field_ref.isEmpty())917 instantDataFilter = getFieldReference(gc);918 // Check if the data is to be read from a file919 else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read)1047 } 1048 // Check if we have a reference on another field 1049 else if (!field_ref.isEmpty()) 1050 instantDataFilter = getFieldReference(gc); 1051 // Check if the data is to be read from a file 1052 else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read) 920 1053 instantDataFilter = serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid, 921 1054 freq_offset.isEmpty() ? NoneDu : freq_offset, 922 1055 true)); 923 else // The data might be passed from the model1056 else // The data might be passed from the model 924 1057 instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(gc, grid)); 925 } 926 927 // If the field data is to be read by the client or/and written to a file 928 if (enableOutput && !storeFilter && !fileWriterFilter) 929 { 930 if (!read_access.isEmpty() && read_access) 931 { 932 storeFilter = boost::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid)); 933 instantDataFilter->connectOutput(storeFilter, 0); 934 } 935 936 if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write)) 937 { 938 fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this)); 939 getTemporalDataFilter(gc, file->output_freq)->connectOutput(fileWriterFilter, 0);