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