#ifndef __XIOS_CAxis__ #define __XIOS_CAxis__ /// XIOS headers /// #include "xios_spl.hpp" #include "group_factory.hpp" #include "virtual_node.hpp" #include "declare_group.hpp" #include "declare_ref_func.hpp" #include "declare_virtual_node.hpp" #include "attribute_array.hpp" #include "attribute_enum.hpp" #include "attribute_enum_impl.hpp" #include "server_distribution_description.hpp" #include "transformation.hpp" #include "transformation_enum.hpp" namespace xios { /// ////////////////////// DĂ©clarations ////////////////////// /// class CAxisGroup; class CAxisAttributes; class CAxis; ///-------------------------------------------------------------- // Declare/Define CAxisAttribute BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) # include "axis_attribute.conf" END_DECLARE_ATTRIBUTE_MAP(CAxis) ///-------------------------------------------------------------- class CAxis : public CObjectTemplate , public CAxisAttributes { /// typedef /// typedef CObjectTemplate SuperClass; typedef CAxisAttributes SuperClassAttribute; public: enum EEventId { EVENT_ID_DISTRIBUTION_ATTRIBUTE, EVENT_ID_DISTRIBUTED_VALUE, EVENT_ID_NON_DISTRIBUTED_VALUE, EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES, EVENT_ID_DISTRIBUTED_ATTRIBUTES } ; public: typedef CAxisAttributes RelAttributes; typedef CAxisGroup RelGroup; typedef CTransformation::TransformationMapTypes TransMapTypes; public: /// Constructeurs /// CAxis(void); explicit CAxis(const StdString & id); CAxis(const CAxis & axis); // Not implemented yet. CAxis(const CAxis * const axis); // Not implemented yet. static CAxis* createAxis(); /// Accesseurs /// const std::set & getRelFiles(void) const; int getNumberWrittenIndexes(MPI_Comm writtenCom); int getTotalNumberWrittenIndexes(MPI_Comm writtenCom); int getOffsetWrittenIndexes(MPI_Comm writtenCom); CArray& getCompressedIndexToWriteOnServer(MPI_Comm writtenCom); std::map getAttributesBufferSize(CContextClient* client, const std::vector& globalDim, int orderPositionInGrid, CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); /// Test /// bool IsWritten(const StdString & filename) const; bool isWrittenCompressed(const StdString& filename) const; bool isDistributed(void) const; bool isCompressible(void) const; /// Mutateur /// void addRelFile(const StdString & filename); void addRelFileCompressed(const StdString& filename); /// VĂ©rifications /// void checkAttributes(void); /// Destructeur /// virtual ~CAxis(void); virtual void parse(xml::CXMLNode & node); void setContextClient(CContextClient* contextClient); /// Accesseurs statiques /// static StdString GetName(void); static StdString GetDefName(void); static ENodeType GetType(void); static bool dispatchEvent(CEventServer& event); void checkAttributesOnClient(); void checkAttributesOnClientAfterTransformation(const std::vector& globalDim, int orderPositionInGrid, CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION); void sendCheckedAttributes(const std::vector& globalDim, int orderPositionInGrid, CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); void checkEligibilityForCompressedOutput(); size_t getGlobalWrittenSize(void) ; void computeWrittenIndex(); void computeWrittenCompressedIndex(MPI_Comm); bool hasTransformation(); void solveInheritanceTransformation(); TransMapTypes getAllTransformations(); void duplicateTransformation(CAxis*); CTransformation* addTransformation(ETranformationType transType, const StdString& id=""); bool isEqual(CAxis* axis); public: bool hasValue; bool hasBounds; bool hasLabel; CArray localIndexToWriteOnServer; private: void checkData(); void checkMask(); void checkBounds(); void checkLabel(); void sendAttributes(const std::vector& globalDim, int orderPositionInGrid, CServerDistributionDescription::ServerDistributionType distType); void sendDistributionAttribute(const std::vector& globalDim, int orderPositionInGrid, CServerDistributionDescription::ServerDistributionType distType); void computeConnectedClients(const std::vector& globalDim, int orderPositionInGrid, CServerDistributionDescription::ServerDistributionType distType); void sendNonDistributedAttributes(void); void sendDistributedAttributes(void); static void recvNonDistributedAttributes(CEventServer& event); static void recvDistributedAttributes(CEventServer& event); static void recvDistributionAttribute(CEventServer& event); void recvNonDistributedAttributes(int rank, CBufferIn& buffer); void recvDistributedAttributes(vector& rank, vector buffers); void recvDistributionAttribute(CBufferIn& buffer); void setTransformations(const TransMapTypes&); private: /** Clients that have to send a domain. There can be multiple clients in case of secondary server, otherwise only one client. */ std::list clients; std::set clientsSet; bool isChecked; bool areClientAttributesChecked_; bool isClientAfterTransformationChecked; std::set relFiles, relFilesCompressed; TransMapTypes transformationMap_; //! True if and only if the data defined on the axis can be outputted in a compressed way bool isCompressible_; std::map > nbSenders; // Mapping of number of communicating client to a server std::map > > indSrv_; // Global index of each client sent to server // std::map > indWrittenSrv_; // Global written index of each client sent to server std::unordered_map globalLocalIndexMap_; std::map numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; std::map > compressedIndexToWriteOnServer; std::map > connectedServerRank_; bool computedWrittenIndex_; private: static bool initializeTransformationMap(std::map& m); static std::map transformationMapList_; static bool dummyTransformationMapList_; DECLARE_REF_FUNC(Axis,axis) }; // class CAxis ///-------------------------------------------------------------- // Declare/Define CAxisGroup and CAxisDefinition DECLARE_GROUP(CAxis); } // namespace xios #endif // __XIOS_CAxis__