[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" |
---|
[219] | 31 | END_DECLARE_ATTRIBUTE_MAP(CAxis) |
---|
| 32 | |
---|
| 33 | ///-------------------------------------------------------------- |
---|
| 34 | |
---|
| 35 | class CAxis |
---|
| 36 | : public CObjectTemplate<CAxis> |
---|
| 37 | , public CAxisAttributes |
---|
| 38 | { |
---|
[987] | 39 | /// typedef /// |
---|
| 40 | typedef CObjectTemplate<CAxis> SuperClass; |
---|
| 41 | typedef CAxisAttributes SuperClassAttribute; |
---|
| 42 | |
---|
[1235] | 43 | public: |
---|
[567] | 44 | enum EEventId |
---|
| 45 | { |
---|
[1144] | 46 | EVENT_ID_DISTRIBUTION_ATTRIBUTE, |
---|
[633] | 47 | EVENT_ID_DISTRIBUTED_VALUE, |
---|
[1025] | 48 | EVENT_ID_NON_DISTRIBUTED_VALUE, |
---|
| 49 | EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES, |
---|
| 50 | EVENT_ID_DISTRIBUTED_ATTRIBUTES |
---|
[567] | 51 | } ; |
---|
| 52 | |
---|
[1235] | 53 | public: |
---|
[219] | 54 | typedef CAxisAttributes RelAttributes; |
---|
| 55 | typedef CAxisGroup RelGroup; |
---|
[621] | 56 | typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; |
---|
[219] | 57 | |
---|
[621] | 58 | public: |
---|
[219] | 59 | /// Constructeurs /// |
---|
| 60 | CAxis(void); |
---|
| 61 | explicit CAxis(const StdString & id); |
---|
| 62 | CAxis(const CAxis & axis); // Not implemented yet. |
---|
| 63 | CAxis(const CAxis * const axis); // Not implemented yet. |
---|
| 64 | |
---|
[622] | 65 | static CAxis* createAxis(); |
---|
[1158] | 66 | |
---|
| 67 | /// Accesseurs /// |
---|
| 68 | const std::set<StdString> & getRelFiles(void) const; |
---|
| 69 | |
---|
[1639] | 70 | int getNumberWrittenIndexes(MPI_Comm writtenCom); |
---|
| 71 | int getTotalNumberWrittenIndexes(MPI_Comm writtenCom); |
---|
| 72 | int getOffsetWrittenIndexes(MPI_Comm writtenCom); |
---|
| 73 | CArray<int, 1>& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom); |
---|
[676] | 74 | |
---|
[1371] | 75 | std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 76 | CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
[731] | 77 | |
---|
[219] | 78 | /// Test /// |
---|
| 79 | bool IsWritten(const StdString & filename) const; |
---|
[676] | 80 | bool isWrittenCompressed(const StdString& filename) const; |
---|
[594] | 81 | bool isDistributed(void) const; |
---|
[676] | 82 | bool isCompressible(void) const; |
---|
[219] | 83 | |
---|
| 84 | /// Mutateur /// |
---|
| 85 | void addRelFile(const StdString & filename); |
---|
[676] | 86 | void addRelFileCompressed(const StdString& filename); |
---|
[219] | 87 | |
---|
[1869] | 88 | |
---|
[219] | 89 | |
---|
| 90 | /// Destructeur /// |
---|
| 91 | virtual ~CAxis(void); |
---|
| 92 | |
---|
[619] | 93 | virtual void parse(xml::CXMLNode & node); |
---|
| 94 | |
---|
[1345] | 95 | void setContextClient(CContextClient* contextClient); |
---|
| 96 | |
---|
[219] | 97 | /// Accesseurs statiques /// |
---|
| 98 | static StdString GetName(void); |
---|
| 99 | static StdString GetDefName(void); |
---|
| 100 | static ENodeType GetType(void); |
---|
| 101 | |
---|
[1235] | 102 | static bool dispatchEvent(CEventServer& event); |
---|
[1869] | 103 | |
---|
| 104 | /// Vérifications /// |
---|
| 105 | void checkAttributes(void); |
---|
| 106 | bool checkAttributes_done_ = false ; |
---|
[1235] | 107 | |
---|
[742] | 108 | void checkAttributesOnClient(); |
---|
[927] | 109 | void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 110 | CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
[567] | 111 | void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 112 | CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
[619] | 113 | |
---|
[676] | 114 | void checkEligibilityForCompressedOutput(); |
---|
[1215] | 115 | size_t getGlobalWrittenSize(void) ; |
---|
[676] | 116 | |
---|
[1129] | 117 | void computeWrittenIndex(); |
---|
[1639] | 118 | void computeWrittenCompressedIndex(MPI_Comm); |
---|
[619] | 119 | bool hasTransformation(); |
---|
| 120 | void solveInheritanceTransformation(); |
---|
[1144] | 121 | TransMapTypes getAllTransformations(); |
---|
[836] | 122 | void duplicateTransformation(CAxis*); |
---|
| 123 | CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
[1158] | 124 | bool isEqual(CAxis* axis); |
---|
[619] | 125 | |
---|
[1235] | 126 | public: |
---|
| 127 | bool hasValue; |
---|
[1558] | 128 | bool hasBounds; |
---|
| 129 | bool hasLabel; |
---|
| 130 | |
---|
[1637] | 131 | CArray<int,1> localIndexToWriteOnServer; |
---|
[1869] | 132 | |
---|
| 133 | void computeConnectedClients(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid); |
---|
| 134 | private: std::set<CContextClient*> computeConnectedClients_done_ ; public : |
---|
| 135 | /** The number of server of a context client. Avoid to re-compute indice computed in a previous computeConnectedClient */ |
---|
| 136 | private: std::set<int> listNbServer_ ; public: |
---|
[676] | 137 | |
---|
| 138 | private: |
---|
[551] | 139 | void checkData(); |
---|
| 140 | void checkMask(); |
---|
[1158] | 141 | void checkBounds(); |
---|
| 142 | void checkLabel(); |
---|
[1870] | 143 | public: |
---|
| 144 | void sendAxisToFileServer(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid) ; |
---|
| 145 | private: |
---|
| 146 | std::set<CContextClient*> sendAxisToFileServer_done_ ; |
---|
| 147 | |
---|
[1875] | 148 | public: |
---|
| 149 | void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ; |
---|
[1870] | 150 | private: |
---|
[1875] | 151 | std::set<CContextClient*> sendAxisToCouplerOut_done_ ; |
---|
| 152 | |
---|
| 153 | public: |
---|
| 154 | void makeAliasForCoupling(const string& fieldId, int posInGrid) ; |
---|
| 155 | |
---|
| 156 | private: |
---|
[1870] | 157 | void sendAttributes(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
[1875] | 158 | CServerDistributionDescription::ServerDistributionType distType, const string& axisId=""); |
---|
[1870] | 159 | void sendDistributionAttribute(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
[1875] | 160 | CServerDistributionDescription::ServerDistributionType distType, const string& axisId=""); |
---|
[1869] | 161 | |
---|
[595] | 162 | |
---|
[1875] | 163 | void sendNonDistributedAttributes(CContextClient* client, const string& axisId=""); |
---|
| 164 | void sendDistributedAttributes(CContextClient* client, const string& axisId=""); |
---|
[619] | 165 | |
---|
[1025] | 166 | static void recvNonDistributedAttributes(CEventServer& event); |
---|
| 167 | static void recvDistributedAttributes(CEventServer& event); |
---|
[1235] | 168 | static void recvDistributionAttribute(CEventServer& event); |
---|
[1025] | 169 | void recvNonDistributedAttributes(int rank, CBufferIn& buffer); |
---|
| 170 | void recvDistributedAttributes(vector<int>& rank, vector<CBufferIn*> buffers); |
---|
[1235] | 171 | void recvDistributionAttribute(CBufferIn& buffer); |
---|
[1025] | 172 | |
---|
[621] | 173 | void setTransformations(const TransMapTypes&); |
---|
[676] | 174 | |
---|
[567] | 175 | private: |
---|
[1345] | 176 | |
---|
[1875] | 177 | /** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */ |
---|
[1353] | 178 | std::list<CContextClient*> clients; |
---|
| 179 | std::set<CContextClient*> clientsSet; |
---|
[1345] | 180 | |
---|
[1875] | 181 | private: |
---|
[1869] | 182 | /** define if the axis is completed or not ie all attributes have been received before in case |
---|
| 183 | of grid reading from file or coupling */ |
---|
| 184 | bool isCompleted_=true ; |
---|
[1875] | 185 | public: |
---|
| 186 | /*! |
---|
| 187 | \brief Check if a axis is completed |
---|
| 188 | Before make any axis processing, we must be sure that all axis informations have |
---|
| 189 | been sent, for exemple when reading a grid in a file or when grid elements are sent by an |
---|
| 190 | other context (coupling). So all direct reference of the axis (axis_ref) must be also completed |
---|
| 191 | \return true if axis and axis reference are completed |
---|
| 192 | */ |
---|
| 193 | bool isCompleted(void) |
---|
| 194 | { |
---|
| 195 | if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false; |
---|
| 196 | else return isCompleted_ ; |
---|
| 197 | } |
---|
| 198 | void setCompleted(void) { isCompleted_=true ; } |
---|
| 199 | void unsetCompleted(void) { isCompleted_=false ; } |
---|
| 200 | |
---|
| 201 | private: |
---|
[219] | 202 | bool isChecked; |
---|
[567] | 203 | bool areClientAttributesChecked_; |
---|
[927] | 204 | bool isClientAfterTransformationChecked; |
---|
[676] | 205 | std::set<StdString> relFiles, relFilesCompressed; |
---|
[1143] | 206 | TransMapTypes transformationMap_; |
---|
[676] | 207 | //! True if and only if the data defined on the axis can be outputted in a compressed way |
---|
| 208 | bool isCompressible_; |
---|
[1869] | 209 | |
---|
[1337] | 210 | std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server |
---|
[1542] | 211 | std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server |
---|
[1236] | 212 | // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server |
---|
[1542] | 213 | std::unordered_map<size_t,size_t> globalLocalIndexMap_; |
---|
[1249] | 214 | std::map<int,int> numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; |
---|
| 215 | std::map<int, CArray<int, 1> > compressedIndexToWriteOnServer; |
---|
[1337] | 216 | std::map<int, std::vector<int> > connectedServerRank_; |
---|
[1235] | 217 | bool computedWrittenIndex_; |
---|
[1099] | 218 | |
---|
[836] | 219 | private: |
---|
| 220 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
| 221 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
| 222 | static bool dummyTransformationMapList_; |
---|
| 223 | |
---|
[540] | 224 | DECLARE_REF_FUNC(Axis,axis) |
---|
[219] | 225 | }; // class CAxis |
---|
| 226 | |
---|
| 227 | ///-------------------------------------------------------------- |
---|
| 228 | |
---|
| 229 | // Declare/Define CAxisGroup and CAxisDefinition |
---|
| 230 | DECLARE_GROUP(CAxis); |
---|
[335] | 231 | } // namespace xios |
---|
[219] | 232 | |
---|
[591] | 233 | #endif // __XIOS_CAxis__ |
---|