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