Ignore:
Timestamp:
11/13/14 15:09:14 (9 years ago)
Author:
mhnguyen
Message:

Implementing buffer size auto-detection for mode client -server

+) Process xml tree in client side then send all the information to server
+) Only information enabled fields in enabled files are sent to server
+) Some important change in structure of code which must be refactored

Test
+) On Curie
+) Only mode client-server
+) Passed for all tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/context.hpp

    r501 r509  
    1818   class CContextClient ; 
    1919   class CContextServer ; 
    20     
    21     
     20 
     21 
    2222   /// ////////////////////// Déclarations ////////////////////// /// 
    2323   class CContextGroup; 
     
    3333 
    3434   ///-------------------------------------------------------------- 
    35  
     35  /*! 
     36  \class CContext 
     37   This class corresponds to the concrete presentation of context in xml file and in play an essential role in XIOS 
     38   Each object of this class contains all root definition of elements: files, fiels, domains, axis, etc, ... from which 
     39   we can have access to each element. 
     40   In fact, every thing must a be inside a particuliar context. After the xml file (iodef.xml) is parsed, 
     41   object of the class is created and its contains all information of other elements in the xml file. 
     42  */ 
    3643   class CContext 
    3744      : public CObjectTemplate<CContext> 
     
    4249         { 
    4350           EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, 
    44            EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE 
     51           EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 
     52           EVENT_ID_POST_PROCESS 
    4553         } ; 
    46           
     54 
    4755         /// typedef /// 
    4856         typedef CObjectTemplate<CContext>   SuperClass; 
     
    7078 
    7179      public : 
    72        
     80 
    7381         /// Mutateurs /// 
    7482         void setCalendar(boost::shared_ptr<CCalendar> newCalendar); 
    75        
     83 
    7684         /// Accesseurs /// 
    7785         boost::shared_ptr<CCalendar>      getCalendar(void) const; 
    7886 
    79          /// Accesseurs statiques /// 
    80          static StdString GetName(void); 
    81          static StdString GetDefName(void);          
    82          static ENodeType GetType(void);          
    83  
    84          static CContextGroup* GetContextGroup(void); 
    85  
    86       public : 
    87  
    88          /// Traitements /// 
    89          virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); 
    90          void solveFieldRefInheritance(bool apply); 
    91          void solveCalendar(void); 
    92  
    93          /// Autres méthodes statiques /// 
    94          static void ShowTree(StdOStream & out = std::clog); 
    95          static void CleanTree(void); 
    96  
    97          /// Test /// 
    98          virtual bool hasChild(void) const; 
    99  
     87      public : 
     88         // Initialize server or client 
     89         void initServer(MPI_Comm intraComm, MPI_Comm interComm) ; 
     90         void initClient(MPI_Comm intraComm, MPI_Comm interComm) ; 
     91         bool isInitialized(void) ; 
     92 
     93         // Put sever or client into loop state 
    10094         bool eventLoop(void) ; 
    10195         bool serverLoop(void) ; 
    10296         void clientLoop(void) ; 
    103          void initServer(MPI_Comm intraComm, MPI_Comm interComm) ; 
    104          void initClient(MPI_Comm intraComm, MPI_Comm interComm) ; 
    105          bool isInitialized(void) ; 
    106          CContextServer* server ; 
    107          CContextClient* client ; 
    108          bool hasClient ; 
    109          bool hasServer ; 
     97 
     98         // Process all information of calendar 
     99         void solveCalendar(void); 
     100 
     101         // Finalize a context 
    110102         void finalize(void) ; 
    111103         void closeDefinition(void) ; 
     104 
     105         // Some functions to process context 
    112106         void findAllEnabledFields(void); 
    113107         void processEnabledFiles(void) ; 
    114          void solveAllGridRef(void); 
    115          void solveAllOperation(void); 
    116          void solveAllExpression(void); 
    117108         void solveAllInheritance(bool apply=true) ; 
    118109         void findEnabledFiles(void); 
     
    120111         void updateCalendar(int step) ; 
    121112         void createFileHeader(void ) ; 
    122       // dispatch event 
    123          static bool dispatchEvent(CEventServer& event) ; 
     113         void solveAllRefOfEnabledFields(bool sendToServer); 
     114         void buildAllExpressionOfEnabledFields(); 
     115         void postProcessing(); 
     116 
     117         std::map<int, StdSize>& getDataSize(); 
     118         void setClientServerBuffer(); 
     119 
     120         // Send context close definition 
    124121         void sendCloseDefinition(void) ; 
     122         // There are something to send on closing context defintion 
    125123         void sendUpdateCalendar(int step) ; 
    126124         void sendCreateFileHeader(void) ; 
     125         void sendEnabledFiles(); 
     126         void sendEnabledFields(); 
     127         void sendRefDomainsAxis(); 
     128         void sendRefGrid(); 
     129         void sendPostProcessing(); 
     130 
     131         // Client side: Receive and process messages 
    127132         static void recvUpdateCalendar(CEventServer& event) ; 
    128133         void recvUpdateCalendar(CBufferIn& buffer) ; 
     
    130135         static void recvCreateFileHeader(CEventServer& event) ; 
    131136         void recvCreateFileHeader(CBufferIn& buffer) ; 
    132          static CContext* getCurrent(void) ; 
    133          static CContextGroup* getRoot(void) ; 
    134          static void setCurrent(const string& id) ; 
    135          static CContext* create(const string& id = "") ; 
    136           
    137       public : 
    138        
    139          /// Autres /// 
     137         static void recvSolveInheritanceContext(CEventServer& event); 
     138         void recvSolveInheritanceContext(CBufferIn& buffer); 
     139         static void recvPostProcessing(CEventServer& event); 
     140         void recvPostProcessing(CBufferIn& buffer); 
     141 
     142         // dispatch event 
     143         static bool dispatchEvent(CEventServer& event) ; 
     144 
     145      public: 
     146        // Get current context 
     147        static CContext* getCurrent(void); 
     148 
     149        // Get context root 
     150        static CContextGroup* getRoot(void); 
     151 
     152        // Set current context 
     153        static void setCurrent(const string& id); 
     154 
     155        // Create new context 
     156        static CContext* create(const string& id = ""); 
     157 
     158        /// Accesseurs statiques /// 
     159        static StdString GetName(void); 
     160        static StdString GetDefName(void); 
     161        static ENodeType GetType(void); 
     162 
     163        static CContextGroup* GetContextGroup(void); 
     164 
     165        // Some functions to visualize structure of current context 
     166        static void ShowTree(StdOStream & out = std::clog); 
     167        static void CleanTree(void); 
     168 
     169      public : 
     170         // Parse xml node and write all info into context 
    140171         virtual void parse(xml::CXMLNode & node); 
    141172 
     173         // Visualize a context 
    142174         virtual StdString toString(void) const; 
    143 //         virtual void toBinary  (StdOStream & os) const; 
    144 //         virtual void fromBinary(StdIStream & is); 
    145           
    146       public : 
    147        
    148          boost::shared_ptr<CCalendar>      calendar; 
    149   
     175 
     176 
     177         // Solve all inheritance relation in current context 
     178         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); 
     179 
     180         // Verify if all root definition in a context have children 
     181         virtual bool hasChild(void) const; 
     182 
     183      public : 
     184         // Calendar of context 
     185         boost::shared_ptr<CCalendar>   calendar; 
     186 
     187         // List of all enabled files (files on which fields are written) 
    150188         std::vector<CFile*> enabledFiles; 
     189 
     190         // Context root 
    151191         static shared_ptr<CContextGroup> root ; 
    152192 
     193         // Determine context on client or not 
     194         bool hasClient ; 
     195 
     196         // Determine context on server or not 
     197         bool hasServer ; 
     198 
     199         // Concrete context server 
     200         CContextServer* server ; 
     201 
     202         // Concrete contex client 
     203         CContextClient* client ; 
     204 
     205      private: 
     206         bool isPostProcessed; 
     207         std::map<int, StdSize> dataSize_; 
     208 
     209 
     210      public: // Some function maybe removed in the near future 
     211        // virtual void toBinary  (StdOStream & os) const; 
     212        // virtual void fromBinary(StdIStream & is); 
     213        // void solveAllGridRef(void); 
     214        // void solveAllOperation(void); 
     215        // void solveAllExpression(void); 
     216        // void solveFieldRefInheritance(bool apply); 
    153217 
    154218   }; // class CContext 
Note: See TracChangeset for help on using the changeset viewer.