[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 | { |
---|
[633] | 47 | EVENT_ID_SERVER_ATTRIBUT, |
---|
| 48 | EVENT_ID_INDEX, |
---|
| 49 | EVENT_ID_DISTRIBUTED_VALUE, |
---|
[1025] | 50 | EVENT_ID_NON_DISTRIBUTED_VALUE, |
---|
| 51 | EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES, |
---|
| 52 | EVENT_ID_DISTRIBUTED_ATTRIBUTES |
---|
[567] | 53 | } ; |
---|
| 54 | |
---|
[219] | 55 | |
---|
[987] | 56 | |
---|
[219] | 57 | public : |
---|
| 58 | |
---|
| 59 | typedef CAxisAttributes RelAttributes; |
---|
| 60 | typedef CAxisGroup RelGroup; |
---|
[621] | 61 | typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; |
---|
[219] | 62 | |
---|
[621] | 63 | public: |
---|
[219] | 64 | /// Constructeurs /// |
---|
| 65 | CAxis(void); |
---|
| 66 | explicit CAxis(const StdString & id); |
---|
| 67 | CAxis(const CAxis & axis); // Not implemented yet. |
---|
| 68 | CAxis(const CAxis * const axis); // Not implemented yet. |
---|
| 69 | |
---|
[622] | 70 | static CAxis* createAxis(); |
---|
| 71 | |
---|
[219] | 72 | /// Accesseurs /// |
---|
| 73 | const std::set<StdString> & getRelFiles(void) const; |
---|
| 74 | |
---|
[676] | 75 | const std::vector<int>& getIndexesToWrite(void) const; |
---|
| 76 | int getNumberWrittenIndexes() const; |
---|
| 77 | int getTotalNumberWrittenIndexes() const; |
---|
| 78 | int getOffsetWrittenIndexes() const; |
---|
| 79 | |
---|
[1025] | 80 | int getStartWriteIndex() const; |
---|
| 81 | int getCountWriteIndex() const; |
---|
| 82 | int getLocalWriteSize() const; |
---|
| 83 | int getGlobalWriteSize() const; |
---|
| 84 | |
---|
[731] | 85 | std::map<int, StdSize> getAttributesBufferSize(); |
---|
| 86 | |
---|
[219] | 87 | /// Test /// |
---|
| 88 | bool IsWritten(const StdString & filename) const; |
---|
[676] | 89 | bool isWrittenCompressed(const StdString& filename) const; |
---|
[594] | 90 | bool isDistributed(void) const; |
---|
[676] | 91 | bool isCompressible(void) const; |
---|
[219] | 92 | |
---|
| 93 | /// Mutateur /// |
---|
| 94 | void addRelFile(const StdString & filename); |
---|
[676] | 95 | void addRelFileCompressed(const StdString& filename); |
---|
[219] | 96 | |
---|
| 97 | /// Vérifications /// |
---|
| 98 | void checkAttributes(void); |
---|
| 99 | |
---|
| 100 | /// Destructeur /// |
---|
| 101 | virtual ~CAxis(void); |
---|
| 102 | |
---|
[619] | 103 | virtual void parse(xml::CXMLNode & node); |
---|
| 104 | |
---|
[219] | 105 | /// Accesseurs statiques /// |
---|
| 106 | static StdString GetName(void); |
---|
| 107 | static StdString GetDefName(void); |
---|
| 108 | static ENodeType GetType(void); |
---|
| 109 | |
---|
[1025] | 110 | // void sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 111 | // CServerDistributionDescription::ServerDistributionType distType); |
---|
[567] | 112 | static bool dispatchEvent(CEventServer& event); |
---|
| 113 | static void recvServerAttribut(CEventServer& event); |
---|
[1025] | 114 | // void recvServerAttribut(CBufferIn& buffer) ; |
---|
[742] | 115 | void checkAttributesOnClient(); |
---|
[927] | 116 | void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 117 | CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
[567] | 118 | void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 119 | CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
[619] | 120 | |
---|
[676] | 121 | void checkEligibilityForCompressedOutput(); |
---|
| 122 | |
---|
[619] | 123 | bool hasTransformation(); |
---|
| 124 | void solveInheritanceTransformation(); |
---|
[621] | 125 | TransMapTypes getAllTransformations(); |
---|
[775] | 126 | void fillInValues(const CArray<double,1>& values); |
---|
[836] | 127 | void duplicateTransformation(CAxis*); |
---|
| 128 | CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
[619] | 129 | |
---|
[567] | 130 | public: |
---|
| 131 | int zoom_begin_srv, zoom_end_srv, zoom_size_srv; |
---|
| 132 | int ni_srv, begin_srv, end_srv; |
---|
[633] | 133 | CArray<double,1> value_srv; |
---|
| 134 | CArray<double,2> bound_srv; |
---|
[816] | 135 | bool hasValue; |
---|
[987] | 136 | CArray<int,1> globalDimGrid; |
---|
| 137 | int orderPosInGrid; |
---|
[676] | 138 | |
---|
| 139 | private: |
---|
[551] | 140 | void checkData(); |
---|
| 141 | void checkMask(); |
---|
[631] | 142 | void checkZoom(); |
---|
[1025] | 143 | void checkBounds(); |
---|
| 144 | void sendAttributes(); |
---|
[815] | 145 | void computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 146 | CServerDistributionDescription::ServerDistributionType distType); |
---|
[595] | 147 | |
---|
[1025] | 148 | void sendNonDistributedAttributes(void); |
---|
| 149 | void sendDistributedAttributes(void); |
---|
[619] | 150 | |
---|
[1025] | 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); |
---|
| 155 | |
---|
[621] | 156 | void setTransformations(const TransMapTypes&); |
---|
[676] | 157 | |
---|
[567] | 158 | private: |
---|
[219] | 159 | bool isChecked; |
---|
[567] | 160 | bool areClientAttributesChecked_; |
---|
[927] | 161 | bool isClientAfterTransformationChecked; |
---|
[676] | 162 | std::set<StdString> relFiles, relFilesCompressed; |
---|
[621] | 163 | TransMapTypes transformationMap_; |
---|
[594] | 164 | bool isDistributed_; |
---|
[676] | 165 | //! True if and only if the data defined on the axis can be outputted in a compressed way |
---|
| 166 | bool isCompressible_; |
---|
[633] | 167 | std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server |
---|
[1025] | 168 | boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server |
---|
[676] | 169 | std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server |
---|
[1025] | 170 | boost::unordered_map<size_t,size_t> globalLocalIndexMap_; |
---|
[676] | 171 | std::vector<int> indexesToWrite; |
---|
| 172 | int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; |
---|
[633] | 173 | std::vector<int> connectedServerRank_; |
---|
| 174 | std::map<int, CArray<int,1> > indiSrv_; |
---|
| 175 | bool hasBounds_; |
---|
[836] | 176 | |
---|
[1025] | 177 | int start_write_index_; |
---|
| 178 | int count_write_index_; |
---|
| 179 | int local_write_size_; |
---|
| 180 | int global_write_size_; |
---|
| 181 | |
---|
[836] | 182 | private: |
---|
| 183 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
| 184 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
| 185 | static bool dummyTransformationMapList_; |
---|
| 186 | |
---|
[540] | 187 | DECLARE_REF_FUNC(Axis,axis) |
---|
[219] | 188 | }; // class CAxis |
---|
| 189 | |
---|
| 190 | ///-------------------------------------------------------------- |
---|
| 191 | |
---|
| 192 | // Declare/Define CAxisGroup and CAxisDefinition |
---|
| 193 | DECLARE_GROUP(CAxis); |
---|
[335] | 194 | } // namespace xios |
---|
[219] | 195 | |
---|
[591] | 196 | #endif // __XIOS_CAxis__ |
---|