source: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp @ 1930

Last change on this file since 1930 was 1930, checked in by ymipsl, 4 years ago

Big update on on going work related to data distribution and transfer between clients and servers.
Revisite of the source and store filter using "connectors".

YM

  • 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: 12.3 KB
RevLine 
[591]1#ifndef __XIOS_CAxis__
2#define __XIOS_CAxis__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]6#include "group_factory.hpp"
[619]7#include "virtual_node.hpp"
[219]8
9#include "declare_group.hpp"
[540]10#include "declare_ref_func.hpp"
[619]11#include "declare_virtual_node.hpp"
[369]12#include "attribute_array.hpp"
[399]13#include "attribute_enum.hpp"
14#include "attribute_enum_impl.hpp"
[567]15#include "server_distribution_description.hpp"
[619]16#include "transformation.hpp"
17#include "transformation_enum.hpp"
[1918]18#include "element.hpp"
19#include "local_connector.hpp"
[1930]20#include "scatterer_connector.hpp"
21#include "gatherer_connector.hpp"
22#include "distribution_type.hpp"
[219]23
[1930]24
[335]25namespace xios {
[219]26   /// ////////////////////// Déclarations ////////////////////// ///
27
28   class CAxisGroup;
29   class CAxisAttributes;
30   class CAxis;
31
32   ///--------------------------------------------------------------
33
34   // Declare/Define CAxisAttribute
35   BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis)
[231]36#  include "axis_attribute.conf"
[219]37   END_DECLARE_ATTRIBUTE_MAP(CAxis)
38
39   ///--------------------------------------------------------------
40
41   class CAxis
42      : public CObjectTemplate<CAxis>
43      , public CAxisAttributes
44   {
[987]45               /// typedef ///
46         typedef CObjectTemplate<CAxis>   SuperClass;
47         typedef CAxisAttributes SuperClassAttribute;
48         
[1235]49      public:
[567]50         enum EEventId
51         {
[1144]52           EVENT_ID_DISTRIBUTION_ATTRIBUTE,           
[633]53           EVENT_ID_DISTRIBUTED_VALUE,
[1025]54           EVENT_ID_NON_DISTRIBUTED_VALUE,
55           EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES,
[1930]56           EVENT_ID_DISTRIBUTED_ATTRIBUTES,
57           EVENT_ID_AXIS_DISTRIBUTION,
58           EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE
[567]59         } ;
60
[1235]61      public:
[219]62         typedef CAxisAttributes RelAttributes;
63         typedef CAxisGroup      RelGroup;
[621]64         typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes;
[219]65
[621]66      public:
[219]67         /// Constructeurs ///
68         CAxis(void);
69         explicit CAxis(const StdString & id);
70         CAxis(const CAxis & axis);       // Not implemented yet.
71         CAxis(const CAxis * const axis); // Not implemented yet.
72
[622]73         static CAxis* createAxis();
[1158]74
75         /// Accesseurs ///
76         const std::set<StdString> & getRelFiles(void) const;
77
[1639]78         int getNumberWrittenIndexes(MPI_Comm writtenCom);
79         int getTotalNumberWrittenIndexes(MPI_Comm writtenCom);
80         int getOffsetWrittenIndexes(MPI_Comm writtenCom);
81         CArray<int, 1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom);
[676]82
[1371]83         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
84                                                        CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
[731]85
[219]86         /// Test ///
87         bool IsWritten(const StdString & filename) const;
[676]88         bool isWrittenCompressed(const StdString& filename) const;
[594]89         bool isDistributed(void) const;
[676]90         bool isCompressible(void) const;
[219]91
92         /// Mutateur ///
93         void addRelFile(const StdString & filename);
[676]94         void addRelFileCompressed(const StdString& filename);
[219]95
[1869]96         
[219]97
98         /// Destructeur ///
99         virtual ~CAxis(void);
100
[619]101         virtual void parse(xml::CXMLNode & node);
102
[1345]103         void setContextClient(CContextClient* contextClient);
104
[219]105         /// Accesseurs statiques ///
106         static StdString GetName(void);
107         static StdString GetDefName(void);
108         static ENodeType GetType(void);
109
[1235]110         static bool dispatchEvent(CEventServer& event);         
[1869]111       
112         /// Vérifications ///
113         void checkAttributes(void);
114         bool checkAttributes_done_ = false ;
[1235]115         
[742]116         void checkAttributesOnClient();
[927]117         void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid,
118                                                         CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION);
[567]119         void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
120                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
[619]121
[676]122         void checkEligibilityForCompressedOutput();
[1215]123         size_t getGlobalWrittenSize(void) ;
[676]124
[1129]125         void computeWrittenIndex();
[1639]126         void computeWrittenCompressedIndex(MPI_Comm);
[619]127         bool hasTransformation();
128         void solveInheritanceTransformation();
[1144]129         TransMapTypes getAllTransformations();         
[836]130         void duplicateTransformation(CAxis*);
131         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id="");
[1158]132         bool isEqual(CAxis* axis);
[619]133
[1235]134      public: 
135        bool hasValue;       
[1558]136        bool hasBounds;
137        bool hasLabel;
138
[1637]139        CArray<int,1> localIndexToWriteOnServer;
[1869]140         
141         void computeConnectedClients(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid);
142         private: std::set<CContextClient*> computeConnectedClients_done_ ; public :
143         /** The number of server of a context client. Avoid to re-compute indice computed in a previous computeConnectedClient */
144         private: std::set<int> listNbServer_ ; public:
[676]145
146      private:
[551]147         void checkData();
148         void checkMask();
[1158]149         void checkBounds();
150         void checkLabel();
[1870]151      public:
152         void sendAxisToFileServer(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid) ;
153      private:
154         std::set<CContextClient*> sendAxisToFileServer_done_ ;
155     
[1875]156      public:
157         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
[1870]158      private:
[1875]159         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
160   
161      public:
162         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
163
164      private:
[1870]165         void sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
[1875]166                             CServerDistributionDescription::ServerDistributionType distType, const string& axisId="");
[1870]167         void sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
[1875]168                                        CServerDistributionDescription::ServerDistributionType distType, const string& axisId="");
[1869]169         
[595]170
[1875]171         void sendNonDistributedAttributes(CContextClient* client, const string& axisId="");
[1930]172         void sendDistributedAttributes_old(CContextClient* client, const string& axisId="");
[619]173
[1025]174         static void recvNonDistributedAttributes(CEventServer& event);
[1930]175         static void recvDistributedAttributes_old(CEventServer& event);
[1235]176         static void recvDistributionAttribute(CEventServer& event);
[1025]177         void recvNonDistributedAttributes(int rank, CBufferIn& buffer);
[1930]178         void recvDistributedAttributes_old(vector<int>& rank, vector<CBufferIn*> buffers);
[1235]179         void recvDistributionAttribute(CBufferIn& buffer);
[1025]180
[621]181         void setTransformations(const TransMapTypes&);
[676]182
[567]183      private:
[1345]184
[1875]185/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
[1353]186         std::list<CContextClient*> clients;
187         std::set<CContextClient*> clientsSet;
[1345]188
[1875]189      private:
[1869]190         /** define if the axis is completed or not ie all attributes have been received before in case
191             of grid reading from file or coupling */ 
192         bool isCompleted_=true ; 
[1875]193      public:     
194         /*!
195           \brief Check if a axis is completed
196           Before make any axis processing, we must be sure that all axis informations have
197           been sent, for exemple when reading a grid in a file or when grid elements are sent by an
198           other context (coupling). So all direct reference of the axis (axis_ref) must be also completed
199           \return true if axis and axis reference are completed
200          */
201         bool isCompleted(void)
202         {
203           if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false;
204           else return isCompleted_ ;
205         }
206         void setCompleted(void) { isCompleted_=true ; }
207         void unsetCompleted(void) { isCompleted_=false ; }
208     
209      private:
[219]210         bool isChecked;
[567]211         bool areClientAttributesChecked_;
[927]212         bool isClientAfterTransformationChecked;
[676]213         std::set<StdString> relFiles, relFilesCompressed;
[1143]214         TransMapTypes transformationMap_;         
[676]215         //! True if and only if the data defined on the axis can be outputted in a compressed way
216         bool isCompressible_;
[1869]217
[1337]218         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
[1542]219         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
[1236]220         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
[1542]221         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
[1249]222         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
223         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;
[1337]224         std::map<int, std::vector<int> > connectedServerRank_;
[1235]225         bool computedWrittenIndex_;                 
[1099]226
[836]227       private:
228         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
229         static std::map<StdString, ETranformationType> transformationMapList_;
230         static bool dummyTransformationMapList_;
231
[1918]232
[1930]233       //////////////////////////////////////////////////////////////////////////////////////
234       //  this part is related to distribution, element definition, views and connectors  //
235       //////////////////////////////////////////////////////////////////////////////////////
[1918]236         
237        private:
238         CLocalElement* localElement_ = nullptr ;
239         void initializeLocalElement(void) ;
240        public: 
241         CLocalElement* getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; }
242         CLocalView* getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;}
243        private:
244         void addFullView(void) ;
245         void addWorkflowView(void) ;
246         void addModelView(void) ;
247
248        private:
249         CLocalConnector* modelToWorkflowConnector_ ;
250         void computeModelToWorkflowConnector(void)  ;
251        public:
252         CLocalConnector* getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;}
[1930]253       
254       public:
255         void computeRemoteElement(CContextClient* client, EDistributionType) ;
256         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, const string& axisId="") ;
[1918]257
[1930]258         static void recvAxisDistribution(CEventServer& event) ;
259         void receivedAxisDistribution(CEventServer& event, int phasis) ;
[1918]260
[1930]261         void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& axisId) ;
262         static void recvDistributedAttributes(CEventServer& event) ;
263         void recvDistributedAttributes(CEventServer& event, const string& type) ;
264       private:
265         map<CContextClient*, CDistributedElement*> remoteElement_ ;
266       public: 
267         CDistributedElement* getRemoteElement(CContextClient* client) {return remoteElement_[client] ;}
268       private:
269         map<CContextClient*, CScattererConnector*> clientToServerConnector_ ;
270       public: 
271         CScattererConnector* getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;}
272       private:
273         CGathererConnector*  gathererConnector_ ;
274         CGathererConnector* serverFromClientConnector_ ;
275         CDistributedElement* elementFrom_ ;
276       public:
277        CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
278
279
280
[540]281         DECLARE_REF_FUNC(Axis,axis)
[219]282   }; // class CAxis
283
284   ///--------------------------------------------------------------
285
286   // Declare/Define CAxisGroup and CAxisDefinition
287   DECLARE_GROUP(CAxis);
[335]288} // namespace xios
[219]289
[591]290#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.