source: XIOS/dev/dev_trunk_omp/src/node/axis.hpp @ 1661

Last change on this file since 1661 was 1661, checked in by yushan, 5 years ago

MARK: branch merged with trunk @1660. Test (test_complete, test_remap) on ADA with IntelMPI and _usingEP/_usingMPI as switch.

  • 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.8 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
19#include "mpi_std.hpp"
20
21namespace xios {
22   /// ////////////////////// Déclarations ////////////////////// ///
23
24   class CAxisGroup;
25   class CAxisAttributes;
26   class CAxis;
27
28   ///--------------------------------------------------------------
29
30   // Declare/Define CAxisAttribute
31   BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis)
32#  include "axis_attribute.conf"
33   END_DECLARE_ATTRIBUTE_MAP(CAxis)
34
35   ///--------------------------------------------------------------
36
37   class CAxis
38      : public CObjectTemplate<CAxis>
39      , public CAxisAttributes
40   {
41               /// typedef ///
42         typedef CObjectTemplate<CAxis>   SuperClass;
43         typedef CAxisAttributes SuperClassAttribute;
44         
45      public:
46         enum EEventId
47         {
48           EVENT_ID_DISTRIBUTION_ATTRIBUTE,           
49           EVENT_ID_DISTRIBUTED_VALUE,
50           EVENT_ID_NON_DISTRIBUTED_VALUE,
51           EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES,
52           EVENT_ID_DISTRIBUTED_ATTRIBUTES
53         } ;
54
55      public:
56         typedef CAxisAttributes RelAttributes;
57         typedef CAxisGroup      RelGroup;
58         typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes;
59
60      public:
61         /// Constructeurs ///
62         CAxis(void);
63         explicit CAxis(const StdString & id);
64         CAxis(const CAxis & axis);       // Not implemented yet.
65         CAxis(const CAxis * const axis); // Not implemented yet.
66
67         static CAxis* createAxis();
68
69         /// Accesseurs ///
70         const std::set<StdString> & getRelFiles(void) const;
71
72         int getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom);
73         int getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom);
74         int getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom);
75         CArray<int, 1>& getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom);
76
77         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
78                                                        CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
79
80         /// Test ///
81         bool IsWritten(const StdString & filename) const;
82         bool isWrittenCompressed(const StdString& filename) const;
83         bool isDistributed(void) const;
84         bool isCompressible(void) const;
85
86         /// Mutateur ///
87         void addRelFile(const StdString & filename);
88         void addRelFileCompressed(const StdString& filename);
89
90         /// Vérifications ///
91         void checkAttributes(void);
92
93         /// Destructeur ///
94         virtual ~CAxis(void);
95
96         virtual void parse(xml::CXMLNode & node);
97
98         void setContextClient(CContextClient* contextClient);
99
100         /// Accesseurs statiques ///
101         static StdString GetName(void);
102         static StdString GetDefName(void);
103         static ENodeType GetType(void);
104
105         static bool dispatchEvent(CEventServer& event);         
106         
107         void checkAttributesOnClient();
108         void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid,
109                                                         CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION);
110         void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
111                                    CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
112
113         void checkEligibilityForCompressedOutput();
114         size_t getGlobalWrittenSize(void) ;
115
116         void computeWrittenIndex();
117         void computeWrittenCompressedIndex(ep_lib::MPI_Comm);
118         bool hasTransformation();
119         void solveInheritanceTransformation();
120         TransMapTypes getAllTransformations();         
121         void duplicateTransformation(CAxis*);
122         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id="");
123         bool isEqual(CAxis* axis);
124
125      public: 
126        bool hasValue;       
127        bool hasBounds;
128        bool hasLabel;
129
130        CArray<int,1> localIndexToWriteOnServer;
131
132      private:
133         void checkData();
134         void checkMask();
135         void checkBounds();
136         void checkLabel();
137         void sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid,
138                             CServerDistributionDescription::ServerDistributionType distType);
139         void sendDistributionAttribute(const std::vector<int>& globalDim, int orderPositionInGrid,
140                                        CServerDistributionDescription::ServerDistributionType distType);
141         void computeConnectedClients(const std::vector<int>& globalDim, int orderPositionInGrid,
142                                     CServerDistributionDescription::ServerDistributionType distType);
143
144         void sendNonDistributedAttributes(void);
145         void sendDistributedAttributes(void);
146
147         static void recvNonDistributedAttributes(CEventServer& event);
148         static void recvDistributedAttributes(CEventServer& event);
149         static void recvDistributionAttribute(CEventServer& event);
150         void recvNonDistributedAttributes(int rank, CBufferIn& buffer);
151         void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers);
152         void recvDistributionAttribute(CBufferIn& buffer);
153
154         void setTransformations(const TransMapTypes&);
155
156      private:
157
158/** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */
159         std::list<CContextClient*> clients;
160         std::set<CContextClient*> clientsSet;
161
162         bool isChecked;
163         bool areClientAttributesChecked_;
164         bool isClientAfterTransformationChecked;
165         std::set<StdString> relFiles, relFilesCompressed;
166         TransMapTypes transformationMap_;         
167         //! True if and only if the data defined on the axis can be outputted in a compressed way
168         bool isCompressible_;
169         std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
170         std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
171         // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
172         std::unordered_map<size_t,size_t> globalLocalIndexMap_;
173         std::vector<int> indexesToWrite;
174         std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
175         std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer;
176         std::map<int, std::vector<int> > connectedServerRank_;
177         bool computedWrittenIndex_;                 
178
179       private:
180         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
181         static bool initializeTransformationMap();
182         static std::map<StdString, ETranformationType> *transformationMapList_ptr;
183         #pragma omp threadprivate(transformationMapList_ptr)
184
185         DECLARE_REF_FUNC(Axis,axis)
186   }; // class CAxis
187
188   ///--------------------------------------------------------------
189
190   // Declare/Define CAxisGroup and CAxisDefinition
191   DECLARE_GROUP(CAxis);
192} // namespace xios
193
194#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.