/*! \file server_distribution_description.hpp \author Ha NGUYEN \since 04 Jan 2015 \date 11 Jan 2016 \brief Description of index distribution on server(s). */ #ifndef __XIOS_SERVER_DISTRIBUTION_DESCRIPTION_HPP #define __XIOS_SERVER_DISTRIBUTION_DESCRIPTION_HPP #include "xios_spl.hpp" #include "array_new.hpp" #include namespace xios { /*! \class CServerDistributionDescription This class contains information that describe distribution of servers. */ class CServerDistributionDescription { public: enum ServerDistributionType { BAND_DISTRIBUTION, PLAN_DISTRIBUTION, ROOT_DISTRIBUTION }; /** Default constructor */ CServerDistributionDescription(const std::vector& globalDimensionSize, int nServer, ServerDistributionType serType=BAND_DISTRIBUTION); /** Default destructor */ virtual ~CServerDistributionDescription(); void computeServerDistribution(bool doComputeGlobalIndex = false, int positionDimensionDistributed = 1); std::vector computeServerGlobalIndexInRange(const std::pair& indexBeginEnd, int positionDimensionDistributed = 1); std::vector computeServerGlobalByElement(std::vector > >& indexServerOnElement, int rank, int clientSize, const CArray& axisDomainOrder, int positionDimensionDistributed = 1); std::vector > getServerIndexBegin() const; std::vector > getServerDimensionSizes() const; const std::vector >& getGlobalIndex() const; const std::unordered_map& getGlobalIndexRange() const; int getDimensionDistributed(); static int defaultDistributedDimension(int gridDimension, ServerDistributionType serType=BAND_DISTRIBUTION); protected: int computeBandDistribution(int nServer, int positionDimensionDistributed = 1); int computeRootDistribution(int nServer, int positionDimensionDistributed = 1); void computePlanDistribution(int nServer); void computeRangeProcIndex(int clientRank, int clientSize, int rangeProcSize, int& rangeBegin, int& rangeSize); private: std::vector > indexBegin_; //!< Begin index of each dimension std::vector > dimensionSizes_; //!< Size of each dimension std::vector nGlobal_; //!< Global size of each dimension //!< General case, index describes distribution of each server (rarely use) std::vector > vecGlobalIndex_; //!< In case we need only global index of one server with specific rank std::unordered_map globalIndex_; //!< Type of distribution on server side ServerDistributionType serverType_; //!< Number of server int nServer_; //!< Position of dimension distributed on server side (by default, the second dimension) int positionDimensionDistributed_; }; } // namespace xios #endif // __XIOS_SERVER_DISTRIBUTION_DESCRIPTION_HPP