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