source: XIOS3/trunk/src/node/axis.hpp @ 2397

Last change on this file since 2397 was 2397, checked in by ymipsl, 22 months ago
  • Optimize remote connector computation in case of read (reverse way).
  • don't compute anymore clientFromServerConnector (and all intermediate computation) for non reading case.

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.5 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"
[1984]18#include "transformation_path.hpp"
[1918]19#include "element.hpp"
20#include "local_connector.hpp"
[1930]21#include "scatterer_connector.hpp"
22#include "gatherer_connector.hpp"
23#include "distribution_type.hpp"
[1984]24#include "generic_algorithm_transformation.hpp"
[2274]25#include "grid_transformation_factory_impl.hpp"
[219]26
[1930]27
[1984]28namespace xios
29{
[219]30   /// ////////////////////// Déclarations ////////////////////// ///
31
32   class CAxisGroup;
33   class CAxisAttributes;
34   class CAxis;
[2206]35   class CField;
[219]36
37   ///--------------------------------------------------------------
38
39   // Declare/Define CAxisAttribute
40   BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis)
[231]41#  include "axis_attribute.conf"
[219]42   END_DECLARE_ATTRIBUTE_MAP(CAxis)
43
44   ///--------------------------------------------------------------
45
46   class CAxis
47      : public CObjectTemplate<CAxis>
48      , public CAxisAttributes
49   {
[987]50               /// typedef ///
51         typedef CObjectTemplate<CAxis>   SuperClass;
52         typedef CAxisAttributes SuperClassAttribute;
53         
[1235]54      public:
[567]55         enum EEventId
56         {
[2326]57           EVENT_ID_COLLECTIVE=100,
[1930]58           EVENT_ID_AXIS_DISTRIBUTION,
[2326]59           EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE,
60           EVENT_ID_NO_COLLECTIVE=1000,
[567]61         } ;
62
[1235]63      public:
[219]64         typedef CAxisAttributes RelAttributes;
65         typedef CAxisGroup      RelGroup;
66
[621]67      public:
[219]68         /// Constructeurs ///
69         CAxis(void);
70         explicit CAxis(const StdString & id);
71         CAxis(const CAxis & axis);       // Not implemented yet.
72         CAxis(const CAxis * const axis); // Not implemented yet.
[2274]73         static void releaseStaticAllocation(void) ; // release static allocation on heap
[219]74
[622]75         static CAxis* createAxis();
[2206]76         static CAxis* get(const string& id, bool noError=false) ; //<! return axis pointer using id
77         static bool has(const string& id) ; //<! return domain pointer using id
78         static CField*  getFieldFromId(const string& id) ;
[1158]79
80         /// Accesseurs ///
81         const std::set<StdString> & getRelFiles(void) const;
[1975]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;
[1956]90       
[1984]91      public:
[1956]92        /*!
93            \brief return if the axis can be written or not in a compressed way.
94            ie if there are some masked or indexed point on the domain. Valid only on server side.
95            \return true if domain can be writtedn in a compressed way
96         */ 
97         bool isCompressible(void) { if (!isCompressibleComputed_) computeIsCompressible() ; return isCompressible_ ;} 
[1984]98      private:
[1956]99         bool isCompressible_ ; /** specify if the domain can be written in a compressed way */ 
100         bool isCompressibleComputed_=false ; /** Indicate if compressability has been computed*/
101         void computeIsCompressible() ;
102       
[1984]103      public:
[219]104
105         /// Mutateur ///
106         void addRelFile(const StdString & filename);
[676]107         void addRelFileCompressed(const StdString& filename);
[219]108
[1869]109         
[219]110
111         /// Destructeur ///
112         virtual ~CAxis(void);
113
[619]114         virtual void parse(xml::CXMLNode & node);
115
[1345]116         void setContextClient(CContextClient* contextClient);
117
[219]118         /// Accesseurs statiques ///
119         static StdString GetName(void);
120         static StdString GetDefName(void);
121         static ENodeType GetType(void);
122
[1235]123         static bool dispatchEvent(CEventServer& event);         
[1869]124       
125         /// Vérifications ///
126         void checkAttributes(void);
127         bool checkAttributes_done_ = false ;
[2291]128         bool checkGeometricAttributes(bool generateError) ; 
129         void setGeometricAttributes(const CAxis& axisSrc) ;
130         void resetGeometricAttributes(void) ;
[619]131
[2388]132         size_t computeAttributesHash( MPI_Comm comm );
[2389]133         void renameAttributesBeforeWriting(CAxis* writtenAxis=NULL);
[2386]134
[1215]135         size_t getGlobalWrittenSize(void) ;
[676]136
[1984]137      //////////////////////////
138      ///// transformations ////
139      //////////////////////////
140      public:
141        typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes;
142      private:
143        static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
144        static std::map<StdString, ETranformationType> transformationMapList_;
145        static bool dummyTransformationMapList_;
146        TransMapTypes transformationMap_;         
147
148      public:
149        CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id="");
150        CTransformation<CAxis>* addTransformation(ETranformationType transType, CTransformation<CAxis>* transformation) ;
151        void setTransformations(const TransMapTypes&);         
152        void duplicateTransformation(CAxis*);
153        TransMapTypes getAllTransformations();
154        bool hasTransformation();
155        void solveInheritanceTransformation_old(); // to remove later
156        void solveInheritanceTransformation();
157      private:
158        bool solveInheritanceTransformation_done_= false ;
[2206]159      public:
160        bool activateFieldWorkflow(CGarbageCollector& gc) ;
[1984]161      private:
[2206]162        bool activateFieldWorkflow_done_=false ;
163      private:
[2270]164        shared_ptr<CGenericAlgorithmTransformation> transformationAlgorithm_ = nullptr ;
[1984]165      public:
[2270]166        void setTransformationAlgorithm(shared_ptr<CGenericAlgorithmTransformation> transformationAlgorithm) { transformationAlgorithm_=transformationAlgorithm ;}
167        shared_ptr<CGenericAlgorithmTransformation> getTransformationAlgorithm(void) { return transformationAlgorithm_ ;}   
[1984]168      private:
169        CTransformationPaths transformationPaths_ ;
170      public:
171        CTransformationPaths getTransformationPaths(void) {return transformationPaths_;} 
172        void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;}
173
174      ////////////////////////////
[1158]175         bool isEqual(CAxis* axis);
[619]176
[1235]177      public: 
178        bool hasValue;       
[1558]179        bool hasBounds;
180        bool hasLabel;
181
[1984]182      private:
[2291]183         bool checkData(bool generateError);
184         bool checkMask(bool generateError);
185         bool checkBounds(bool generateError);
186         bool checkLabel(bool generateError);
[1870]187     
[1875]188      public:
189         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
[1870]190      private:
[1875]191         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
192   
193      public:
194         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
[2022]195         string getCouplingAlias(const string& fieldId, int posInGrid) ;
[1875]196
[567]197      private:
[1345]198
[1875]199/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
[1353]200         std::list<CContextClient*> clients;
201         std::set<CContextClient*> clientsSet;
[1345]202
[1875]203      private:
[1869]204         /** define if the axis is completed or not ie all attributes have been received before in case
205             of grid reading from file or coupling */ 
206         bool isCompleted_=true ; 
[1875]207      public:     
208         /*!
209           \brief Check if a axis is completed
210           Before make any axis processing, we must be sure that all axis informations have
211           been sent, for exemple when reading a grid in a file or when grid elements are sent by an
212           other context (coupling). So all direct reference of the axis (axis_ref) must be also completed
213           \return true if axis and axis reference are completed
214          */
215         bool isCompleted(void)
216         {
217           if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false;
218           else return isCompleted_ ;
[2282]219
220           MISSING_RETURN( "bool CAxis::isCompleted() " );
221           return true;
[1875]222         }
223         void setCompleted(void) { isCompleted_=true ; }
224         void unsetCompleted(void) { isCompleted_=false ; }
225     
226      private:
[219]227         bool isChecked;
[676]228         std::set<StdString> relFiles, relFilesCompressed;
[1984]229          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
[1337]230         std::map<int, std::vector<int> > connectedServerRank_;
[1099]231
[1930]232       //////////////////////////////////////////////////////////////////////////////////////
233       //  this part is related to distribution, element definition, views and connectors  //
234       //////////////////////////////////////////////////////////////////////////////////////
[1918]235         
236        private:
[2267]237         shared_ptr<CLocalElement> localElement_ ;
[1918]238         void initializeLocalElement(void) ;
239        public: 
[2267]240         shared_ptr<CLocalElement> getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; }
241         shared_ptr<CLocalView> getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;}
[1918]242        private:
243         void addFullView(void) ;
244         void addWorkflowView(void) ;
245         void addModelView(void) ;
246
247        private:
[2267]248         shared_ptr<CLocalConnector> modelToWorkflowConnector_ ;
[1918]249         void computeModelToWorkflowConnector(void)  ;
250        public:
[2267]251         shared_ptr<CLocalConnector> getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;}
[1930]252       
253       public:
254         void computeRemoteElement(CContextClient* client, EDistributionType) ;
[2397]255         void distributeToServer(CContextClient* client, bool inOut, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn, 
[2304]256                                 shared_ptr<CScattererConnector>& scattererConnector, const string& axisId="") ;
[1918]257
[1930]258         static void recvAxisDistribution(CEventServer& event) ;
259         void receivedAxisDistribution(CEventServer& event, int phasis) ;
[1943]260         void setServerMask(CArray<bool,1>& serverMask, CContextClient* client ) ;
[2267]261         void sendDistributedAttributes(CContextClient* client, shared_ptr<CScattererConnector> scattererConnector, const string& axisId) ;
[1930]262         static void recvDistributedAttributes(CEventServer& event) ;
263         void recvDistributedAttributes(CEventServer& event, const string& type) ;
264       private:
[2267]265         map<CContextClient*, shared_ptr<CDistributedElement>> remoteElement_ ;
[1930]266       public: 
[2267]267         shared_ptr<CDistributedElement> getRemoteElement(CContextClient* client) {return remoteElement_[client] ;}
[1930]268       private:
[2267]269         map<CContextClient*, shared_ptr<CScattererConnector>> clientToServerConnector_ ;
[1930]270       public: 
[2267]271         shared_ptr<CScattererConnector> getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;}
[1930]272       private:
[2267]273         shared_ptr<CGathererConnector>  gathererConnector_ ;
[1943]274       public:
[2267]275         shared_ptr<CGathererConnector> getGathererConnector(void) { return gathererConnector_ ;}
[1943]276       private:
[2267]277         shared_ptr<CGathererConnector> serverFromClientConnector_ ;
278         shared_ptr<CDistributedElement> elementFrom_ ;
[1930]279       public:
[2267]280        shared_ptr<CGathererConnector> getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
[1930]281
[1934]282       private:
[2267]283         shared_ptr<CScattererConnector> serverToClientConnector_ = nullptr ;
[2304]284         shared_ptr<CDistributedElement> elementTo_ ;
[1934]285       public: 
[2267]286         shared_ptr<CScattererConnector> getServerToClientConnector(void) { return serverToClientConnector_ ;} 
[1930]287
[1934]288       private:
[2267]289          map<CContextClient*,shared_ptr<CGathererConnector>>  clientFromServerConnector_  ;
[1934]290       public: 
[2267]291        shared_ptr<CGathererConnector> getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} 
[1930]292
[540]293         DECLARE_REF_FUNC(Axis,axis)
[219]294   }; // class CAxis
295
296   ///--------------------------------------------------------------
297
298   // Declare/Define CAxisGroup and CAxisDefinition
299   DECLARE_GROUP(CAxis);
[335]300} // namespace xios
[219]301
[591]302#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.