[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 | |
---|
[1460] | 19 | #include "mpi_std.hpp" |
---|
| 20 | |
---|
[335] | 21 | namespace xios { |
---|
[219] | 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) |
---|
[231] | 32 | # include "axis_attribute.conf" |
---|
[821] | 33 | # include "axis_attribute_private.conf" |
---|
[219] | 34 | END_DECLARE_ATTRIBUTE_MAP(CAxis) |
---|
| 35 | |
---|
| 36 | ///-------------------------------------------------------------- |
---|
| 37 | |
---|
| 38 | class CAxis |
---|
| 39 | : public CObjectTemplate<CAxis> |
---|
| 40 | , public CAxisAttributes |
---|
| 41 | { |
---|
[1460] | 42 | /// typedef /// |
---|
| 43 | typedef CObjectTemplate<CAxis> SuperClass; |
---|
| 44 | typedef CAxisAttributes SuperClassAttribute; |
---|
| 45 | |
---|
| 46 | public: |
---|
[567] | 47 | enum EEventId |
---|
| 48 | { |
---|
[1460] | 49 | EVENT_ID_DISTRIBUTION_ATTRIBUTE, |
---|
[633] | 50 | EVENT_ID_DISTRIBUTED_VALUE, |
---|
[1460] | 51 | EVENT_ID_NON_DISTRIBUTED_VALUE, |
---|
| 52 | EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES, |
---|
| 53 | EVENT_ID_DISTRIBUTED_ATTRIBUTES |
---|
[567] | 54 | } ; |
---|
| 55 | |
---|
[1460] | 56 | public: |
---|
[219] | 57 | typedef CAxisAttributes RelAttributes; |
---|
| 58 | typedef CAxisGroup RelGroup; |
---|
[621] | 59 | typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; |
---|
[219] | 60 | |
---|
[621] | 61 | public: |
---|
[219] | 62 | /// Constructeurs /// |
---|
| 63 | CAxis(void); |
---|
| 64 | explicit CAxis(const StdString & id); |
---|
| 65 | CAxis(const CAxis & axis); // Not implemented yet. |
---|
| 66 | CAxis(const CAxis * const axis); // Not implemented yet. |
---|
| 67 | |
---|
[622] | 68 | static CAxis* createAxis(); |
---|
| 69 | |
---|
[219] | 70 | /// Accesseurs /// |
---|
| 71 | const std::set<StdString> & getRelFiles(void) const; |
---|
| 72 | |
---|
[1460] | 73 | int getNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom); |
---|
| 74 | int getTotalNumberWrittenIndexes(ep_lib::MPI_Comm writtenCom); |
---|
| 75 | int getOffsetWrittenIndexes(ep_lib::MPI_Comm writtenCom); |
---|
| 76 | CArray<int, 1>& getCompressedIndexToWriteOnServer(ep_lib::MPI_Comm writtenCom); |
---|
[676] | 77 | |
---|
[1460] | 78 | std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
| 79 | CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
[731] | 80 | |
---|
[219] | 81 | /// Test /// |
---|
| 82 | bool IsWritten(const StdString & filename) const; |
---|
[676] | 83 | bool isWrittenCompressed(const StdString& filename) const; |
---|
[594] | 84 | bool isDistributed(void) const; |
---|
[676] | 85 | bool isCompressible(void) const; |
---|
[219] | 86 | |
---|
| 87 | /// Mutateur /// |
---|
| 88 | void addRelFile(const StdString & filename); |
---|
[676] | 89 | void addRelFileCompressed(const StdString& filename); |
---|
[219] | 90 | |
---|
| 91 | /// Vérifications /// |
---|
| 92 | void checkAttributes(void); |
---|
| 93 | |
---|
| 94 | /// Destructeur /// |
---|
| 95 | virtual ~CAxis(void); |
---|
| 96 | |
---|
[619] | 97 | virtual void parse(xml::CXMLNode & node); |
---|
| 98 | |
---|
[1460] | 99 | void setContextClient(CContextClient* contextClient); |
---|
| 100 | |
---|
[219] | 101 | /// Accesseurs statiques /// |
---|
| 102 | static StdString GetName(void); |
---|
| 103 | static StdString GetDefName(void); |
---|
| 104 | static ENodeType GetType(void); |
---|
| 105 | |
---|
[1460] | 106 | static bool dispatchEvent(CEventServer& event); |
---|
| 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(); |
---|
[1460] | 115 | size_t getGlobalWrittenSize(void) ; |
---|
[676] | 116 | |
---|
[1460] | 117 | void computeWrittenIndex(); |
---|
| 118 | void computeWrittenCompressedIndex(ep_lib::MPI_Comm); |
---|
[619] | 119 | bool hasTransformation(); |
---|
| 120 | void solveInheritanceTransformation(); |
---|
[1460] | 121 | TransMapTypes getAllTransformations(); |
---|
[836] | 122 | void duplicateTransformation(CAxis*); |
---|
| 123 | CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
[1106] | 124 | bool isEqual(CAxis* axis); |
---|
[1460] | 125 | bool zoomByIndex(); |
---|
[619] | 126 | |
---|
[1460] | 127 | public: |
---|
| 128 | bool hasValue; |
---|
| 129 | CArray<size_t,1> localIndexToWriteOnServer; |
---|
[676] | 130 | |
---|
| 131 | private: |
---|
[551] | 132 | void checkData(); |
---|
| 133 | void checkMask(); |
---|
[631] | 134 | void checkZoom(); |
---|
[633] | 135 | void checkBounds(); |
---|
[1460] | 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, |
---|
[815] | 142 | CServerDistributionDescription::ServerDistributionType distType); |
---|
[595] | 143 | |
---|
[1460] | 144 | void sendNonDistributedAttributes(void); |
---|
| 145 | void sendDistributedAttributes(void); |
---|
[619] | 146 | |
---|
[1460] | 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 | |
---|
[621] | 154 | void setTransformations(const TransMapTypes&); |
---|
[676] | 155 | |
---|
[567] | 156 | private: |
---|
[1460] | 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 | |
---|
[219] | 162 | bool isChecked; |
---|
[567] | 163 | bool areClientAttributesChecked_; |
---|
[927] | 164 | bool isClientAfterTransformationChecked; |
---|
[676] | 165 | std::set<StdString> relFiles, relFilesCompressed; |
---|
[1460] | 166 | TransMapTypes transformationMap_; |
---|
[676] | 167 | //! True if and only if the data defined on the axis can be outputted in a compressed way |
---|
| 168 | bool isCompressible_; |
---|
[1460] | 169 | std::map<int, map<int,int> > nbSenders; // Mapping of number of communicating client to a server |
---|
[1545] | 170 | std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server |
---|
[1460] | 171 | // std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server |
---|
[1545] | 172 | std::unordered_map<size_t,size_t> globalLocalIndexMap_; |
---|
[676] | 173 | std::vector<int> indexesToWrite; |
---|
[1460] | 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 hasBounds; |
---|
| 178 | bool hasLabel; |
---|
| 179 | bool computedWrittenIndex_; |
---|
[836] | 180 | |
---|
| 181 | private: |
---|
| 182 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
[1134] | 183 | static bool initializeTransformationMap(); |
---|
| 184 | static std::map<StdString, ETranformationType> *transformationMapList_ptr; |
---|
[1331] | 185 | #pragma omp threadprivate(transformationMapList_ptr) |
---|
[1328] | 186 | static bool dummyTransformationMapList_; |
---|
[1331] | 187 | #pragma omp threadprivate(dummyTransformationMapList_) |
---|
[1134] | 188 | |
---|
[540] | 189 | DECLARE_REF_FUNC(Axis,axis) |
---|
[219] | 190 | }; // class CAxis |
---|
| 191 | |
---|
| 192 | ///-------------------------------------------------------------- |
---|
| 193 | |
---|
| 194 | // Declare/Define CAxisGroup and CAxisDefinition |
---|
| 195 | DECLARE_GROUP(CAxis); |
---|
[335] | 196 | } // namespace xios |
---|
[219] | 197 | |
---|
[591] | 198 | #endif // __XIOS_CAxis__ |
---|