source: XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp @ 1236

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

Making some changes to allow pools with different number of server

+) Associate context client to each grid distribution (This should be changed in the future)
+) Correct some buffer size estimation
+) Clean some redundant code and add comments

  • 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
  • Property svn:executable set to *
File size: 7.1 KB
Line 
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
19namespace 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() const;
72         int getTotalNumberWrittenIndexes() const;
73         int getOffsetWrittenIndexes() const;
74
75         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client);
76
77         /// Test ///
78         bool IsWritten(const StdString & filename) const;
79         bool isWrittenCompressed(const StdString& filename) const;
80         bool isDistributed(void) const;
81         bool isCompressible(void) const;
82
83         /// Mutateur ///
84         void addRelFile(const StdString & filename);
85         void addRelFileCompressed(const StdString& filename);
86
87         /// Vérifications ///
88         void checkAttributes(void);
89
90         /// Destructeur ///
91         virtual ~CAxis(void);
92
93         virtual void parse(xml::CXMLNode & node);
94
95         /// Accesseurs statiques ///
96         static StdString GetName(void);
97         static StdString GetDefName(void);
98         static ENodeType GetType(void);
99
100         static bool dispatchEvent(CEventServer& event);         
101         
102         void checkAttributesOnClient();
103         void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid,
104                                                         CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION);
105         void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
106                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
107
108         void checkEligibilityForCompressedOutput();
109         size_t getGlobalWrittenSize(void) ;
110
111         void computeWrittenIndex();
112         bool hasTransformation();
113         void solveInheritanceTransformation();
114         TransMapTypes getAllTransformations();         
115         void duplicateTransformation(CAxis*);
116         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id="");
117         bool isEqual(CAxis* axis);
118         bool zoomByIndex();
119
120      public: 
121        bool hasValue;       
122        CArray<size_t,1> localIndexToWriteOnServer;
123        CArray<int, 1> compressedIndexToWriteOnServer;
124
125      private:
126         void checkData();
127         void checkMask();
128         void checkZoom();
129         void checkBounds();
130         void checkLabel();
131         void sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
132                             CServerDistributionDescription::ServerDistributionType distType);
133         void sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid,
134                                        CServerDistributionDescription::ServerDistributionType distType);
135         void computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid,
136                                     CServerDistributionDescription::ServerDistributionType distType);
137
138         void sendNonDistributedAttributes(void);
139         void sendDistributedAttributes(void);
140
141         static void recvNonDistributedAttributes(CEventServer& event);
142         static void recvDistributedAttributes(CEventServer& event);
143         static void recvDistributionAttribute(CEventServer& event);
144         void recvNonDistributedAttributes(int rank, CBufferIn& buffer);
145         void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers);
146         void recvDistributionAttribute(CBufferIn& buffer);
147
148         void setTransformations(const TransMapTypes&);
149
150      private:
151         bool isChecked;
152         bool areClientAttributesChecked_;
153         bool isClientAfterTransformationChecked;
154         std::set<StdString> relFiles, relFilesCompressed;
155         TransMapTypes transformationMap_;         
156         //! True if and only if the data defined on the axis can be outputted in a compressed way
157         bool isCompressible_;
158         std::map<CContextClient*, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
159         std::map<CContextClient*, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
160         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
161         boost::unordered_map<size_t,size_t> globalLocalIndexMap_;
162         std::vector<int> indexesToWrite;
163         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
164         std::map<CContextClient*, std::vector<int> > connectedServerRank_;         
165         bool hasBounds;
166         bool hasLabel;         
167         bool computedWrittenIndex_;                 
168
169       private:
170         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
171         static std::map<StdString, ETranformationType> transformationMapList_;
172         static bool dummyTransformationMapList_;
173
174         DECLARE_REF_FUNC(Axis,axis)
175   }; // class CAxis
176
177   ///--------------------------------------------------------------
178
179   // Declare/Define CAxisGroup and CAxisDefinition
180   DECLARE_GROUP(CAxis);
181} // namespace xios
182
183#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.