source: XIOS/dev/dev_olga/src/node/domain.hpp @ 1099

Last change on this file since 1099 was 1099, checked in by mhnguyen, 7 years ago

Updating 2-level server

+) Make some changes in the way data rebuilt on each level of server
+) Make some changes in the order of functions call during close context to make sure that each server receives the global indexes before calculating index to send to next level
+) Modify some functions to make sure data sent to the correct server pool

Test
+) On Curie
+) Only test_client

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 8.9 KB
Line 
1#ifndef __XIOS_CDomain__
2#define __XIOS_CDomain__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "group_factory.hpp"
7
8#include "declare_group.hpp"
9#include "declare_ref_func.hpp"
10#include "event_client.hpp"
11#include "event_server.hpp"
12#include "buffer_in.hpp"
13#include "array_new.hpp"
14#include "attribute_array.hpp"
15#include "attribute_enum.hpp"
16#include "transformation.hpp"
17#include "transformation_enum.hpp"
18#include "server_distribution_description.hpp"
19#include "mesh.hpp"
20
21namespace xios {
22
23   /// ////////////////////// Déclarations ////////////////////// ///
24
25   class CDomainGroup;
26   class CDomainAttributes;
27   class CDomain;
28   class CFile;
29
30   ///--------------------------------------------------------------
31
32   // Declare/Define CDomainAttribute
33   BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain)
34#  include "domain_attribute.conf"
35#  include "domain_attribute_private.conf"
36   END_DECLARE_ATTRIBUTE_MAP(CDomain)
37
38   ///--------------------------------------------------------------
39
40   class CDomain
41      : public CObjectTemplate<CDomain>
42      , public CDomainAttributes
43   {
44               /// typedef ///
45         typedef CObjectTemplate<CDomain>   SuperClass;
46         typedef CDomainAttributes SuperClassAttribute;
47         
48      public :
49         enum EEventId
50         {
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
54         } ;
55
56
57
58      public:
59
60         typedef CDomainAttributes RelAttributes;
61         typedef CDomainGroup      RelGroup;
62         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
63
64         /// Constructeurs ///
65         CDomain(void);
66         explicit CDomain(const StdString & id);
67         CDomain(const CDomain & domain);       // Not implemented yet.
68         CDomain(const CDomain * const domain); // Not implemented yet.
69
70         static CDomain* createDomain();
71         
72         CMesh* mesh;
73         void assignMesh(const StdString, const int);
74       
75         virtual void parse(xml::CXMLNode & node);
76
77         /// Vérifications ///
78         void checkAttributes(void);
79         void checkAttributesOnClient();
80         void checkAttributesOnClientAfterTransformation();
81         void checkEligibilityForCompressedOutput(void);
82
83         void sendCheckedAttributes();
84
85         bool hasTransformation();
86         void solveInheritanceTransformation();
87         TransMapTypes getAllTransformations();
88         void redistribute(int nbLocalDomain);
89         void duplicateTransformation(CDomain*);
90         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
91
92      public:
93         const std::set<StdString> & getRelFiles(void) const;
94         bool IsWritten(const StdString & filename) const;
95         bool isWrittenCompressed(const StdString& filename) const;
96
97         const std::vector<int>& getIndexesToWrite(void) const;
98         int getNumberWrittenIndexes() const;
99         int getTotalNumberWrittenIndexes() const;
100         int getOffsetWrittenIndexes() const;
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
107         std::map<int, StdSize> getAttributesBufferSize();
108
109         bool isEmpty(void) const;
110         bool isDistributed(void) const;
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
122
123      public:
124         /// Mutateur ///
125         void addRelFile(const StdString & filename);
126         void addRelFileCompressed(const StdString& filename);
127         void completeLonLatClient(void);         
128         void computeConnectedClients();
129
130         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
131                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
132
133         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
134                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
135         void fillInRectilinearLonLat();
136
137         static bool dispatchEvent(CEventServer& event);
138         static void recvDistributionAttributes(CEventServer& event);
139         static void recvIndex(CEventServer& event);
140         static void recvMask(CEventServer& event);
141         static void recvZoom(CEventServer& event);
142         static void recvLon(CEventServer& event);
143         static void recvLat(CEventServer& event);
144         static void recvArea(CEventServer& event);
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);
154
155         /// Destructeur ///
156         virtual ~CDomain(void);
157
158         /// Accesseurs statiques ///
159         static StdString GetName(void);
160         static StdString GetDefName(void);
161
162         static ENodeType GetType(void);
163         const boost::unordered_map<int, vector<size_t> >& getIndexServer() const;
164         CArray<bool, 1> localMask;
165         bool isCurvilinear ;
166         bool hasBounds ;
167         bool hasArea;
168         bool hasLonLat;
169         bool hasPole ;
170
171      private:
172         void checkDomain(void);
173         void checkLocalIDomain(void);
174         void checkLocalJDomain(void);
175
176         void checkMask(void);
177         void checkDomainData(void);
178         void checkCompression(void);
179
180         void checkBounds(void);
181         void checkArea(void);
182         void checkLonLat();
183         void checkZoom(void);
184         void computeLocalMask(void) ;
185
186         void setTransformations(const TransMapTypes&);         
187
188         void sendAttributes();
189         void sendIndex();
190         void sendDistributionAttributes();
191         void sendMask();
192         void sendArea();
193         void sendLonLat();
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
203         bool doZoomByIndex_;
204         bool isChecked;
205         std::set<StdString> relFiles, relFilesCompressed;
206         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
207         bool isClientAfterTransformationChecked;
208         std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_;
209         std::map<int,int> nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server
210
211         boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server
212         boost::unordered_map<int, vector<size_t> > indZoomSrv_; // Global index of each client sent to server
213         std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
214         std::vector<int> indexesToWrite;
215         std::vector<int> recvClientRanks_;
216         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
217         std::vector<int> connectedServerRank_;
218         bool isDistributed_;
219         //! True if and only if the data defined on the domain can be outputted in a compressed way
220         bool isCompressible_;
221         bool isRedistributed_;
222         TransMapTypes transformationMap_;         
223         bool isUnstructed_;
224         boost::unordered_map<size_t,size_t> globalLocalIndexMap_;
225       
226       private:
227         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
228         static std::map<StdString, ETranformationType> transformationMapList_;
229         static bool _dummyTransformationMapList;
230
231         DECLARE_REF_FUNC(Domain,domain)
232
233   }; // class CDomain
234
235   ///--------------------------------------------------------------
236
237   // Declare/Define CDomainGroup and CDomainDefinition
238   DECLARE_GROUP(CDomain);
239
240   ///--------------------------------------------------------------
241
242} // namespace xios
243
244#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.