[591] | 1 | #ifndef __XIOS_CAxis__ |
---|
| 2 | #define __XIOS_CAxis__ |
---|
[219] | 3 | |
---|
[591] | 4 | /// XIOS headers /// |
---|
| 5 | #include "xios_spl.hpp" |
---|
[219] | 6 | #include "group_factory.hpp" |
---|
[619] | 7 | #include "virtual_node.hpp" |
---|
[219] | 8 | |
---|
| 9 | #include "declare_group.hpp" |
---|
[540] | 10 | #include "declare_ref_func.hpp" |
---|
[619] | 11 | #include "declare_virtual_node.hpp" |
---|
[369] | 12 | #include "attribute_array.hpp" |
---|
[399] | 13 | #include "attribute_enum.hpp" |
---|
| 14 | #include "attribute_enum_impl.hpp" |
---|
[567] | 15 | #include "server_distribution_description.hpp" |
---|
[619] | 16 | #include "transformation.hpp" |
---|
| 17 | #include "transformation_enum.hpp" |
---|
[219] | 18 | |
---|
[335] | 19 | namespace xios { |
---|
[219] | 20 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 21 | |
---|
| 22 | class CAxisGroup; |
---|
| 23 | class CAxisAttributes; |
---|
| 24 | class CAxis; |
---|
| 25 | |
---|
| 26 | ///-------------------------------------------------------------- |
---|
| 27 | |
---|
| 28 | // Declare/Define CAxisAttribute |
---|
| 29 | BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) |
---|
[231] | 30 | # include "axis_attribute.conf" |
---|
[821] | 31 | # include "axis_attribute_private.conf" |
---|
[219] | 32 | END_DECLARE_ATTRIBUTE_MAP(CAxis) |
---|
| 33 | |
---|
| 34 | ///-------------------------------------------------------------- |
---|
| 35 | |
---|
| 36 | class CAxis |
---|
| 37 | : public CObjectTemplate<CAxis> |
---|
| 38 | , public CAxisAttributes |
---|
| 39 | { |
---|
[987] | 40 | /// typedef /// |
---|
| 41 | typedef CObjectTemplate<CAxis> SuperClass; |
---|
| 42 | typedef CAxisAttributes SuperClassAttribute; |
---|
| 43 | |
---|
| 44 | public : |
---|
[567] | 45 | enum EEventId |
---|
| 46 | { |
---|
[1144] | 47 | EVENT_ID_DISTRIBUTION_ATTRIBUTE, |
---|
[633] | 48 | EVENT_ID_DISTRIBUTED_VALUE, |
---|
[1025] | 49 | EVENT_ID_NON_DISTRIBUTED_VALUE, |
---|
| 50 | EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES, |
---|
| 51 | EVENT_ID_DISTRIBUTED_ATTRIBUTES |
---|
[567] | 52 | } ; |
---|
| 53 | |
---|
[219] | 54 | |
---|
[987] | 55 | |
---|
[219] | 56 | public : |
---|
| 57 | |
---|
| 58 | typedef CAxisAttributes RelAttributes; |
---|
| 59 | typedef CAxisGroup RelGroup; |
---|
[621] | 60 | typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; |
---|
[219] | 61 | |
---|
[621] | 62 | public: |
---|
[219] | 63 | /// Constructeurs /// |
---|
| 64 | CAxis(void); |
---|
| 65 | explicit CAxis(const StdString & id); |
---|
| 66 | CAxis(const CAxis & axis); // Not implemented yet. |
---|
| 67 | CAxis(const CAxis * const axis); // Not implemented yet. |
---|
| 68 | |
---|
[622] | 69 | static CAxis* createAxis(); |
---|
[1158] | 70 | |
---|
| 71 | /// Accesseurs /// |
---|
| 72 | const std::set<StdString> & getRelFiles(void) const; |
---|
| 73 | |
---|
[676] | 74 | int getNumberWrittenIndexes() const; |
---|
| 75 | int getTotalNumberWrittenIndexes() const; |
---|
| 76 | int getOffsetWrittenIndexes() const; |
---|
| 77 | |
---|
[731] | 78 | std::map<int, StdSize> getAttributesBufferSize(); |
---|
| 79 | |
---|
[219] | 80 | /// Test /// |
---|
| 81 | bool IsWritten(const StdString & filename) const; |
---|
[676] | 82 | bool isWrittenCompressed(const StdString& filename) const; |
---|
[594] | 83 | bool isDistributed(void) const; |
---|
[676] | 84 | bool isCompressible(void) const; |
---|
[219] | 85 | |
---|
| 86 | /// Mutateur /// |
---|
| 87 | void addRelFile(const StdString & filename); |
---|
[676] | 88 | void addRelFileCompressed(const StdString& filename); |
---|
[219] | 89 | |
---|
| 90 | /// Vérifications /// |
---|
| 91 | void checkAttributes(void); |
---|
| 92 | |
---|
| 93 | /// Destructeur /// |
---|
| 94 | virtual ~CAxis(void); |
---|
| 95 | |
---|
[619] | 96 | virtual void parse(xml::CXMLNode & node); |
---|
| 97 | |
---|
[219] | 98 | /// Accesseurs statiques /// |
---|
| 99 | static StdString GetName(void); |
---|
| 100 | static StdString GetDefName(void); |
---|
| 101 | static ENodeType GetType(void); |
---|
| 102 | |
---|
[567] | 103 | static bool dispatchEvent(CEventServer& event); |
---|
[1099] | 104 | static void recvDistributionAttribute(CEventServer& event); |
---|
| 105 | void recvDistributionAttribute(CBufferIn& buffer) ; |
---|
[742] | 106 | void checkAttributesOnClient(); |
---|
[927] | 107 | void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 108 | CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
[567] | 109 | void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 110 | CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
[619] | 111 | |
---|
[676] | 112 | void checkEligibilityForCompressedOutput(); |
---|
| 113 | |
---|
[1129] | 114 | void computeWrittenIndex(); |
---|
[619] | 115 | bool hasTransformation(); |
---|
| 116 | void solveInheritanceTransformation(); |
---|
[1144] | 117 | TransMapTypes getAllTransformations(); |
---|
[836] | 118 | void duplicateTransformation(CAxis*); |
---|
| 119 | CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
[1158] | 120 | bool isEqual(CAxis* axis); |
---|
[619] | 121 | |
---|
[567] | 122 | public: |
---|
| 123 | int zoom_begin_srv, zoom_end_srv, zoom_size_srv; |
---|
| 124 | int ni_srv, begin_srv, end_srv; |
---|
[633] | 125 | CArray<double,1> value_srv; |
---|
| 126 | CArray<double,2> bound_srv; |
---|
[1158] | 127 | CArray<StdString,1> label_srv; |
---|
[816] | 128 | bool hasValue; |
---|
[987] | 129 | CArray<int,1> globalDimGrid; |
---|
| 130 | int orderPosInGrid; |
---|
[1129] | 131 | CArray<size_t,1> localIndexToWriteOnServer; |
---|
[1143] | 132 | CArray<int, 1> compressedIndexToWriteOnServer; |
---|
[676] | 133 | |
---|
| 134 | private: |
---|
[551] | 135 | void checkData(); |
---|
| 136 | void checkMask(); |
---|
[631] | 137 | void checkZoom(); |
---|
[1158] | 138 | void checkBounds(); |
---|
| 139 | void checkLabel(); |
---|
[1099] | 140 | void sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 141 | CServerDistributionDescription::ServerDistributionType distType); |
---|
| 142 | void sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 143 | CServerDistributionDescription::ServerDistributionType distType); |
---|
[815] | 144 | void computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 145 | CServerDistributionDescription::ServerDistributionType distType); |
---|
[595] | 146 | |
---|
[1025] | 147 | void sendNonDistributedAttributes(void); |
---|
| 148 | void sendDistributedAttributes(void); |
---|
[619] | 149 | |
---|
[1025] | 150 | static void recvNonDistributedAttributes(CEventServer& event); |
---|
| 151 | static void recvDistributedAttributes(CEventServer& event); |
---|
| 152 | void recvNonDistributedAttributes(int rank, CBufferIn& buffer); |
---|
| 153 | void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers); |
---|
| 154 | |
---|
[621] | 155 | void setTransformations(const TransMapTypes&); |
---|
[676] | 156 | |
---|
[567] | 157 | private: |
---|
[219] | 158 | bool isChecked; |
---|
[567] | 159 | bool areClientAttributesChecked_; |
---|
[927] | 160 | bool isClientAfterTransformationChecked; |
---|
[676] | 161 | std::set<StdString> relFiles, relFilesCompressed; |
---|
[1143] | 162 | TransMapTypes transformationMap_; |
---|
[676] | 163 | //! True if and only if the data defined on the axis can be outputted in a compressed way |
---|
| 164 | bool isCompressible_; |
---|
[633] | 165 | std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server |
---|
[1025] | 166 | boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server |
---|
[676] | 167 | std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server |
---|
[1025] | 168 | boost::unordered_map<size_t,size_t> globalLocalIndexMap_; |
---|
[676] | 169 | std::vector<int> indexesToWrite; |
---|
| 170 | int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; |
---|
[633] | 171 | std::vector<int> connectedServerRank_; |
---|
| 172 | std::map<int, CArray<int,1> > indiSrv_; |
---|
| 173 | bool hasBounds_; |
---|
[1158] | 174 | bool hasLabel; |
---|
[1099] | 175 | bool doZoomByIndex_; |
---|
[1129] | 176 | bool computedWrittenIndex_; |
---|
[1099] | 177 | |
---|
[836] | 178 | private: |
---|
| 179 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
| 180 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
| 181 | static bool dummyTransformationMapList_; |
---|
| 182 | |
---|
[540] | 183 | DECLARE_REF_FUNC(Axis,axis) |
---|
[219] | 184 | }; // class CAxis |
---|
| 185 | |
---|
| 186 | ///-------------------------------------------------------------- |
---|
| 187 | |
---|
| 188 | // Declare/Define CAxisGroup and CAxisDefinition |
---|
| 189 | DECLARE_GROUP(CAxis); |
---|
[335] | 190 | } // namespace xios |
---|
[219] | 191 | |
---|
[591] | 192 | #endif // __XIOS_CAxis__ |
---|