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

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

Updating two-level server.
Each client now can play the role of server: It can forward data to other clients or write data like a server.
Each client must combine all data received from other client(s) before forward them or write them on files

+) Correct some bugs of exchange data_index in domain and axis
+) Reorder some functions in context.cpp to make sure that all necessary attributes are available before computing index
+) Add the mapping index for client to write data.

Test
+) On Curie
+) test_client and test_complete
+) Mode:

  • Only one level: Correct
  • Two levels: Work if using ddt (bug)

+) Only zoom is tested but other transformations should work
+) No reading test

  • 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: 9.2 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           EVENT_ID_INDEX_ZOOM
55         } ;
56
57
58
59      public:
60
61         typedef CDomainAttributes RelAttributes;
62         typedef CDomainGroup      RelGroup;
63         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
64
65         /// Constructeurs ///
66         CDomain(void);
67         explicit CDomain(const StdString & id);
68         CDomain(const CDomain & domain);       // Not implemented yet.
69         CDomain(const CDomain * const domain); // Not implemented yet.
70
71         static CDomain* createDomain();
72         
73         CMesh* mesh;
74         void assignMesh(const StdString, const int);
75       
76         virtual void parse(xml::CXMLNode & node);
77
78         /// Vérifications ///
79         void checkAttributes(void);
80         void checkAttributesOnClient();
81         void checkAttributesOnClientAfterTransformation();
82         void checkEligibilityForCompressedOutput(void);
83
84         void sendCheckedAttributes();
85
86         bool hasTransformation();
87         void solveInheritanceTransformation();
88         TransMapTypes getAllTransformations();
89         void redistribute(int nbLocalDomain);
90         void duplicateTransformation(CDomain*);
91         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
92
93      public:
94         const std::set<StdString> & getRelFiles(void) const;
95         bool IsWritten(const StdString & filename) const;
96         bool isWrittenCompressed(const StdString& filename) const;
97
98         const std::vector<int>& getIndexesToWrite(void) const;
99         int getNumberWrittenIndexes() const;
100         int getTotalNumberWrittenIndexes() const;
101         int getOffsetWrittenIndexes() const;
102
103         const std::vector<int>& getStartWriteIndex() const;
104         const std::vector<int>& getCountWriteIndex() const;
105         const std::vector<int>& getLocalWriteSize() const;
106         const std::vector<int>& getGlobalWriteSize() const;
107
108         std::map<int, StdSize> getAttributesBufferSize();
109         CArray<size_t,1> localIndexToWriteOnServer;
110
111         bool isEmpty(void) const;
112         bool isDistributed(void) const;
113         bool isCompressible(void) const; 
114 
115         CArray<double, 1> lonvalue, latvalue;
116         CArray<double, 2> bounds_lonvalue, bounds_latvalue;
117         CArray<double, 1> areavalue;
118
119         vector<int> connectedServer ; // list of connected server
120         vector<int> nbSenders ; // for each communication with a server, number of communicating client
121         vector<int> nbDataSrv ; // size of data to send to each server
122         vector< vector<int> > i_indSrv ; // for each server, i global index to send
123         vector< vector<int> > j_indSrv ; // for each server, j global index to send
124
125      public:
126         /// Mutateur ///
127         void addRelFile(const StdString & filename);
128         void addRelFileCompressed(const StdString& filename);
129         void completeLonLatClient(void);         
130         void computeConnectedClients();
131         void computeWrittenIndex();
132
133         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
134                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
135
136         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
137                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
138         void fillInRectilinearLonLat();
139
140         static bool dispatchEvent(CEventServer& event);
141         static void recvDistributionAttributes(CEventServer& event);
142         static void recvIndex(CEventServer& event);
143         static void recvIndexZoom(CEventServer& event);
144         static void recvMask(CEventServer& event);
145         static void recvZoom(CEventServer& event);
146         static void recvLon(CEventServer& event);
147         static void recvLat(CEventServer& event);
148         static void recvArea(CEventServer& event);
149         static void recvDataIndex(CEventServer& event);
150         void recvDistributionAttributes(CBufferIn& buffer);                 
151         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);
152         void recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers);
153         void recvMask(std::map<int, CBufferIn*>& rankBuffers);
154         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
155         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
156         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
157         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
158
159         /// Destructeur ///
160         virtual ~CDomain(void);
161
162         /// Accesseurs statiques ///
163         static StdString GetName(void);
164         static StdString GetDefName(void);
165
166         static ENodeType GetType(void);
167         const boost::unordered_map<int, vector<size_t> >& getIndexServer() const;
168         CArray<bool, 1> localMask;
169         bool isCurvilinear ;
170         bool hasBounds ;
171         bool hasArea;
172         bool hasLonLat;
173         bool hasPole ;
174
175      private:
176         void checkDomain(void);
177         void checkLocalIDomain(void);
178         void checkLocalJDomain(void);
179
180         void checkMask(void);
181         void checkDomainData(void);
182         void checkCompression(void);
183
184         void checkBounds(void);
185         void checkArea(void);
186         void checkLonLat();
187         void checkZoom(void);
188         void computeLocalMask(void) ;
189
190         void setTransformations(const TransMapTypes&);         
191
192         void sendAttributes();
193         void sendIndex();
194         void sendDistributionAttributes();
195         void sendMask();
196         void sendArea();
197         void sendLonLat();
198         void sendIndexZoom();
199         void sendDataIndex();
200
201         void convertLonLatValue();
202
203       private:         
204         std::vector<int> start_write_index_;
205         std::vector<int> count_write_index_;
206         std::vector<int> local_write_size_;
207         std::vector<int> global_write_size_;
208
209         bool doZoomByIndex_;
210         bool isChecked, computedWrittenIndex_;
211         std::set<StdString> relFiles, relFilesCompressed;
212         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
213         bool isClientAfterTransformationChecked;
214         std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_, indGlobZoom_;
215         std::map<int,int> nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server
216
217         boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server
218         boost::unordered_map<int, vector<size_t> > indZoomSrv_; // Global index of each client sent to server
219         std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
220         std::vector<int> indexesToWrite;
221         std::vector<int> recvClientRanks_, recvClientZoomRanks_;
222         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
223         std::vector<int> connectedServerRank_, connectedServerZoomRank_;
224         bool isDistributed_;
225         //! True if and only if the data defined on the domain can be outputted in a compressed way
226         bool isCompressible_;
227         bool isRedistributed_;
228         TransMapTypes transformationMap_;         
229         bool isUnstructed_;
230         boost::unordered_map<size_t,size_t> globalLocalIndexMap_, globalLocalIndexZoomMap_;
231       
232       private:
233         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
234         static std::map<StdString, ETranformationType> transformationMapList_;
235         static bool _dummyTransformationMapList;
236
237         DECLARE_REF_FUNC(Domain,domain)
238
239   }; // class CDomain
240
241   ///--------------------------------------------------------------
242
243   // Declare/Define CDomainGroup and CDomainDefinition
244   DECLARE_GROUP(CDomain);
245
246   ///--------------------------------------------------------------
247
248} // namespace xios
249
250#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.